Overhaul quick settings for VDS and PrintingSelector (#5602)

* Move show folders option next to the search bar.

* Add a new settings button and settings popup, move the folder visibility checkbox there and the ability to hide tags.

* Make popup not close when interacting with child widgets.

* Fix mocks.

* Include cog icon.

* Move PrintingSelector Display options to new quick settings widget.

* Adjust size before first show so as to not overflow.

* Add option to hide card size slider in VDS.

* Qt5 support.

* Fix some warnings by containerizing layouts because addChildLayout is silly.

* Fix an incorrect slot/signal assignment.

* Correct sub-categories for settings to persist them.

* Shuffle some slots and signals around to distinguish between the tag filter and the tags on the deck preview widgets.

* Add a quick setting to draw unused color identities and center them.

* Respect the setting on startup.

* Move card size slider to the quick settings menu.

* Move PrintingSelector card size slider to quick menu, adjust other layout from other options.

* Improve layout, add a gray border.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-02-10 17:50:08 +01:00 committed by GitHub
parent d1102939a2
commit 7c9bf75393
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 413 additions and 409 deletions

View file

@ -5,7 +5,6 @@
#include "printing_selector_card_search_widget.h"
#include "printing_selector_card_selection_widget.h"
#include "printing_selector_card_sorting_widget.h"
#include "printing_selector_view_options_toolbar_widget.h"
#include <QScrollBar>
@ -29,29 +28,49 @@ PrintingSelector::PrintingSelector(QWidget *parent,
: QWidget(parent), deckEditor(deckEditor), deckModel(deckModel), deckView(deckView)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layout = new QVBoxLayout();
layout = new QVBoxLayout(this);
setLayout(layout);
widgetLoadingBufferTimer = new QTimer(this);
// Initialize toolbar and widgets
viewOptionsToolbar = new PrintingSelectorViewOptionsToolbarWidget(this, this);
layout->addWidget(viewOptionsToolbar);
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
sortToolBar = new PrintingSelectorCardSortingWidget(this);
sortToolBar->setVisible(SettingsCache::instance().getPrintingSelectorSortOptionsVisible());
layout->addWidget(sortToolBar);
sortToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
displayOptionsWidget = new SettingsButtonWidget(this);
displayOptionsWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
// Create the checkbox for navigation buttons visibility
navigationCheckBox = new QCheckBox(this);
navigationCheckBox->setChecked(SettingsCache::instance().getPrintingSelectorNavigationButtonsVisible());
connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
&PrintingSelector::toggleVisibilityNavigationButtons);
connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setPrintingSelectorNavigationButtonsVisible);
cardSizeWidget =
new CardSizeWidget(displayOptionsWidget, flowWidget, SettingsCache::instance().getPrintingSelectorCardSize());
displayOptionsWidget->addSettingsWidget(sortToolBar);
displayOptionsWidget->addSettingsWidget(navigationCheckBox);
displayOptionsWidget->addSettingsWidget(cardSizeWidget);
sortAndOptionsContainer = new QWidget(this);
sortAndOptionsLayout = new QHBoxLayout(sortAndOptionsContainer);
sortAndOptionsLayout->setSpacing(3);
sortAndOptionsLayout->setContentsMargins(0, 0, 0, 0);
sortAndOptionsContainer->setLayout(sortAndOptionsLayout);
searchBar = new PrintingSelectorCardSearchWidget(this);
searchBar->setVisible(SettingsCache::instance().getPrintingSelectorSearchBarVisible());
layout->addWidget(searchBar);
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
sortAndOptionsLayout->addWidget(searchBar);
sortAndOptionsLayout->addWidget(displayOptionsWidget);
layout->addWidget(sortAndOptionsContainer);
layout->addWidget(flowWidget);
cardSizeWidget = new CardSizeWidget(this, flowWidget, SettingsCache::instance().getPrintingSelectorCardSize());
cardSizeWidget->setVisible(SettingsCache::instance().getPrintingSelectorCardSizeSliderVisible());
layout->addWidget(cardSizeWidget);
cardSelectionBar = new PrintingSelectorCardSelectionWidget(this);
cardSelectionBar->setVisible(SettingsCache::instance().getPrintingSelectorNavigationButtonsVisible());
layout->addWidget(cardSelectionBar);
@ -59,6 +78,13 @@ PrintingSelector::PrintingSelector(QWidget *parent,
// Connect deck model data change signal to update display
connect(deckModel, &DeckListModel::rowsInserted, this, &PrintingSelector::printingsInDeckChanged);
connect(deckModel, &DeckListModel::rowsRemoved, this, &PrintingSelector::printingsInDeckChanged);
retranslateUi();
}
void PrintingSelector::retranslateUi()
{
navigationCheckBox->setText(tr("Display Navigation Buttons"));
}
void PrintingSelector::printingsInDeckChanged()
@ -206,36 +232,6 @@ void PrintingSelector::getAllSetsForCurrentCard()
widgetLoadingBufferTimer->start(0); // Process as soon as possible
}
/**
* @brief Toggles the visibility of the sorting options toolbar.
*
* @param _state The visibility state to set.
*/
void PrintingSelector::toggleVisibilitySortOptions(bool _state)
{
sortToolBar->setVisible(_state);
}
/**
* @brief Toggles the visibility of the search bar.
*
* @param _state The visibility state to set.
*/
void PrintingSelector::toggleVisibilitySearchBar(bool _state)
{
searchBar->setVisible(_state);
}
/**
* @brief Toggles the visibility of the card size slider.
*
* @param _state The visibility state to set.
*/
void PrintingSelector::toggleVisibilityCardSizeSlider(bool _state)
{
cardSizeWidget->setVisible(_state);
}
/**
* @brief Toggles the visibility of the navigation buttons.
*

View file

@ -5,7 +5,9 @@
#include "../../../../game/cards/card_database.h"
#include "../cards/card_size_widget.h"
#include "../general/layout_containers/flow_widget.h"
#include "../quick_settings/settings_button_widget.h"
#include <QCheckBox>
#include <QLabel>
#include <QTreeView>
#include <QVBoxLayout>
@ -16,7 +18,7 @@
class PrintingSelectorCardSearchWidget;
class PrintingSelectorCardSelectionWidget;
class PrintingSelectorCardSortingWidget;
class PrintingSelectorViewOptionsToolbarWidget;
class PrintingSelectorViewOptionsWidget;
class TabDeckEditor;
class PrintingSelector : public QWidget
{
@ -24,16 +26,15 @@ class PrintingSelector : public QWidget
public:
PrintingSelector(QWidget *parent, TabDeckEditor *deckEditor, DeckListModel *deckModel, QTreeView *deckView);
void setCard(const CardInfoPtr &newCard, const QString &_currentZone);
void getAllSetsForCurrentCard();
public slots:
void retranslateUi();
void updateDisplay();
void selectPreviousCard();
void selectNextCard();
void toggleVisibilitySortOptions(bool _state);
void toggleVisibilitySearchBar(bool _state);
void toggleVisibilityCardSizeSlider(bool _state);
void toggleVisibilityNavigationButtons(bool _state);
private slots:
@ -41,7 +42,10 @@ private slots:
private:
QVBoxLayout *layout;
PrintingSelectorViewOptionsToolbarWidget *viewOptionsToolbar;
SettingsButtonWidget *displayOptionsWidget;
QWidget *sortAndOptionsContainer;
QHBoxLayout *sortAndOptionsLayout;
QCheckBox *navigationCheckBox;
PrintingSelectorCardSortingWidget *sortToolBar;
PrintingSelectorCardSearchWidget *searchBar;
FlowWidget *flowWidget;

View file

@ -18,8 +18,8 @@ const QStringList PrintingSelectorCardSortingWidget::SORT_OPTIONS = {SORT_OPTION
*/
PrintingSelectorCardSortingWidget::PrintingSelectorCardSortingWidget(PrintingSelector *parent) : parent(parent)
{
setMinimumWidth(300);
sortToolBar = new QHBoxLayout(this);
sortToolBar->setContentsMargins(9, 0, 9, 0);
sortOptionsSelector = new QComboBox(this);
sortOptionsSelector->addItems(SORT_OPTIONS);

View file

@ -1,140 +0,0 @@
#include "printing_selector_view_options_toolbar_widget.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
/**
* @class PrintingSelectorViewOptionsToolbarWidget
* @brief A widget that provides a toolbar for view options with collapsible and expandable functionality.
*
* This widget allows the user to collapse or expand the view options for the PrintingSelector,
* providing a more compact interface when collapsed and a full view of options when expanded.
*/
PrintingSelectorViewOptionsToolbarWidget::PrintingSelectorViewOptionsToolbarWidget(QWidget *_parent,
PrintingSelector *_printingSelector)
: QWidget(_parent), printingSelector(_printingSelector)
{
// Set up layout for the widget
layout = new QVBoxLayout();
layout->setContentsMargins(9, 0, 9, 0);
layout->setSpacing(0);
setLayout(layout);
// Set up the expanded widget with its layout
expandedWidget = new QWidget(this);
auto *expandedLayout = new QVBoxLayout(expandedWidget);
expandedLayout->setContentsMargins(0, 0, 0, 0);
expandedLayout->setSpacing(0);
// Collapse button to toggle between expanded and collapsed states
collapseButton = new QPushButton("", this);
collapseButton->setFixedSize(20, 20);
collapseButton->setToolTip("Collapse");
collapseButton->setStyleSheet("border: none;");
connect(collapseButton, &QPushButton::clicked, this, &PrintingSelectorViewOptionsToolbarWidget::collapse);
expandedLayout->addWidget(collapseButton, 0, Qt::AlignLeft);
// View options widget
viewOptions = new PrintingSelectorViewOptionsWidget(expandedWidget, printingSelector);
expandedLayout->addWidget(viewOptions);
expandedWidget->setLayout(expandedLayout);
// Set up the collapsed widget with its layout
collapsedWidget = new QWidget(this);
auto *collapsedLayout = new QHBoxLayout(collapsedWidget);
collapsedLayout->setContentsMargins(5, 0, 5, 0);
collapsedLayout->setSpacing(0);
// Expand button to show full options
expandButton = new QPushButton("", this);
expandButton->setFixedSize(20, 20);
expandButton->setToolTip("Expand");
expandButton->setStyleSheet("border: none;");
connect(expandButton, &QPushButton::clicked, this, &PrintingSelectorViewOptionsToolbarWidget::expand);
collapsedLayout->addWidget(expandButton);
// Label for collapsed state
auto *collapsedLabel = new QLabel(tr("Display Options"), this);
collapsedLayout->addWidget(collapsedLabel);
collapsedWidget->setLayout(collapsedLayout);
// Stack widget to switch between expanded and collapsed states
stackedWidget = new QStackedWidget(this);
stackedWidget->addWidget(expandedWidget);
stackedWidget->addWidget(collapsedWidget);
layout->addWidget(stackedWidget);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
// Default to the expanded widget
stackedWidget->setCurrentWidget(expandedWidget);
// Connect the stacked widget to update the layout when it changes
connect(stackedWidget, &QStackedWidget::currentChanged, this,
&PrintingSelectorViewOptionsToolbarWidget::onWidgetChanged);
}
/**
* @brief Toggles the widget to the collapsed state.
*/
void PrintingSelectorViewOptionsToolbarWidget::collapse()
{
stackedWidget->setCurrentWidget(collapsedWidget);
updateGeometry();
}
/**
* @brief Toggles the widget to the expanded state.
*/
void PrintingSelectorViewOptionsToolbarWidget::expand()
{
stackedWidget->setCurrentWidget(expandedWidget);
updateGeometry();
}
/**
* @brief Handles the geometry update when the stacked widget changes.
*
* This ensures that the parent layout is also updated when the widget's display state changes.
*/
void PrintingSelectorViewOptionsToolbarWidget::onWidgetChanged(int)
{
updateGeometry();
if (parentWidget() && parentWidget()->layout()) {
parentWidget()->layout()->invalidate();
}
}
/**
* @brief Provides the recommended size for the widget based on the current view.
*
* @return QSize The suggested size for the widget.
*/
QSize PrintingSelectorViewOptionsToolbarWidget::sizeHint() const
{
return stackedWidget->currentWidget()->sizeHint();
}
/**
* @brief Provides the minimum size required for the widget based on the current view.
*
* @return QSize The minimum size required for the widget.
*/
QSize PrintingSelectorViewOptionsToolbarWidget::minimumSizeHint() const
{
return stackedWidget->currentWidget()->minimumSizeHint();
}
/**
* @brief Returns the view options widget contained within this toolbar.
*
* @return PrintingSelectorViewOptionsWidget* The view options widget.
*/
PrintingSelectorViewOptionsWidget *PrintingSelectorViewOptionsToolbarWidget::getViewOptionsWidget() const
{
return viewOptions;
}

View file

@ -1,36 +0,0 @@
#ifndef PRINTING_SELECTOR_SORT_AND_SEARCH_TOOLBAR_WIDGET_H
#define PRINTING_SELECTOR_SORT_AND_SEARCH_TOOLBAR_WIDGET_H
#include "printing_selector.h"
#include "printing_selector_view_options_widget.h"
#include <QPushButton>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QWidget>
class PrintingSelectorViewOptionsToolbarWidget : public QWidget
{
Q_OBJECT
public:
explicit PrintingSelectorViewOptionsToolbarWidget(QWidget *parent, PrintingSelector *printingSelector);
void collapse();
void expand();
void onWidgetChanged(int);
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
PrintingSelectorViewOptionsWidget *getViewOptionsWidget() const;
private:
QVBoxLayout *layout;
PrintingSelector *printingSelector;
PrintingSelectorViewOptionsWidget *viewOptions;
QWidget *expandedWidget;
QPushButton *collapseButton;
QWidget *collapsedWidget;
QPushButton *expandButton;
QStackedWidget *stackedWidget;
};
#endif // PRINTING_SELECTOR_SORT_AND_SEARCH_TOOLBAR_WIDGET_H

View file

@ -1,63 +0,0 @@
#include "printing_selector_view_options_widget.h"
#include "../../../../settings/cache_settings.h"
/**
* @class PrintingSelectorViewOptionsWidget
* @brief A widget that provides the view options for the PrintingSelector, including checkboxes
* for sorting, search bar, card size slider, and navigation buttons.
*
* This widget allows the user to toggle the visibility of various interface components of the
* PrintingSelector through checkboxes. The state of the checkboxes is saved and restored using
* the `SettingsCache`.
*/
PrintingSelectorViewOptionsWidget::PrintingSelectorViewOptionsWidget(QWidget *parent,
PrintingSelector *_printingSelector)
: QWidget(parent), printingSelector(_printingSelector)
{
// Create the grid to hold the checkboxes
gridLayout = new QGridLayout(this);
setLayout(gridLayout);
// Create the checkbox for sorting options visibility
sortCheckBox = new QCheckBox(this);
sortCheckBox->setText(tr("Display Sorting Options"));
sortCheckBox->setChecked(SettingsCache::instance().getPrintingSelectorSortOptionsVisible());
connect(sortCheckBox, &QCheckBox::QT_STATE_CHANGED, printingSelector,
&PrintingSelector::toggleVisibilitySortOptions);
connect(sortCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setPrintingSelectorSortOptionsVisible);
// Create the checkbox for search bar visibility
searchCheckBox = new QCheckBox(this);
searchCheckBox->setText(tr("Display Search Bar"));
searchCheckBox->setChecked(SettingsCache::instance().getPrintingSelectorSearchBarVisible());
connect(searchCheckBox, &QCheckBox::QT_STATE_CHANGED, printingSelector,
&PrintingSelector::toggleVisibilitySearchBar);
connect(searchCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setPrintingSelectorSearchBarVisible);
// Create the checkbox for card size slider visibility
cardSizeCheckBox = new QCheckBox(this);
cardSizeCheckBox->setText(tr("Display Card Size Slider"));
cardSizeCheckBox->setChecked(SettingsCache::instance().getPrintingSelectorCardSizeSliderVisible());
connect(cardSizeCheckBox, &QCheckBox::QT_STATE_CHANGED, printingSelector,
&PrintingSelector::toggleVisibilityCardSizeSlider);
connect(cardSizeCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setPrintingSelectorCardSizeSliderVisible);
// Create the checkbox for navigation buttons visibility
navigationCheckBox = new QCheckBox(this);
navigationCheckBox->setText(tr("Display Navigation Buttons"));
navigationCheckBox->setChecked(SettingsCache::instance().getPrintingSelectorNavigationButtonsVisible());
connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, printingSelector,
&PrintingSelector::toggleVisibilityNavigationButtons);
connect(navigationCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setPrintingSelectorNavigationButtonsVisible);
// Add checkboxes to the grid
gridLayout->addWidget(sortCheckBox, 0, 0);
gridLayout->addWidget(searchCheckBox, 0, 1);
gridLayout->addWidget(cardSizeCheckBox, 1, 0);
gridLayout->addWidget(navigationCheckBox, 1, 1);
}

View file

@ -1,27 +0,0 @@
#ifndef PRINTING_SELECTOR_VIEW_OPTIONS_WIDGET_H
#define PRINTING_SELECTOR_VIEW_OPTIONS_WIDGET_H
#include "../general/layout_containers/flow_widget.h"
#include "printing_selector.h"
#include <QCheckBox>
#include <QHBoxLayout>
#include <QWidget>
class PrintingSelectorViewOptionsWidget : public QWidget
{
Q_OBJECT
public:
explicit PrintingSelectorViewOptionsWidget(QWidget *parent, PrintingSelector *_printingSelector);
private:
QGridLayout *gridLayout;
PrintingSelector *printingSelector;
QCheckBox *sortCheckBox;
QCheckBox *searchCheckBox;
QCheckBox *cardSizeCheckBox;
QCheckBox *navigationCheckBox;
};
#endif // PRINTING_SELECTOR_VIEW_OPTIONS_WIDGET_H