mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 01:53:25 -08:00
[Client] Settings: extract SettingsView from DlgSettings (#7482)
* [Client] Settings: extract SettingsView from DlgSettings Move the search bar, tab bar, stacked pages and search results out of DlgSettings into a reusable SettingsView widget. The dialog becomes a thin frame (title, OK button, close validation) delegating to the view. No visual or behavior change; tr() contexts preserved as DlgSettings. * [Client] Settings: match CI clang-format-18 line breaking --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
a12b97ec50
commit
679762c624
5 changed files with 625 additions and 519 deletions
98
cockatrice/src/interface/widgets/dialogs/settings_view.h
Normal file
98
cockatrice/src/interface/widgets/dialogs/settings_view.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* @file settings_view.h
|
||||
* @brief Settings content widget hosted by the settings dialog (and, later, the settings tab)
|
||||
* @ingroup Dialogs
|
||||
*/
|
||||
#ifndef SETTINGS_VIEW_H
|
||||
#define SETTINGS_VIEW_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class QModelIndex;
|
||||
class QObject;
|
||||
class QEvent;
|
||||
|
||||
class QStackedWidget;
|
||||
class QToolButton;
|
||||
class QListView;
|
||||
class QLineEdit;
|
||||
class AbstractSettingsPage;
|
||||
class SettingsSearchModel;
|
||||
class SettingsSearchDelegate;
|
||||
|
||||
/**
|
||||
* @brief Settings pages with tabbed navigation and search, without any dialog chrome
|
||||
*
|
||||
* Owns the search bar, the tab bar, the stacked settings pages and the search
|
||||
* results view. Dialog/tab hosts only add their own frame (buttons, titles).
|
||||
*/
|
||||
class SettingsView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Page order in the tab bar, matching the order pages are added in setupUi()
|
||||
*
|
||||
* Use these values instead of raw indices so reordering pages never silently
|
||||
* breaks external callers like tab_room.cpp.
|
||||
*/
|
||||
enum SettingsPage
|
||||
{
|
||||
GeneralPage = 0,
|
||||
AppearancePage,
|
||||
UserInterfacePage,
|
||||
DeckEditorPage,
|
||||
StoragePage,
|
||||
MessagesPage,
|
||||
SoundPage,
|
||||
ShortcutsPage,
|
||||
NumPages
|
||||
};
|
||||
|
||||
explicit SettingsView(QWidget *parent = nullptr);
|
||||
void setTab(int index);
|
||||
AbstractSettingsPage *page(SettingsPage which) const;
|
||||
|
||||
private slots:
|
||||
void onTabClicked(int index);
|
||||
void onSearchTextChanged(const QString &text);
|
||||
void onSearchResultClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
// UI elements
|
||||
QLineEdit *searchEdit; ///< Search bar for filtering settings
|
||||
QWidget *tabBarWidget; ///< Container widget for the tab buttons
|
||||
QList<QToolButton *> tabButtons; ///< Navigation tab buttons
|
||||
QStackedWidget *pagesWidget; ///< Stacked widget containing settings pages
|
||||
QListView *searchResultsView; ///< Search results list view
|
||||
QWidget *pagesContainer; ///< Container stacking pages and search results
|
||||
|
||||
// Data
|
||||
QList<AbstractSettingsPage *> pages; ///< All settings page instances
|
||||
SettingsSearchModel *searchModel; ///< Model for search results
|
||||
SettingsSearchDelegate *searchDelegate; ///< Delegate for search result rendering
|
||||
int currentTabIndex; ///< Currently active tab index
|
||||
bool searchActive; ///< Whether search mode is active
|
||||
|
||||
void setupUi();
|
||||
void setupTabBar();
|
||||
void buildSearchIndex();
|
||||
void switchToTabMode();
|
||||
void switchToSearchMode();
|
||||
void navigateToSearchResult(const QModelIndex &index);
|
||||
void setActiveTab(int index);
|
||||
static void flashWidget(QWidget *widget);
|
||||
static QStringList translatedPageNames();
|
||||
|
||||
void retranslateUi();
|
||||
void retranslateTabNames();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_VIEW_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue