summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-02-09 17:10:08 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-10 10:45:45 -0800
commit57e938d040d290f055f6b9551f390717d53a779d (patch)
tree2485cf5efbc7b1be46969d2f1bf2c9f1bfb0db84 /qt-ui/mainwindow.cpp
parent93198a80986da2179088125e376691dd99da6dcc (diff)
downloadsubsurface-57e938d040d290f055f6b9551f390717d53a779d.tar.gz
Create the method that changes the state of the application
Not used yet. The idea is to call 'setApplicationState("plan");' and all widgegts for plan will be magically setup because we added the plan state with registerApplicationState. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 550c15d97..f1a27a11a 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -170,6 +170,7 @@ MainWindow::MainWindow() : QMainWindow(),
updateManager = new UpdateManager(this);
undoBuffer = new UndoBuffer(this);
+ setApplicationState("Default");
}
MainWindow::~MainWindow()
@@ -1505,3 +1506,25 @@ void MainWindow::registerApplicationState(const QByteArray& state, QWidget *topL
{
applicationState[state] = WidgetForBorder(topLeft, bottomLeft, topRight, bottomRight);
}
+
+void MainWindow::setApplicationState(const QByteArray& state) {
+ if (!applicationState.keys().contains(state))
+ return;
+
+ // yes, index is zero both times. please don't change it.
+ if (ui.topSplitter->count()) {
+ ui.topSplitter->widget(0)->setParent(NULL);
+ ui.topSplitter->widget(0)->setParent(NULL);
+ }
+ if (ui.bottomSplitter->count()) {
+ ui.bottomSplitter->widget(0)->setParent(NULL);
+ ui.bottomSplitter->widget(0)->setParent(NULL);
+ }
+
+
+ WidgetForBorder curr = applicationState[state];
+ ui.topSplitter->addWidget(curr.topLeft);
+ ui.topSplitter->addWidget(curr.topRight);
+ ui.bottomSplitter->addWidget(curr.bottomLeft);
+ ui.bottomSplitter->addWidget(curr.bottomRight);
+}