From 3b188740e83298803d02c929751375707d06173d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 3 Mar 2025 20:12:01 +0200 Subject: [PATCH] fix: Make settings dialogs button order consistent (#84) Currently on Linux most dialogs follow the following order of action buttons: "OK", "Cancel" (left to right). However, several dialogs are constructed explicitly and don't follow this convention. This commit fixes this discrepancy. Fixes: https://github.com/Palm1r/QodeAssist/issues/83 --- settings/GeneralSettings.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/settings/GeneralSettings.cpp b/settings/GeneralSettings.cpp index 8097ec4..5f9ca70 100644 --- a/settings/GeneralSettings.cpp +++ b/settings/GeneralSettings.cpp @@ -42,6 +42,17 @@ namespace QodeAssist::Settings { +void addDialogButtons(QBoxLayout *layout, QAbstractButton *okButton, QAbstractButton *cancelButton) +{ +#if defined(Q_OS_MACOS) + layout->addWidget(cancelButton); + layout->addWidget(okButton); +#else + layout->addWidget(okButton); + layout->addWidget(cancelButton); +#endif +} + GeneralSettings &generalSettings() { static GeneralSettings settings; @@ -322,8 +333,7 @@ void GeneralSettings::showModelsNotSupportedDialog(Utils::StringAspect &aspect) auto cancelButton = new QPushButton(TrConstants::CANCEL); connect(cancelButton, &QPushButton::clicked, &dialog, &QDialog::reject); - dialog.buttonLayout()->addWidget(cancelButton); - dialog.buttonLayout()->addWidget(okButton); + addDialogButtons(dialog.buttonLayout(), okButton, cancelButton); modelList->setFocus(); dialog.exec(); @@ -362,8 +372,7 @@ void GeneralSettings::showUrlSelectionDialog( auto cancelButton = new QPushButton(TrConstants::CANCEL); connect(cancelButton, &QPushButton::clicked, &dialog, &QDialog::reject); - dialog.buttonLayout()->addWidget(cancelButton); - dialog.buttonLayout()->addWidget(okButton); + addDialogButtons(dialog.buttonLayout(), okButton, cancelButton); urlList->setFocus(); dialog.exec();