aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLibravatar Keshav Bhatt <keshavnrj@gmail.com>2022-06-16 21:40:07 +0530
committerLibravatar Keshav Bhatt <keshavnrj@gmail.com>2022-06-16 21:40:07 +0530
commitd99090116cc9e99a1263cdf8b723ad910553f7d6 (patch)
tree481da1b45d638c91d6cb29aa2905259b59616658 /src
parent3a08d5d5801c7e902620e45305da838904bda1ab (diff)
downloadwhatsie-d99090116cc9e99a1263cdf8b723ad910553f7d6.tar.gz
whatsie-d99090116cc9e99a1263cdf8b723ad910553f7d6.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/settingswidget.cpp21
-rw-r--r--src/settingswidget.h2
2 files changed, 15 insertions, 8 deletions
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();