mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
fb1cf8d0e5
commit
00ff63f186
3 changed files with 15 additions and 2 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue