summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-11-09 23:41:36 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-12-23 11:46:07 (GMT)
commiteac8b0d41d9ba7609a22f0d84fabc488872cc547 (patch)
tree828a2b2124fad8895065d54a7cfb663970602d25 /Swift
parent0f186904e643fe99f178357746cc81fcfed0b7c7 (diff)
downloadswift-eac8b0d41d9ba7609a22f0d84fabc488872cc547.zip
swift-eac8b0d41d9ba7609a22f0d84fabc488872cc547.tar.bz2
Remember window splitter placement in netbook mode
Change-Id: I53ce03b9536e97766c4afd286f3b09a941693265
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtSingleWindow.cpp27
-rw-r--r--Swift/QtUI/QtSingleWindow.h5
-rw-r--r--Swift/QtUI/QtUIFactory.cpp2
3 files changed, 32 insertions, 2 deletions
diff --git a/Swift/QtUI/QtSingleWindow.cpp b/Swift/QtUI/QtSingleWindow.cpp
index 2a19dd4..733571f 100644
--- a/Swift/QtUI/QtSingleWindow.cpp
+++ b/Swift/QtUI/QtSingleWindow.cpp
@@ -7,10 +7,12 @@
#include <Swift/QtUI/QtSingleWindow.h>
#include <Swift/QtUI/QtSettingsProvider.h>
+#include <Swiften/Base/foreach.h>
namespace Swift {
static const QString SINGLE_WINDOW_GEOMETRY = QString("SINGLE_WINDOW_GEOMETRY");
+static const QString SINGLE_WINDOW_SPLITS = QString("SINGLE_WINDOW_SPLITS");
QtSingleWindow::QtSingleWindow(QtSettingsProvider* settings) : QSplitter() {
settings_ = settings;
@@ -18,12 +20,35 @@ QtSingleWindow::QtSingleWindow(QtSettingsProvider* settings) : QSplitter() {
if (geometryVariant.isValid()) {
restoreGeometry(geometryVariant.toByteArray());
}
+ connect(this, SIGNAL(splitterMoved(int, int)), this, SLOT(handleSplitterMoved(int, int)));
+ restoreSplitters();
+}
+QtSingleWindow::~QtSingleWindow() {
}
-QtSingleWindow::~QtSingleWindow() {
+void QtSingleWindow::handleSplitterMoved(int, int) {
+ QList<QVariant> variantValues;
+ QList<int> intValues = sizes();
+ foreach (int value, intValues) {
+ variantValues.append(QVariant(value));
+ }
+ settings_->getQSettings()->setValue(SINGLE_WINDOW_SPLITS, QVariant(variantValues));
+}
+
+void QtSingleWindow::restoreSplitters() {
+ QList<QVariant> variantValues = settings_->getQSettings()->value(SINGLE_WINDOW_SPLITS).toList();
+ QList<int> intValues;
+ foreach (QVariant value, variantValues) {
+ intValues.append(value.toInt());
+ }
+ setSizes(intValues);
+}
+void QtSingleWindow::insertAtFront(QWidget* widget) {
+ insertWidget(0, widget);
+ restoreSplitters();
}
void QtSingleWindow::handleGeometryChanged() {
diff --git a/Swift/QtUI/QtSingleWindow.h b/Swift/QtUI/QtSingleWindow.h
index 861eda7..6cbc3e4 100644
--- a/Swift/QtUI/QtSingleWindow.h
+++ b/Swift/QtUI/QtSingleWindow.h
@@ -12,14 +12,19 @@ namespace Swift {
class QtSettingsProvider;
class QtSingleWindow : public QSplitter {
+ Q_OBJECT
public:
QtSingleWindow(QtSettingsProvider* settings);
virtual ~QtSingleWindow();
+ void insertAtFront(QWidget* widget);
protected:
void resizeEvent(QResizeEvent*);
void moveEvent(QMoveEvent*);
+ private slots:
+ void handleSplitterMoved(int, int);
private:
void handleGeometryChanged();
+ void restoreSplitters();
private:
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index 40b4c16..008d042 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -86,7 +86,7 @@ MainWindow* QtUIFactory::createMainWindow(UIEventStream* eventStream) {
LoginWindow* QtUIFactory::createLoginWindow(UIEventStream* eventStream) {
loginWindow = new QtLoginWindow(eventStream, settings, timerFactory_);
if (netbookSplitter) {
- netbookSplitter->insertWidget(0, loginWindow);
+ netbookSplitter->insertAtFront(loginWindow);
}
connect(systemTray, SIGNAL(clicked()), loginWindow, SLOT(toggleBringToFront()));