aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoingui.cpp28
-rw-r--r--src/qt/bitcoingui.h4
-rw-r--r--src/qt/guiutil.cpp25
-rw-r--r--src/qt/guiutil.h5
-rw-r--r--src/qt/rpcconsole.cpp2
5 files changed, 34 insertions, 30 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 4ed734b9c9..8ec2f03fad 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -48,8 +48,6 @@
#endif
#include <QMimeData>
#include <QStyle>
-#include <QSettings>
-#include <QDesktopWidget>
#include <QListWidget>
#include <iostream>
@@ -67,7 +65,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
rpcConsole(0),
prevBlocks(0)
{
- restoreWindowGeometry();
+ GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this);
#ifndef Q_OS_MAC
if (!fIsTestnet)
@@ -165,7 +163,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
BitcoinGUI::~BitcoinGUI()
{
- saveWindowGeometry();
+ GUIUtil::saveWindowGeometry("nWindow", this);
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_OS_MAC
@@ -424,28 +422,6 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
}
#endif
-void BitcoinGUI::saveWindowGeometry()
-{
- QSettings settings;
- settings.setValue("nWindowPos", pos());
- settings.setValue("nWindowSize", size());
-}
-
-void BitcoinGUI::restoreWindowGeometry()
-{
- QSettings settings;
- QPoint pos = settings.value("nWindowPos").toPoint();
- QSize size = settings.value("nWindowSize", QSize(850, 550)).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);
- }
- resize(size);
- move(pos);
-}
-
void BitcoinGUI::optionsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 685ce8b430..6b9161539c 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -122,10 +122,6 @@ private:
void createTrayIcon(bool fIsTestnet);
/** Create system tray menu (or setup the dock menu) */
void createTrayIconMenu();
- /** Save window size and position */
- void saveWindowGeometry();
- /** Restore window size and position */
- void restoreWindowGeometry();
public slots:
/** Set number of connections shown in the UI */
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)
{
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index e2c7d18aa2..ca3e7fe91d 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -96,6 +96,11 @@ namespace GUIUtil
bool GetStartOnSystemStartup();
bool SetStartOnSystemStartup(bool fAutoStart);
+ /** Save window size and position */
+ void saveWindowGeometry(const QString& strSetting, QWidget *parent);
+ /** Restore window size and position */
+ void restoreWindowGeometry(const QString& strSetting, const QSize &defaultSizeIn, QWidget *parent);
+
/** Help message for Bitcoin-Qt, shown with --help. */
class HelpMessageBox : public QMessageBox
{
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index ef72b17201..8953c36579 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -187,6 +187,7 @@ RPCConsole::RPCConsole(QWidget *parent) :
historyPtr(0)
{
ui->setupUi(this);
+ GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this);
#ifndef Q_OS_MAC
ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export"));
@@ -209,6 +210,7 @@ RPCConsole::RPCConsole(QWidget *parent) :
RPCConsole::~RPCConsole()
{
+ GUIUtil::saveWindowGeometry("nRPCConsoleWindow", this);
emit stopExecutor();
delete ui;
}