diff options
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r-- | src/qt/guiutil.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 0ea5060e76..32131bc39d 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -23,6 +23,8 @@ #include <QFileDialog> #include <QDesktopServices> #include <QThread> +#include <QSettings> +#include <QDesktopWidget> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> @@ -486,6 +488,29 @@ bool SetStartOnSystemStartup(bool fAutoStart) { return false; } #endif +void saveWindowGeometry(const QString& strSetting, QWidget *parent) +{ + QSettings settings; + settings.setValue(strSetting + "Pos", parent->pos()); + settings.setValue(strSetting + "Size", parent->size()); +} + +void restoreWindowGeometry(const QString& strSetting, const QSize& defaultSize, QWidget *parent) +{ + QSettings settings; + QPoint pos = settings.value(strSetting + "Pos").toPoint(); + QSize size = settings.value(strSetting + "Size", defaultSize).toSize(); + + if (!pos.x() && !pos.y()) { + QRect screen = QApplication::desktop()->screenGeometry(); + pos.setX((screen.width() - size.width()) / 2); + pos.setY((screen.height() - size.height()) / 2); + } + + parent->resize(size); + parent->move(pos); +} + HelpMessageBox::HelpMessageBox(QWidget *parent) : QMessageBox(parent) { |