From de1498c043eb1a85a76d253c0ae0ab5aa02063d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Krzemi=C5=84ski?= Date: Sat, 8 Aug 2015 21:04:24 +0200 Subject: [PATCH] fix #15 - window position in multi-screen environment --- src/forms/frmabout.cpp | 6 +++--- src/forms/frmcorrect.cpp | 6 +++--- src/forms/frmlistsubtitles.cpp | 6 +++--- src/forms/frmnapiprojektconfig.cpp | 4 ++++ src/forms/frmopensubtitlesconfig.cpp | 4 ++++ src/forms/frmoptions.cpp | 6 +++--- src/forms/frmprogress.cpp | 9 +++++++-- src/forms/frmreport.cpp | 6 +++--- src/forms/frmscan.cpp | 6 +++--- src/forms/frmsummary.cpp | 6 +++--- src/forms/frmupload.cpp | 6 +++--- 11 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/forms/frmabout.cpp b/src/forms/frmabout.cpp index fac0bed..402a24e 100644 --- a/src/forms/frmabout.cpp +++ b/src/forms/frmabout.cpp @@ -21,7 +21,7 @@ frmAbout::frmAbout(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) setAttribute(Qt::WA_QuitOnClose, false); ui.lbTitle->setText(QString("QNapi ") + QNAPI_DISPLAYABLE_VERSION); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } diff --git a/src/forms/frmcorrect.cpp b/src/forms/frmcorrect.cpp index fcc01c7..32219d0 100644 --- a/src/forms/frmcorrect.cpp +++ b/src/forms/frmcorrect.cpp @@ -29,9 +29,9 @@ frmCorrect::frmCorrect(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) connect(&postThread, SIGNAL(postFinished(bool)), this, SLOT(postFinished(bool))); connect(&postThread, SIGNAL(invalidUserPass()), this, SLOT(invalidUserPass())); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmCorrect::closeEvent(QCloseEvent *event) diff --git a/src/forms/frmlistsubtitles.cpp b/src/forms/frmlistsubtitles.cpp index 42fe0ca..785943b 100644 --- a/src/forms/frmlistsubtitles.cpp +++ b/src/forms/frmlistsubtitles.cpp @@ -20,9 +20,9 @@ frmListSubtitles::frmListSubtitles(QWidget *parent, Qt::WindowFlags f) { ui.setupUi(this); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmListSubtitles::setFileName(const QString & name) diff --git a/src/forms/frmnapiprojektconfig.cpp b/src/forms/frmnapiprojektconfig.cpp index 6c04171..32f1735 100644 --- a/src/forms/frmnapiprojektconfig.cpp +++ b/src/forms/frmnapiprojektconfig.cpp @@ -26,6 +26,10 @@ frmNapiProjektConfig::frmNapiProjektConfig(QWidget *parent, Qt::WindowFlags f) load(); connect(ui.pbRegister, SIGNAL(clicked()), this, SLOT(pbRegisterClicked())); + + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmNapiProjektConfig::accept() diff --git a/src/forms/frmopensubtitlesconfig.cpp b/src/forms/frmopensubtitlesconfig.cpp index abd2075..d803635 100644 --- a/src/forms/frmopensubtitlesconfig.cpp +++ b/src/forms/frmopensubtitlesconfig.cpp @@ -26,6 +26,10 @@ frmOpenSubtitlesConfig::frmOpenSubtitlesConfig(QWidget *parent, Qt::WindowFlags load(); connect(ui.pbRegister, SIGNAL(clicked()), this, SLOT(pbRegisterClicked())); + + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmOpenSubtitlesConfig::accept() diff --git a/src/forms/frmoptions.cpp b/src/forms/frmoptions.cpp index ee015e4..032814b 100644 --- a/src/forms/frmoptions.cpp +++ b/src/forms/frmoptions.cpp @@ -63,9 +63,9 @@ frmOptions::frmOptions(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) showAllEncodings(); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } frmOptions::~frmOptions() diff --git a/src/forms/frmprogress.cpp b/src/forms/frmprogress.cpp index 417c02a..eee6708 100644 --- a/src/forms/frmprogress.cpp +++ b/src/forms/frmprogress.cpp @@ -39,6 +39,10 @@ frmProgress::frmProgress(QWidget * parent, Qt::WindowFlags f) &getThread, SLOT(subtitlesSelected(int))); connect(&getThread, SIGNAL(finished()), this, SLOT(downloadFinished())); + + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmProgress::receiveRequest(const QString & request) @@ -99,8 +103,9 @@ bool frmProgress::download() if(!isVisible()) { - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); show(); } diff --git a/src/forms/frmreport.cpp b/src/forms/frmreport.cpp index 6127b19..f09c6ab 100644 --- a/src/forms/frmreport.cpp +++ b/src/forms/frmreport.cpp @@ -32,9 +32,9 @@ frmReport::frmReport(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) ui.cbProblem->setCurrentIndex(4); cbProblemChanged(); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmReport::closeEvent(QCloseEvent *event) diff --git a/src/forms/frmscan.cpp b/src/forms/frmscan.cpp index 6c1480a..62f513b 100644 --- a/src/forms/frmscan.cpp +++ b/src/forms/frmscan.cpp @@ -47,9 +47,9 @@ frmScan::frmScan(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) iconFilm = QIcon(":/ui/film.png"); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } frmScan::~frmScan() diff --git a/src/forms/frmsummary.cpp b/src/forms/frmsummary.cpp index 9d1dce6..ced7ee5 100644 --- a/src/forms/frmsummary.cpp +++ b/src/forms/frmsummary.cpp @@ -20,9 +20,9 @@ frmSummary::frmSummary(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) setAttribute(Qt::WA_QuitOnClose, false); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmSummary::setSummaryList(const QStringList & listSuccess, const QStringList & listFailures) diff --git a/src/forms/frmupload.cpp b/src/forms/frmupload.cpp index e788a29..99110de 100644 --- a/src/forms/frmupload.cpp +++ b/src/forms/frmupload.cpp @@ -35,9 +35,9 @@ frmUpload::frmUpload(QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) if(QFileInfo(GlobalConfig().previousDialogPath()).isDir()) ui.leSelectDirectory->setText(GlobalConfig().previousDialogPath()); - // workaround dla compiza? - move((QApplication::desktop()->width() - width()) / 2, - (QApplication::desktop()->height() - height()) / 2); + QRect position = frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); } void frmUpload::closeEvent(QCloseEvent *event)