summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-11-09 22:58:09 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-12-23 11:46:07 (GMT)
commit0f186904e643fe99f178357746cc81fcfed0b7c7 (patch)
treeea654ab00c5db894976ac8379e0556c8c6ed4802
parentb417643f363c3bc8c555d9eacd186f3eece089ce (diff)
downloadswift-0f186904e643fe99f178357746cc81fcfed0b7c7.zip
swift-0f186904e643fe99f178357746cc81fcfed0b7c7.tar.bz2
Remember single window size
Change-Id: Ic65eef49b415a7b8e1575b517cc758cb9c95defc
-rw-r--r--Swift/QtUI/QtSingleWindow.cpp25
-rw-r--r--Swift/QtUI/QtSingleWindow.h11
-rw-r--r--Swift/QtUI/QtSwift.cpp11
3 files changed, 40 insertions, 7 deletions
diff --git a/Swift/QtUI/QtSingleWindow.cpp b/Swift/QtUI/QtSingleWindow.cpp
index 6a87825..2a19dd4 100644
--- a/Swift/QtUI/QtSingleWindow.cpp
+++ b/Swift/QtUI/QtSingleWindow.cpp
@@ -6,9 +6,19 @@
#include <Swift/QtUI/QtSingleWindow.h>
+#include <Swift/QtUI/QtSettingsProvider.h>
+
namespace Swift {
-QtSingleWindow::QtSingleWindow() : QSplitter() {
+static const QString SINGLE_WINDOW_GEOMETRY = QString("SINGLE_WINDOW_GEOMETRY");
+
+QtSingleWindow::QtSingleWindow(QtSettingsProvider* settings) : QSplitter() {
+ settings_ = settings;
+ QVariant geometryVariant = settings_->getQSettings()->value(SINGLE_WINDOW_GEOMETRY);
+ if (geometryVariant.isValid()) {
+ restoreGeometry(geometryVariant.toByteArray());
+ }
+
}
@@ -16,4 +26,17 @@ QtSingleWindow::~QtSingleWindow() {
}
+void QtSingleWindow::handleGeometryChanged() {
+ settings_->getQSettings()->setValue(SINGLE_WINDOW_GEOMETRY, saveGeometry());
+
+}
+
+void QtSingleWindow::resizeEvent(QResizeEvent*) {
+ handleGeometryChanged();
+}
+
+void QtSingleWindow::moveEvent(QMoveEvent*) {
+ handleGeometryChanged();
+}
+
}
diff --git a/Swift/QtUI/QtSingleWindow.h b/Swift/QtUI/QtSingleWindow.h
index 996ab20..861eda7 100644
--- a/Swift/QtUI/QtSingleWindow.h
+++ b/Swift/QtUI/QtSingleWindow.h
@@ -9,12 +9,21 @@
#include <QSplitter>
namespace Swift {
+ class QtSettingsProvider;
class QtSingleWindow : public QSplitter {
public:
- QtSingleWindow();
+ QtSingleWindow(QtSettingsProvider* settings);
virtual ~QtSingleWindow();
+ protected:
+ void resizeEvent(QResizeEvent*);
+ void moveEvent(QMoveEvent*);
+ private:
+ void handleGeometryChanged();
+ private:
+
+ QtSettingsProvider* settings_;
};
}
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index c11c3fe..57386d4 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -124,11 +124,6 @@ QMap<QString, QString> QtSwift::loadEmoticonsFile(const QString& fileName) {
}
QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL), idleDetector_(&idleQuerier_, networkFactories_.getTimerFactory(), 1000) {
- if (options.count("netbook-mode")) {
- splitter_ = new QtSingleWindow();
- } else {
- splitter_ = NULL;
- }
QCoreApplication::setApplicationName(SWIFT_APPLICATION_NAME);
QCoreApplication::setOrganizationName(SWIFT_ORGANIZATION_NAME);
QCoreApplication::setOrganizationDomain(SWIFT_ORGANIZATION_DOMAIN);
@@ -142,6 +137,12 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
QMap<QString, QString> emoticons = loadEmoticonsFile(P2QSTRING((Paths::getExecutablePath() / "emoticons.txt").string()));
+ if (options.count("netbook-mode")) {
+ splitter_ = new QtSingleWindow(qtSettings_);
+ } else {
+ splitter_ = NULL;
+ }
+
int numberOfAccounts = 1;
try {
numberOfAccounts = options["multi-account"].as<int>();