aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-08-05 00:58:05 -0700
committerGavin Andresen <gavinandresen@gmail.com>2013-08-05 00:58:05 -0700
commita4ae02969e6c8fd6f17ac5f2f495149476463344 (patch)
treef39250736d5f36f722d11fd126a347b2b2189c17 /src/qt/guiutil.cpp
parentd687aaa31180a7a81362711608c697b53c2739e6 (diff)
parentc431e9f1f03023d216db0ff48d3d598e705c97f9 (diff)
Merge pull request #2827 from Diapolo/rpccon_winpos
Bitcoin-Qt: save and restore position of debug window
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r--src/qt/guiutil.cpp25
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)
{