diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-11-30 20:33:43 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-12-01 03:45:59 +0100 |
commit | 0fc4bd8976e5459b84307b595049f081ed8c2c78 (patch) | |
tree | e7267c15d47e13609a4b4beb3c3a11b47d6d19ab /desktop-widgets | |
parent | ba83ce34e04ba233883bba711a6f39df57fd3e7e (diff) | |
download | subsurface-0fc4bd8976e5459b84307b595049f081ed8c2c78.tar.gz |
Disable specific tabs when dive trip selected
Disable tabs for equipment, info, pictures and extra info if a
dive trip is selected.
Remember specific tab selection for dives and dive trip to recover
selection when browsing dive list.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 26 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.h | 3 |
2 files changed, 28 insertions, 1 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 0b9c4731b..724afac57 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -44,7 +44,9 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), cylindersModel(new CylindersModel(this)), editMode(NONE), copyPaste(false), - currentTrip(0) + currentTrip(0), + lastTabSelectedDive(0), + lastTabSelectedDiveTrip(0) { ui.setupUi(this); @@ -469,7 +471,18 @@ void MainTab::updateDiveInfo(bool clear) ui.dateEdit->setDate(localTime.date()); ui.timeEdit->setTime(localTime.time()); if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) { + // Remember the tab selected for last dive + if (lastSelectedDive) + lastTabSelectedDive = ui.tabWidget->currentIndex(); ui.tabWidget->setTabText(0, tr("Trip notes")); + ui.tabWidget->setTabEnabled(1, false); + ui.tabWidget->setTabEnabled(2, false); + ui.tabWidget->setTabEnabled(4, false); + ui.tabWidget->setTabEnabled(5, false); + // Recover the tab selected for last dive trip + if (lastSelectedDive) + ui.tabWidget->setCurrentIndex(lastTabSelectedDiveTrip); + lastSelectedDive = false; currentTrip = *MainWindow::instance()->dive_list()->selectedTrips().begin(); // only use trip relevant fields ui.divemaster->setVisible(false); @@ -511,7 +524,18 @@ void MainTab::updateDiveInfo(bool clear) ui.duration->setVisible(false); ui.durationLabel->setVisible(false); } else { + // Remember the tab selected for last dive trip + if (!lastSelectedDive) + lastTabSelectedDiveTrip = ui.tabWidget->currentIndex(); ui.tabWidget->setTabText(0, tr("Notes")); + ui.tabWidget->setTabEnabled(1, true); + ui.tabWidget->setTabEnabled(2, true); + ui.tabWidget->setTabEnabled(4, true); + ui.tabWidget->setTabEnabled(5, true); + // Recover the tab selected for last dive + if (!lastSelectedDive) + ui.tabWidget->setCurrentIndex(lastTabSelectedDive); + lastSelectedDive = true; currentTrip = NULL; // make all the fields visible writeable ui.diveTripLocation->hide(); diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h index 74872ea08..ec060081f 100644 --- a/desktop-widgets/tab-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -115,6 +115,9 @@ private: Completers completers; bool modified; bool copyPaste; + bool lastSelectedDive; + int lastTabSelectedDive; + int lastTabSelectedDiveTrip; void resetPallete(); void saveTags(); void saveTaggedStrings(); |