From c995069e14cdd7c1132866ac78ad7839faecfa15 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Tue, 21 Nov 2017 12:23:58 +0100 Subject: Desktop UI: allow user defined cylinder as default Currently, it was only possible to use a hard-coded default cylinder in the preferences. At the same time, the user is allowed to add own cylinders to a dive (by just typing in a new name and cylinder properties). These own cylinders could not be selected in the preferences, requiring the user to manually add this every dive. Not sure the reason for all this was intentional, or just an overlooked aspect in the implementation. It appeared that the selection list in the UI was constructed before any logbook was parsed, so at that moment, there are only hard-coded cylinders. The fix is simple. Refresh the UI of the preferences just before it is shown. While opening the logbook, a new list of cylinders, including the own cylinders is constructed, so the UI is refreshed to that. While a simple change, there is a use case that might be considered strange. Open a logbook, choose new logbook, and change the default cylinder preference to an own (from the previously opened logbook). Do not add a dive with the new (own) cylinder and save this logbook. Reopen this new logbook, and see that the default cylinder in the preferences is empty. This is logical, as the list of own possible cylinders is constructed from the (new) logbook, that has no dive with that specific own cylinder. I consider this acceptable behavior, as it can be also be used to copy own cylinders to a new logbook. Fixes: #821 Proposed-by: Davide DB Signed-off-by: Jan Mulder --- desktop-widgets/mainwindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'desktop-widgets') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index e84b6160a..f685a2b74 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -774,6 +774,11 @@ void MainWindow::showProfile() void MainWindow::on_actionPreferences_triggered() { + // the refreshPages() is currently done for just one + // reason. Allow the user to define a default cylinder that + // is not hardcoded but coming from the logbook. + PreferencesDialog::instance()->refreshPages(); + PreferencesDialog::instance()->show(); PreferencesDialog::instance()->raise(); } -- cgit v1.2.3-70-g09d2