fix(ui): reach the settings screen from the menu bar only

The settings screen was given a sidebar entry, but it is not a place to
browse from: the bar lists where the packages are, and preferences are
where you configure the application. It now opens from the Paramètres menu
and Ctrl+, and nowhere else.

Two consequences of it having no navigation button are handled rather than
left to chance: openSettingsPage() does the work a button would have done
(switch, reload, retitle, journal), and the sidebar unchecks itself on the
way in, since leaving the previous entry highlighted would point at the
wrong screen. Clicking a sidebar entry afterwards selects it as usual.
This commit is contained in:
BlackAngelTV committed 2026-09-28 21:15:16 +02:00
1 parent aff959bc4b
commit bbaf39144f
6 files changed
+45 -23

No files matched your search

+31 -14
View File
@@ -562,8 +562,8 @@ void MainWindow::setupSidebar() {
addNavButton(NavHistory, "history", "Historique", "Historique des actions");
addNavButton(NavLogs, "logs", "Logs", "Logs pacman");
addNavButton(NavPlugins, "plugin", "Plugins", "Gestionnaires de paquets et extensions");
addNavButton(NavSettings, "settings", "Paramètres",
"Journal, glisser-déposer, langue et mises à jour");
// No entry for the settings screen: it is not a place to browse from, and
// the menu bar is the one way in (see openSettingsPage).
connect(m_navGroup, &QButtonGroup::idClicked, this, &MainWindow::onNavChanged);
m_navGroup->button(NavDashboard)->setChecked(true);
@@ -754,7 +754,6 @@ void MainWindow::setupMenuBar() {
toolsMenu->addAction("Historique", this, [this, goTo] { goTo(NavHistory); });
toolsMenu->addAction("Logs pacman", this, [this, goTo] { goTo(NavLogs); });
toolsMenu->addAction("Plugins", this, [this, goTo] { goTo(NavPlugins); });
toolsMenu->addAction("Paramètres", this, [this, goTo] { goTo(NavSettings); });
toolsMenu->addSeparator();
toolsMenu->addAction("Prévisualiser les mises à jour", this, [this, goTo] {
goTo(NavUpdates);
@@ -767,7 +766,7 @@ void MainWindow::setupMenuBar() {
// The dedicated screen holds every preference; the two entries below are
// shortcuts to the one that would otherwise be a menu of its own.
settingsMenu->addAction("Ouvrir les paramètres", this,
[this, goTo] { goTo(NavSettings); });
&MainWindow::openSettingsPage);
settingsMenu->addSeparator();
QActionGroup* credGroup = new QActionGroup(this);
@@ -852,9 +851,7 @@ void MainWindow::setupShortcuts() {
m_navGroup->button(NavUpdates)->click();
});
// The convention every other application uses for its own settings.
bind(QKeySequence(QStringLiteral("Ctrl+,")), [this]() {
m_navGroup->button(NavSettings)->click();
});
bind(QKeySequence(QStringLiteral("Ctrl+,")), [this]() { openSettingsPage(); });
bind(QKeySequence(QStringLiteral("Ctrl+E")), [this]() {
LogManager::instance().logEvent(QStringLiteral("ui"),
QStringLiteral("export de la liste affichée"));
@@ -880,7 +877,6 @@ void MainWindow::onNavChanged(int id) {
case NavHistory: pageName = QStringLiteral("historique"); break;
case NavLogs: pageName = QStringLiteral("logs"); break;
case NavPlugins: pageName = QStringLiteral("plugins"); break;
case NavSettings: pageName = QStringLiteral("paramètres"); break;
default: break;
}
LogManager::instance().logEvent(
@@ -921,10 +917,6 @@ void MainWindow::onNavChanged(int id) {
m_pages->setCurrentWidget(m_plugins);
m_plugins->refresh();
break;
case NavSettings:
m_pages->setCurrentWidget(m_settings);
m_settings->refresh();
break;
default:
break;
}
@@ -935,9 +927,36 @@ void MainWindow::onNavChanged(int id) {
void MainWindow::onOpenPage(const QString& pageId) {
const int navId = m_navIdByPage.value(pageId, -1);
if (navId < 0) return;
// The settings screen has no navigation button to click, so it is opened
// directly; every other screen is reached by clicking its own button.
if (pageId == QLatin1String("settings")) {
openSettingsPage();
return;
}
if (QAbstractButton* button = m_navGroup->button(navId)) button->click();
}
// The settings screen is the one screen without a sidebar entry: it is not a
// destination to browse from, so the Paramètres menu and Ctrl+, are the only
// ways in. Everything a navigation button does for free — switching the stacked
// widget, reloading, retitling, journalling — is done here instead.
void MainWindow::openSettingsPage() {
LogManager::instance().logEvent(QStringLiteral("ui"),
QStringLiteral("navigation → paramètres"));
// Nothing stays selected in the sidebar: the settings screen is not one of
// the places it lists, and leaving the previous entry highlighted would
// point at the wrong screen. The group has to stop being exclusive first,
// otherwise it puts one of its buttons back as soon as none is checked.
m_navGroup->setExclusive(false);
for (QAbstractButton* button : m_navGroup->buttons()) button->setChecked(false);
m_navGroup->setExclusive(true);
m_pages->setCurrentWidget(m_settings);
m_settings->refresh();
updatePageTitle();
}
// Navigates to the Installed screen and opens the package the user clicked in
// the dashboard activity list.
void MainWindow::onOpenPackage(const QString& name) {
@@ -1172,8 +1191,6 @@ void MainWindow::retranslateUI() {
QT_TRANSLATE_NOOP("MainWindow", "Logs pacman")},
{NavPlugins, QT_TRANSLATE_NOOP("MainWindow", "Plugins"),
QT_TRANSLATE_NOOP("MainWindow", "Gestionnaires de paquets et extensions")},
{NavSettings, QT_TRANSLATE_NOOP("MainWindow", "Paramètres"),
QT_TRANSLATE_NOOP("MainWindow", "Journal, glisser-déposer, langue et mises à jour")},
};
for (const NavLabel& label : kNavLabels) {