diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-05-03 19:19:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-05-13 07:08:34 -0700 |
commit | 57bf174c4f0092d25865b7f15b864c9bbaa45eda (patch) | |
tree | b535cea18d651ec3a665c7b6f1aefa015f695a4e /desktop-widgets/mainwindow.cpp | |
parent | 9d342d0e1aac56c44a80e5025d4cf3b89c5746cf (diff) | |
download | subsurface-57bf174c4f0092d25865b7f15b864c9bbaa45eda.tar.gz |
Desktop: On dive edit from the dive list or map, switch to new state
If "Edit dive" is selected from the dive list or the map view, switch
to a new mode, which shows the dive infos and the profile.
After the edit, switch back to the previous state.
Fixes #1213
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 74 |
1 files changed, 56 insertions, 18 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 910c7a290..4069d8405 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1228,6 +1228,61 @@ void MainWindow::on_actionViewAll_triggered() ui.bottomSplitter->setCollapsible(1,false); } +void MainWindow::enterEditState() +{ + stateBeforeEdit = state; + if (state == VIEWALL || state == INFO_MAXIMIZED) + return; + toggleCollapsible(true); + beginChangeState(EDIT); + ui.topSplitter->setSizes({ EXPANDED, EXPANDED }); + ui.mainSplitter->setSizes({ EXPANDED, COLLAPSED }); + int appW = qApp->desktop()->size().width(); + QList<int> infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) }; + + QSettings settings; + settings.beginGroup("MainWindow"); + if (settings.value("mainSplitter").isValid()) { + ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray()); + if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0) + ui.topSplitter->setSizes(infoProfileSizes); + } else { + ui.topSplitter->setSizes(infoProfileSizes); + } +} + +void MainWindow::exitEditState() +{ + if (stateBeforeEdit == state) + return; + enterState(stateBeforeEdit); +} + +void MainWindow::enterState(CurrentState newState) +{ + state = newState; + switch (state) { + case VIEWALL: + on_actionViewAll_triggered(); + break; + case MAP_MAXIMIZED: + on_actionViewMap_triggered(); + break; + case INFO_MAXIMIZED: + on_actionViewInfo_triggered(); + break; + case LIST_MAXIMIZED: + on_actionViewList_triggered(); + break; + case PROFILE_MAXIMIZED: + on_actionViewProfile_triggered(); + break; + case EDIT: + default: + break; + } +} + void MainWindow::beginChangeState(CurrentState s) { if (state == VIEWALL && state != s) { @@ -1433,24 +1488,7 @@ void MainWindow::initialUiSetup() restoreState(settings.value("windowState", 0).toByteArray()); } - state = (CurrentState)settings.value("lastState", 0).toInt(); - switch (state) { - case VIEWALL: - on_actionViewAll_triggered(); - break; - case MAP_MAXIMIZED: - on_actionViewMap_triggered(); - break; - case INFO_MAXIMIZED: - on_actionViewInfo_triggered(); - break; - case LIST_MAXIMIZED: - on_actionViewList_triggered(); - break; - case PROFILE_MAXIMIZED: - on_actionViewProfile_triggered(); - break; - } + enterState((CurrentState)settings.value("lastState", 0).toInt()); settings.endGroup(); show(); } |