Show dialog centered

This commit is contained in:
Nicolas Mailloux 2021-04-02 21:06:15 -04:00
parent 8e9cdaac5a
commit c540c3bfdf
2 changed files with 8 additions and 1 deletions

View file

@ -4,6 +4,7 @@
#include <QFile> #include <QFile>
#include <QDebug> #include <QDebug>
#include <QProcess> #include <QProcess>
#include <QScreen>
generalDialog::generalDialog(QWidget *parent) : generalDialog::generalDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -49,6 +50,12 @@ generalDialog::generalDialog(QWidget *parent) :
// We shouldn't be there ;) // We shouldn't be there ;)
; ;
} }
// Centering dialog
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
int x = (screenGeometry.width() - this->width()) / 2;
int y = (screenGeometry.height() - this->height()) / 2;
this->move(x, y);
} }
generalDialog::~generalDialog() generalDialog::~generalDialog()

View file

@ -317,7 +317,7 @@ void settings::on_usbmsBtn_clicked()
usbms_t->start(); usbms_t->start();
} }
// Now I know that QStackedWidget exists... ;p // Now I know that QStackedWidgets exist... ;p
void settings::on_previousBtn_clicked() void settings::on_previousBtn_clicked()
{ {