From a8d627e1dfb45944f8024d17856e73626ce7cb0a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 15 Mar 2009 17:48:20 +0000 Subject: [PATCH] - resize program preferences window if it does not fit with current screen resolution --- src/options_imp.cpp | 21 +++++++++++++++++++++ src/options_imp.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/options_imp.cpp b/src/options_imp.cpp index d050856d0..bd4dd9db1 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef Q_WS_WIN #include #endif @@ -240,6 +241,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ } // Tab selection mecanism connect(tabSelection, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); + // Adapt size + adaptToScreenSize(); } // Main destructor @@ -281,6 +284,24 @@ void options_imp::useStyle(){ } } +void options_imp::adaptToScreenSize() { + int scrn = 0; + QWidget *w = this->topLevelWidget(); + + if(w) + scrn = QApplication::desktop()->screenNumber(w); + else if(QApplication::desktop()->isVirtualDesktop()) + scrn = QApplication::desktop()->screenNumber(QCursor::pos()); + else + scrn = QApplication::desktop()->screenNumber(this); + + QRect desk(QApplication::desktop()->availableGeometry(scrn)); + if(width() > desk.width() || height() > desk.height()) { + if(desk.width() > 0 && desk.height() > 0) + resize(desk.width(), desk.height()); + } +} + void options_imp::saveOptions(){ applyButton->setEnabled(false); QSettings settings("qBittorrent", "qBittorrent"); diff --git a/src/options_imp.h b/src/options_imp.h index cc3515513..cb3b76159 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -159,6 +159,7 @@ class options_imp : public QDialog, private Ui::Dialog { void setSystrayOptionsState(int checkBoxValue); void enableWebUi(bool checkBoxValue); void changePage(QListWidgetItem*, QListWidgetItem*); + void adaptToScreenSize(); public slots: void setLocale(QString locale);