mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:23:24 +00:00
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>
This commit is contained in:
parent
9d342d0e1a
commit
57bf174c4f
3 changed files with 65 additions and 19 deletions
|
@ -1228,6 +1228,61 @@ void MainWindow::on_actionViewAll_triggered()
|
||||||
ui.bottomSplitter->setCollapsible(1,false);
|
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)
|
void MainWindow::beginChangeState(CurrentState s)
|
||||||
{
|
{
|
||||||
if (state == VIEWALL && state != s) {
|
if (state == VIEWALL && state != s) {
|
||||||
|
@ -1433,24 +1488,7 @@ void MainWindow::initialUiSetup()
|
||||||
restoreState(settings.value("windowState", 0).toByteArray());
|
restoreState(settings.value("windowState", 0).toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
state = (CurrentState)settings.value("lastState", 0).toInt();
|
enterState((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;
|
|
||||||
}
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,8 @@ public:
|
||||||
MAP_MAXIMIZED,
|
MAP_MAXIMIZED,
|
||||||
INFO_MAXIMIZED,
|
INFO_MAXIMIZED,
|
||||||
PROFILE_MAXIMIZED,
|
PROFILE_MAXIMIZED,
|
||||||
LIST_MAXIMIZED
|
LIST_MAXIMIZED,
|
||||||
|
EDIT
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindow();
|
MainWindow();
|
||||||
|
@ -87,6 +88,8 @@ public:
|
||||||
NotificationWidget *getNotificationWidget();
|
NotificationWidget *getNotificationWidget();
|
||||||
void enableDisableCloudActions();
|
void enableDisableCloudActions();
|
||||||
void setCheckedActionFilterTags(bool checked);
|
void setCheckedActionFilterTags(bool checked);
|
||||||
|
void enterEditState();
|
||||||
|
void exitEditState();
|
||||||
|
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
|
@ -190,6 +193,7 @@ private:
|
||||||
QAction *actionPreviousDive;
|
QAction *actionPreviousDive;
|
||||||
UserManual *helpView;
|
UserManual *helpView;
|
||||||
CurrentState state;
|
CurrentState state;
|
||||||
|
CurrentState stateBeforeEdit;
|
||||||
QString filter_open();
|
QString filter_open();
|
||||||
QString filter_import();
|
QString filter_import();
|
||||||
static MainWindow *m_Instance;
|
static MainWindow *m_Instance;
|
||||||
|
@ -210,6 +214,7 @@ private:
|
||||||
QString lastUsedDir();
|
QString lastUsedDir();
|
||||||
void updateLastUsedDir(const QString &s);
|
void updateLastUsedDir(const QString &s);
|
||||||
void registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
|
void registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight);
|
||||||
|
void enterState(CurrentState);
|
||||||
bool filesAsArguments;
|
bool filesAsArguments;
|
||||||
UpdateManager *updateManager;
|
UpdateManager *updateManager;
|
||||||
|
|
||||||
|
|
|
@ -334,6 +334,7 @@ void MainTab::enableEdition(EditMode newEditMode)
|
||||||
ui.editDiveSiteButton->setEnabled(false);
|
ui.editDiveSiteButton->setEnabled(false);
|
||||||
MainWindow::instance()->dive_list()->setEnabled(false);
|
MainWindow::instance()->dive_list()->setEnabled(false);
|
||||||
MainWindow::instance()->setEnabledToolbar(false);
|
MainWindow::instance()->setEnabledToolbar(false);
|
||||||
|
MainWindow::instance()->enterEditState();
|
||||||
|
|
||||||
if (isTripEdit) {
|
if (isTripEdit) {
|
||||||
// we are editing trip location and notes
|
// we are editing trip location and notes
|
||||||
|
@ -991,6 +992,7 @@ void MainTab::acceptChanges()
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
|
||||||
MainWindow::instance()->dive_list()->verticalScrollBar()->setSliderPosition(scrolledBy);
|
MainWindow::instance()->dive_list()->verticalScrollBar()->setSliderPosition(scrolledBy);
|
||||||
MainWindow::instance()->dive_list()->setFocus();
|
MainWindow::instance()->dive_list()->setFocus();
|
||||||
|
MainWindow::instance()->exitEditState();
|
||||||
cylindersModel->changed = false;
|
cylindersModel->changed = false;
|
||||||
weightModel->changed = false;
|
weightModel->changed = false;
|
||||||
MainWindow::instance()->setEnabledToolbar(true);
|
MainWindow::instance()->setEnabledToolbar(true);
|
||||||
|
@ -1058,6 +1060,7 @@ void MainTab::rejectChanges()
|
||||||
// show the profile and dive info
|
// show the profile and dive info
|
||||||
MainWindow::instance()->graphics()->replot();
|
MainWindow::instance()->graphics()->replot();
|
||||||
MainWindow::instance()->setEnabledToolbar(true);
|
MainWindow::instance()->setEnabledToolbar(true);
|
||||||
|
MainWindow::instance()->exitEditState();
|
||||||
cylindersModel->changed = false;
|
cylindersModel->changed = false;
|
||||||
weightModel->changed = false;
|
weightModel->changed = false;
|
||||||
cylindersModel->updateDive();
|
cylindersModel->updateDive();
|
||||||
|
|
Loading…
Add table
Reference in a new issue