add search bar to ZoneViewWidget

This commit is contained in:
RickyRister 2025-04-04 22:48:46 -07:00
parent dd37823a5d
commit caae0c8e10
3 changed files with 21 additions and 1 deletions

View file

@ -11,7 +11,7 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
{
setBackgroundBrush(QBrush(QColor(0, 0, 0)));
setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing);
setFocusPolicy(Qt::NoFocus);
setFocusPolicy(Qt::ClickFocus);
setViewportUpdateMode(BoundingRectViewportUpdate);
connect(scene, &GameScene::sceneRectChanged, this, &GameView::updateSceneRect);

View file

@ -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);

View file

@ -7,6 +7,7 @@
#include <QComboBox>
#include <QGraphicsProxyWidget>
#include <QGraphicsWidget>
#include <QLineEdit>
class QLabel;
class QPushButton;
@ -47,6 +48,8 @@ private:
QPushButton *closeButton;
QScrollBar *scrollBar;
ScrollableGraphicsProxyWidget *scrollBarProxy;
QLineEdit searchEdit;
QComboBox groupBySelector;
QComboBox sortBySelector;
QCheckBox shuffleCheckBox;