mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Client] Settings: sub-page rows deep-linking into page sections (#7487)
Add AbstractSettingsPage::getSections built from each page's group boxes. Show each multi-group page's sections as child rows in the navigation tree. Section rows show the parent page and scroll to and highlight the group box. Start pages collapsed. Keep single-group pages flat. Reworked to stay in the enlarged modal instead of the settings tab. Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
4974cac59a
commit
4750e67b7f
4 changed files with 132 additions and 13 deletions
|
|
@ -137,6 +137,30 @@ QList<SettingsSearchEntry> AbstractSettingsPage::getSearchEntries()
|
|||
return autoDetectSearchEntries(this, -1);
|
||||
}
|
||||
|
||||
QList<SettingsPageSection> AbstractSettingsPage::getSections()
|
||||
{
|
||||
QList<SettingsPageSection> sections;
|
||||
|
||||
// Walk the top-level layout in display order (creation order differs on some pages)
|
||||
if (QLayout *mainLayout = layout()) {
|
||||
for (int i = 0; i < mainLayout->count(); ++i) {
|
||||
QLayoutItem *item = mainLayout->itemAt(i);
|
||||
QWidget *widget = item ? item->widget() : nullptr;
|
||||
auto *groupBox = qobject_cast<QGroupBox *>(widget);
|
||||
if (!groupBox || groupBox->title().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
sections.append({groupBox->title(), groupBox});
|
||||
}
|
||||
}
|
||||
|
||||
// A single group is the page itself; sub-page entries would only duplicate it
|
||||
if (sections.size() < 2) {
|
||||
sections.clear();
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
|
||||
QList<SettingsSearchEntry> AbstractSettingsPage::autoDetectSearchEntries(QWidget *page, int pageIndex)
|
||||
{
|
||||
QList<SettingsSearchEntry> entries;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define COCKATRICE_ABSTRACT_SETTINGS_PAGE_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
|
|
@ -11,12 +12,28 @@
|
|||
|
||||
struct SettingsSearchEntry;
|
||||
|
||||
/**
|
||||
* @brief A navigable section of a settings page (one group box)
|
||||
*/
|
||||
struct SettingsPageSection
|
||||
{
|
||||
QString title; ///< Translated group title
|
||||
QWidget *sectionWidget = nullptr; ///< Group box to scroll to and highlight
|
||||
};
|
||||
|
||||
class AbstractSettingsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual void retranslateUi() = 0;
|
||||
virtual QList<SettingsSearchEntry> getSearchEntries();
|
||||
/**
|
||||
* @brief Sections of this page for sub-page navigation, in display order
|
||||
*
|
||||
* Scans the page's direct-child group boxes; pages with a single group
|
||||
* report no sections so the nav stays flat for them.
|
||||
*/
|
||||
QList<SettingsPageSection> getSections();
|
||||
|
||||
protected:
|
||||
static QList<SettingsSearchEntry> autoDetectSearchEntries(QWidget *page, int pageIndex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue