diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-07-13 13:14:23 +0200 |
---|---|---|
committer | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-07-29 16:22:46 +0200 |
commit | c431e9f1f03023d216db0ff48d3d598e705c97f9 (patch) | |
tree | 6132628aa34888e6e9af93982c77d8afcff2f045 /src/qt/guiutil.cpp | |
parent | c4316fefa5f56d62eeceb710ee18313bd9be1128 (diff) |
Bitcoin-Qt: save and restore position of debug window
- move the code for saving and restoring window positions from BitcoinGUI
to GUIUtil, make it more generic and also use it for saving/restoring
debug window positions
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 521d9bddd8..d51b68e040 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -24,6 +24,8 @@ #include <QFileDialog> #include <QDesktopServices> #include <QThread> +#include <QSettings> +#include <QDesktopWidget> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> @@ -487,6 +489,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) { |