diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-22 09:49:48 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-22 10:00:43 -0700 |
commit | 00ff63f186f65df809610d70ca9b132197b6e72d (patch) | |
tree | 8608a09f7ee76ccbd21933c044cdcaba0ccf9723 /desktop-widgets/tab-widgets | |
parent | fb1cf8d0e5b30794c6d2c5fd247f17fb4d63da08 (diff) | |
download | subsurface-00ff63f186f65df809610d70ca9b132197b6e72d.tar.gz |
desktop: update date and time fields if user changes format
This was more painful than expected, because we get the "preferences"
changed signal too early when the user switches to system format.
The correct format is set by the preferences-widget, not the preferences
subsystem.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 15 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 9c08ddcbd..d11581516 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -8,6 +8,7 @@ #include "desktop-widgets/tab-widgets/maintab.h" #include "desktop-widgets/mainwindow.h" #include "desktop-widgets/mapwidget.h" +#include "desktop-widgets/preferences/preferencesdialog.h" #include "core/qthelper.h" #include "core/trip.h" #include "qt-models/diveplannermodel.h" @@ -71,8 +72,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), extraWidgets << new TabDiveSite(this); ui.tabWidget->addTab(extraWidgets.last(), tr("Dive sites")); - ui.dateEdit->setDisplayFormat(prefs.date_format); - ui.timeEdit->setDisplayFormat(prefs.time_format); + updateDateTimeFields(); closeMessage(); @@ -86,6 +86,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), connect(ui.location, &DiveLocationLineEdit::currentChanged, MapWidget::instance(), &MapWidget::centerOnIndex); connect(ui.location, &DiveLocationLineEdit::editingFinished, this, &MainTab::on_location_diveSiteSelected); + // One might think that we could listen to the precise property-changed signals of the preferences system. + // Alas, this is not the case. When the user switches to system-format, the preferences sends the according + // signal. However, the correct date and time format is set by the preferences dialog later. This should be fixed. + connect(PreferencesDialog::instance(), &PreferencesDialog::settingsChanged, this, &MainTab::updateDateTimeFields); + QAction *action = new QAction(tr("Apply changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); ui.diveNotesMessage->addAction(action); @@ -178,6 +183,12 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.diveTripLocation->hide(); } +void MainTab::updateDateTimeFields() +{ + ui.dateEdit->setDisplayFormat(prefs.date_format); + ui.timeEdit->setDisplayFormat(prefs.time_format); +} + void MainTab::hideMessage() { ui.diveNotesMessage->animatedHide(); diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h index c083554b1..e0bf908d1 100644 --- a/desktop-widgets/tab-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -66,6 +66,7 @@ slots: void displayMessage(QString str); void enableEdition(); void escDetected(void); + void updateDateTimeFields(); private: Ui::MainTab ui; bool editMode; |