From e11f1806b6d722e2ae016bba053ac0c91616d800 Mon Sep 17 00:00:00 2001 From: Roman Mindalev Date: Thu, 21 Mar 2013 00:03:21 +0400 Subject: [PATCH] Save & restore window size and position --- src/qt/bitcoingui.cpp | 20 +++++++++++++++++++- src/qt/bitcoingui.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 4f97a4815..89ce7d4a8 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -69,7 +70,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): rpcConsole(0), prevBlocks(0) { - resize(850, 550); + restoreWindowGeometry(); setWindowTitle(tr("Bitcoin") + " - " + tr("Wallet")); #ifndef Q_OS_MAC qApp->setWindowIcon(QIcon(":icons/bitcoin")); @@ -185,6 +186,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): BitcoinGUI::~BitcoinGUI() { + saveWindowGeometry(); if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu) trayIcon->hide(); #ifdef Q_OS_MAC @@ -466,6 +468,22 @@ 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(); + resize(size); + move(pos); +} + void BitcoinGUI::optionsClicked() { if(!clientModel || !clientModel->getOptionsModel()) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index b992bfdc6..77aa7ec99 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -108,6 +108,10 @@ private: void createTrayIcon(); /** 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 */