mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
desktop: remember previous state when switching to dive site mode
The dive-site editing can be reached from two states: from the dive view and the dive list view. It always jumped back to the dive view. Therefore, remember the state. Use a stack-like structure, so that the feature can be used for the dive-site view as well. This is a bit inconsistent, because for example the statistics view does not remember the previous state and allows a direct jump to a different state. That should be fixed at some point. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
17033d0d83
commit
621a0a4e3a
4 changed files with 17 additions and 2 deletions
|
@ -48,7 +48,7 @@ DiveSiteListView::DiveSiteListView(QWidget *parent) : QWidget(parent)
|
||||||
|
|
||||||
void DiveSiteListView::done()
|
void DiveSiteListView::done()
|
||||||
{
|
{
|
||||||
MainWindow::instance()->setApplicationState(MainWindow::ApplicationState::Default);
|
MainWindow::instance()->enterPreviousState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveSiteListView::diveSiteClicked(const QModelIndex &index)
|
void DiveSiteListView::diveSiteClicked(const QModelIndex &index)
|
||||||
|
|
|
@ -220,7 +220,7 @@ void LocationInformationWidget::acceptChanges()
|
||||||
|
|
||||||
MainWindow::instance()->diveList->setEnabled(true);
|
MainWindow::instance()->diveList->setEnabled(true);
|
||||||
MainWindow::instance()->setEnabledToolbar(true);
|
MainWindow::instance()->setEnabledToolbar(true);
|
||||||
MainWindow::instance()->setApplicationState(MainWindow::ApplicationState::Default);
|
MainWindow::instance()->enterPreviousState();
|
||||||
DiveFilter::instance()->stopFilterDiveSites();
|
DiveFilter::instance()->stopFilterDiveSites();
|
||||||
|
|
||||||
// Subtlety alert: diveSite must be cleared *after* exiting the dive-site mode.
|
// Subtlety alert: diveSite must be cleared *after* exiting the dive-site mode.
|
||||||
|
|
|
@ -282,6 +282,7 @@ void MainWindow::editDiveSite(dive_site *ds)
|
||||||
if (!ds)
|
if (!ds)
|
||||||
return;
|
return;
|
||||||
diveSiteEdit->initFields(ds);
|
diveSiteEdit->initFields(ds);
|
||||||
|
state_stack.push_back(appState);
|
||||||
setApplicationState(ApplicationState::EditDiveSite);
|
setApplicationState(ApplicationState::EditDiveSite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,6 +766,7 @@ void MainWindow::on_actionViewDiveSites_triggered()
|
||||||
{
|
{
|
||||||
if (!userMayChangeAppState())
|
if (!userMayChangeAppState())
|
||||||
return;
|
return;
|
||||||
|
state_stack.push_back(appState);
|
||||||
setApplicationState(ApplicationState::DiveSites);
|
setApplicationState(ApplicationState::DiveSites);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1472,6 +1474,17 @@ bool MainWindow::userMayChangeAppState() const
|
||||||
return applicationState[(int)appState].allowUserChange;
|
return applicationState[(int)appState].allowUserChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For the dive-site list view and the dive-site edit states,
|
||||||
|
// we remember the previous state and then switch back to that.
|
||||||
|
void MainWindow::enterPreviousState()
|
||||||
|
{
|
||||||
|
if (state_stack.empty())
|
||||||
|
setApplicationState(ApplicationState::Default);
|
||||||
|
ApplicationState prev = state_stack.back();
|
||||||
|
state_stack.pop_back();
|
||||||
|
setApplicationState(prev);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::setApplicationState(ApplicationState state)
|
void MainWindow::setApplicationState(ApplicationState state)
|
||||||
{
|
{
|
||||||
if (appState == state)
|
if (appState == state)
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
void importFiles(const QStringList importFiles);
|
void importFiles(const QStringList importFiles);
|
||||||
void setToolButtonsEnabled(bool enabled);
|
void setToolButtonsEnabled(bool enabled);
|
||||||
void setApplicationState(ApplicationState state);
|
void setApplicationState(ApplicationState state);
|
||||||
|
void enterPreviousState();
|
||||||
NotificationWidget *getNotificationWidget();
|
NotificationWidget *getNotificationWidget();
|
||||||
void enableDisableCloudActions();
|
void enableDisableCloudActions();
|
||||||
void enableDisableOtherDCsActions();
|
void enableDisableOtherDCsActions();
|
||||||
|
@ -162,6 +163,7 @@ slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ApplicationState appState;
|
ApplicationState appState;
|
||||||
|
std::vector<ApplicationState> state_stack;
|
||||||
Ui::MainWindow ui;
|
Ui::MainWindow ui;
|
||||||
FilterWidget filterWidget;
|
FilterWidget filterWidget;
|
||||||
std::unique_ptr<QSplitter> topSplitter;
|
std::unique_ptr<QSplitter> topSplitter;
|
||||||
|
|
Loading…
Add table
Reference in a new issue