Skip to content

Commit

Permalink
Merge pull request #11696 from m0dB/11642-pref-dialog-pagetitle
Browse files Browse the repository at this point in the history
on macos, set preferences dialog title to the selected page title
  • Loading branch information
daschuer authored Jul 3, 2023
2 parents b50bb7c + d3f437b commit e854d60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ bool DlgPrefControllers::handleTreeItemClick(QTreeWidgetItem* clickedItem) {
if (controllerIndex >= 0) {
DlgPrefController* pControllerDlg = m_controllerPages.value(controllerIndex);
if (pControllerDlg) {
m_pDlgPreferences->switchToPage(pControllerDlg);
const QString pageTitle = m_pControllersRootItem->text(0) + " - " +
clickedItem->text(0);
m_pDlgPreferences->switchToPage(pageTitle, pControllerDlg);
}
return true;
} else if (clickedItem == m_pControllersRootItem) {
// Switch to the root page and expand the controllers tree item.
m_pDlgPreferences->expandTreeItem(clickedItem);
m_pDlgPreferences->switchToPage(this);
const QString pageTitle = clickedItem->text(0);
m_pDlgPreferences->switchToPage(pageTitle, this);
return true;
}
return false;
Expand Down
15 changes: 12 additions & 3 deletions src/preferences/dialog/dlgpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ void DlgPreferences::changePage(QTreeWidgetItem* pCurrent, QTreeWidgetItem* pPre

for (PreferencesPage page : qAsConst(m_allPages)) {
if (pCurrent == page.pTreeItem) {
switchToPage(page.pDlg);
switchToPage(pCurrent->text(0), page.pDlg);
break;
}
}
}

void DlgPreferences::showSoundHardwarePage() {
switchToPage(m_soundPage.pDlg);
switchToPage(m_soundPage.pTreeItem->text(0), m_soundPage.pDlg);
contentsTreeWidget->setCurrentItem(m_soundPage.pTreeItem);
}

Expand Down Expand Up @@ -507,7 +507,16 @@ void DlgPreferences::expandTreeItem(QTreeWidgetItem* pItem) {
contentsTreeWidget->expandItem(pItem);
}

void DlgPreferences::switchToPage(DlgPreferencePage* pWidget) {
void DlgPreferences::switchToPage(const QString& pageTitle, DlgPreferencePage* pWidget) {
#ifdef __APPLE__
// According to Apple's Human Interface Guidelines, settings dialogs have to
// "Update the window’s title to reflect the currently visible pane."
// This also solves the problem of the changed in terminology, Settings instead
// of Preferences, since macOS Ventura.
setWindowTitle(pageTitle);
#else
Q_UNUSED(pageTitle);
#endif
pagesWidget->setCurrentWidget(pWidget->parentWidget()->parentWidget());

QPushButton* pButton = buttonBox->button(QDialogButtonBox::Help);
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
const QString& iconFile);
void removePageWidget(DlgPreferencePage* pWidget);
void expandTreeItem(QTreeWidgetItem* pItem);
void switchToPage(DlgPreferencePage* pPage);
void switchToPage(const QString& pageTitle, DlgPreferencePage* pPage);

public slots:
void changePage(QTreeWidgetItem* pCurrent, QTreeWidgetItem* pPrevious);
Expand Down

0 comments on commit e854d60

Please sign in to comment.