From 3007d95ceb2ef79412288f99b86a8db70138c700 Mon Sep 17 00:00:00 2001 From: bkkcoins Date: Fri, 21 Sep 2012 10:53:14 +0700 Subject: [PATCH] Added code to remember window position --- lib/gui_lite.py | 13 +++++++++++++ lib/gui_qt.py | 11 ++++++++++- lib/simple_config.py | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/gui_lite.py b/lib/gui_lite.py index 950598b14..bb267e365 100644 --- a/lib/gui_lite.py +++ b/lib/gui_lite.py @@ -5,6 +5,7 @@ from PyQt4.QtGui import * from decimal import Decimal as D from interface import DEFAULT_SERVERS +from simple_config import SimpleConfig from util import get_resource_path as rsrc from i18n import _ import decimal @@ -231,6 +232,12 @@ class MiniWindow(QDialog): close_shortcut = QShortcut(QKeySequence("Ctrl+W"), self) close_shortcut.activated.connect(self.close) + cfg = SimpleConfig() + g = cfg.config["winpos-lite"] + self.setGeometry(g[0], g[1], g[2], g[3]) + show_history.setChecked(cfg.config["history"]) + self.show_history(cfg.config["history"]) + self.setWindowIcon(QIcon(":electrum.png")) self.setWindowTitle("Electrum") self.setWindowFlags(Qt.Window|Qt.MSWindowsFixedSizeDialogHint) @@ -247,6 +254,12 @@ class MiniWindow(QDialog): QDir.setCurrent(old_path) def closeEvent(self, event): + cfg = SimpleConfig() + g = self.geometry() + cfg.config["winpos-lite"] = [g.left(),g.top(),g.width(),g.height()] + cfg.config["history"] = self.history_list.isVisible() + cfg.save_config() + super(MiniWindow, self).closeEvent(event) qApp.quit() diff --git a/lib/gui_qt.py b/lib/gui_qt.py index c619df375..5fdd2487c 100644 --- a/lib/gui_qt.py +++ b/lib/gui_qt.py @@ -38,6 +38,7 @@ except: from wallet import format_satoshis import bmp, mnemonic, pyqrnative, qrscanner +from simple_config import SimpleConfig from decimal import Decimal @@ -202,7 +203,9 @@ class ElectrumWindow(QMainWindow): tabs.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setCentralWidget(tabs) self.create_status_bar() - self.setGeometry(100,100,840,400) + cfg = SimpleConfig() + g = cfg.config["winpos-qt"] + self.setGeometry(g[0], g[1], g[2], g[3]) title = 'Electrum ' + self.wallet.electrum_version + ' - ' + self.wallet.path if not self.wallet.seed: title += ' [seedless]' self.setWindowTitle( title ) @@ -1423,6 +1426,12 @@ class ElectrumWindow(QMainWindow): return True + def closeEvent(self, event): + cfg = SimpleConfig() + g = self.geometry() + cfg.config["winpos-qt"] = [g.left(),g.top(),g.width(),g.height()] + cfg.save_config() + event.accept() class ElectrumGui: diff --git a/lib/simple_config.py b/lib/simple_config.py index 06f78bdc1..582cd057f 100644 --- a/lib/simple_config.py +++ b/lib/simple_config.py @@ -3,7 +3,7 @@ import os from util import user_dir class SimpleConfig: - default_options = {"gui": "lite"} + default_options = {"gui": "lite", "winpos-qt": [100, 100, 840, 400], "winpos-lite": [4, 25, 351, 149], "history": False } def set_key(self, key, value, save = True): self.config[key] = value