From 0fc4bd8976e5459b84307b595049f081ed8c2c78 Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Thu, 30 Nov 2017 20:33:43 +0100 Subject: 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 --- desktop-widgets/tab-widgets/maintab.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'desktop-widgets/tab-widgets/maintab.cpp') 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(); -- cgit v1.2.3-70-g09d2