diff options
-rw-r--r-- | Swift/QtUI/QtSingleWindow.cpp | 27 | ||||
-rw-r--r-- | Swift/QtUI/QtSingleWindow.h | 5 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.cpp | 2 |
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())); |