From d99090116cc9e99a1263cdf8b723ad910553f7d6 Mon Sep 17 00:00:00 2001 From: Keshav Bhatt Date: Thu, 16 Jun 2022 21:40:07 +0530 Subject: chore: improve settings window show behavior - show window on centre of screen where the mainwindow is located - show default pos if geometery is not saved --- src/settingswidget.cpp | 21 ++++++++++++++------- src/settingswidget.h | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp index 8e61b38..38624f8 100644 --- a/src/settingswidget.cpp +++ b/src/settingswidget.cpp @@ -13,7 +13,8 @@ extern int defaultAppAutoLockDuration; extern bool defaultAppAutoLock; extern double defaultZoomFactorMaximized; -SettingsWidget::SettingsWidget(QWidget *parent, QString engineCachePath, +SettingsWidget::SettingsWidget(QWidget *parent, int screenNumber, + QString engineCachePath, QString enginePersistentStoragePath) : QWidget(parent), ui(new Ui::SettingsWidget) { ui->setupUi(this); @@ -119,6 +120,10 @@ SettingsWidget::SettingsWidget(QWidget *parent, QString engineCachePath, ui->scrollAreaWidgetContents->layout()->spacing()); if (settings.value("settingsGeo").isValid()) { this->restoreGeometry(settings.value("settingsGeo").toByteArray()); + QRect screenRect = QGuiApplication::screens().at(screenNumber)->geometry(); + if(!screenRect.contains(this->pos())){ + this->move(screenRect.center()-this->rect().center()); + } } } @@ -489,10 +494,10 @@ void SettingsWidget::on_showShortcutsButton_clicked() { // handle special case for minimize to try action if (action->text().contains("minimize", Qt::CaseInsensitive) || action->text().contains("Mi&nimize to tray")) { - QLabel *label = new QLabel( - action->text().remove("&") + " | " + "Ctrl+W", sheet); - label->setAlignment(Qt::AlignHCenter); - layout->addWidget(label); + QLabel *label = + new QLabel(action->text().remove("&") + " | " + "Ctrl+W", sheet); + label->setAlignment(Qt::AlignHCenter); + layout->addWidget(label); } } } @@ -713,8 +718,10 @@ void SettingsWidget::on_chnageCurrentPasswordPushButton_clicked() { new QPushButton(this->style()->standardIcon(QStyle::SP_DialogYesButton), "Change password", nullptr); msgBox.addButton(changePassword, QMessageBox::NoRole); - connect(changePassword, &QPushButton::clicked, changePassword, - [=]() { this->close(); emit change_lock_password(); }); + connect(changePassword, &QPushButton::clicked, changePassword, [=]() { + this->close(); + emit change_lock_password(); + }); msgBox.exec(); } else { diff --git a/src/settingswidget.h b/src/settingswidget.h index ccf48ec..fdce322 100644 --- a/src/settingswidget.h +++ b/src/settingswidget.h @@ -31,7 +31,7 @@ signals: void appAutoLockChanged(); public: - explicit SettingsWidget(QWidget *parent = nullptr, + explicit SettingsWidget(QWidget *parent = nullptr,int screenNumber = 0, QString engineCachePath = "", QString enginePersistentStoragePath = ""); ~SettingsWidget(); -- cgit v1.2.3