mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
Add search filter to card view window (#5791)
* refactor out search syntax help window * add search bar to ZoneViewWidget * implement filter logic
This commit is contained in:
parent
ad06814ac7
commit
3b758962e4
10 changed files with 116 additions and 40 deletions
|
|
@ -1,7 +1,9 @@
|
|||
#include "view_zone_widget.h"
|
||||
|
||||
#include "../../client/ui/pixel_map_generator.h"
|
||||
#include "../../settings/cache_settings.h"
|
||||
#include "../cards/card_item.h"
|
||||
#include "../filters/syntax_help.h"
|
||||
#include "../game_scene.h"
|
||||
#include "../player/player.h"
|
||||
#include "pb/command_shuffle.pb.h"
|
||||
|
|
@ -41,9 +43,24 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
setFlag(ItemIgnoresTransformations);
|
||||
|
||||
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
||||
vbox->setSpacing(2);
|
||||
|
||||
// If the number is < 0, then it means that we can give the option to make the area sorted
|
||||
if (numberCards < 0) {
|
||||
// search edit
|
||||
searchEdit.setFocusPolicy(Qt::ClickFocus);
|
||||
searchEdit.setPlaceholderText(tr("Search by card name (or search expressions)"));
|
||||
searchEdit.setClearButtonEnabled(true);
|
||||
searchEdit.addAction(loadColorAdjustedPixmap("theme:icons/search"), QLineEdit::LeadingPosition);
|
||||
auto help = searchEdit.addAction(QPixmap("theme:icons/info"), QLineEdit::TrailingPosition);
|
||||
|
||||
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); });
|
||||
|
||||
QGraphicsProxyWidget *searchEditProxy = new QGraphicsProxyWidget;
|
||||
searchEditProxy->setWidget(&searchEdit);
|
||||
searchEditProxy->setZValue(2000000007);
|
||||
vbox->addItem(searchEditProxy);
|
||||
|
||||
// top row
|
||||
QGraphicsLinearLayout *hTopRow = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
|
||||
|
|
@ -128,6 +145,8 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
if (CardList::NoSort == static_cast<CardList::SortOption>(groupBySelector.currentData().toInt())) {
|
||||
pileViewCheckBox.setEnabled(false);
|
||||
}
|
||||
|
||||
connect(&searchEdit, &QLineEdit::textChanged, zone, &ZoneViewZone::setFilterString);
|
||||
}
|
||||
|
||||
setLayout(vbox);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue