From 3242fbdc4525349058be719de7a8e19c8aaf7214 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 12 Apr 2019 20:33:43 +0200 Subject: Dive sites: dont't disable all tabs when creating new dive site The dive tabs are disabled, when no dive is shown. The dive site tab is implemented as a dive tab, which is of course conceptually wrong. Moreover it has the nasty side effect that when adding an empty dive site, no dives are shown and the tab is disabled, leading to a UI dead lock. Therefore, disable all tabs but the dive site tab. The proper fix will be a refactoring of the UI. Reported-by: Doug Junkins Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/maintab.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (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 0f0a2a84b..7dda4c0e7 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -491,10 +491,15 @@ void MainTab::updateDiveInfo() // don't execute this while adding / planning a dive if (editMode == MANUALLY_ADDED_DIVE || MainWindow::instance()->graphics->isPlanner()) return; - if (!isEnabled() && current_dive) - setEnabled(true); - if (isEnabled() && !current_dive) - setEnabled(false); + + // If there is no current dive, disable all widgets except the last, which is the dive site tab. + // TODO: Conceptually, the dive site tab shouldn't even be a tab here! + bool enabled = current_dive != nullptr; + ui.equipmentTab->setEnabled(enabled); + ui.notesTab->setEnabled(enabled); + for (int i = 0; i < extraWidgets.size() - 1; ++i) + extraWidgets[i]->setEnabled(enabled); + editMode = IGNORE; // don't trigger on changes to the widgets for (auto widget : extraWidgets) { -- cgit v1.2.3-70-g09d2