summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferences_language.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-10 17:28:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-10 09:21:47 -0800
commit513f5a0230f5039ba5407562a7539a22cb20802a (patch)
tree9eea6b9290f8a9df0b4caf2d5f86047debbef4fa /desktop-widgets/preferences/preferences_language.cpp
parent4fde26fb2c8478176bdd77be19e091695b744ae8 (diff)
downloadsubsurface-513f5a0230f5039ba5407562a7539a22cb20802a.tar.gz
preferences: support a pre-defined list of time formats
Add a combo-box that holds a list of pre-defined time formats in the Language preferences. The user is still allowed to enter a custom time format. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'desktop-widgets/preferences/preferences_language.cpp')
-rw-r--r--desktop-widgets/preferences/preferences_language.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp
index 0cb36dc2c..5f7b5f488 100644
--- a/desktop-widgets/preferences/preferences_language.cpp
+++ b/desktop-widgets/preferences/preferences_language.cpp
@@ -30,6 +30,10 @@ PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Langu
ui->dateFormatEntry->addItem(format);
connect(ui->dateFormatEntry, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(dateFormatChanged(const QString&)));
+
+ ui->timeFormatEntry->addItem("hh:mm");
+ ui->timeFormatEntry->addItem("h:mm AP");
+ ui->timeFormatEntry->addItem("hh:mm AP");
}
PreferencesLanguage::~PreferencesLanguage()
@@ -47,7 +51,7 @@ void PreferencesLanguage::refreshSettings()
ui->languageSystemDefault->setChecked(prefs.locale.use_system_language);
ui->timeFormatSystemDefault->setChecked(!prefs.time_format_override);
ui->dateFormatSystemDefault->setChecked(!prefs.date_format_override);
- ui->timeFormatEntry->setText(prefs.time_format);
+ ui->timeFormatEntry->setCurrentText(prefs.time_format);
ui->dateFormatEntry->setCurrentText(prefs.date_format);
ui->shortDateFormatEntry->setText(prefs.date_format_short);
QAbstractItemModel *m = ui->languageDropdown->model();
@@ -84,14 +88,14 @@ void PreferencesLanguage::syncSettings()
lang->setUseSystemLanguage(ui->languageSystemDefault->isChecked());
lang->setTimeFormatOverride(!ui->timeFormatSystemDefault->isChecked());
lang->setDateFormatOverride(!ui->dateFormatSystemDefault->isChecked());
- lang->setTimeFormat(ui->timeFormatEntry->text());
+ lang->setTimeFormat(ui->timeFormatEntry->currentText());
lang->setDateFormat(ui->dateFormatEntry->currentText());
lang->setDateFormatShort(ui->shortDateFormatEntry->text());
uiLanguage(NULL);
QString qDateTimeWeb = tr("These will be used as is. This might not be what you intended.\nSee http://doc.qt.io/qt-5/qdatetime.html#toString");
QRegExp tfillegalchars("[^hHmszaApPt\\s:;\\.,]");
- if (tfillegalchars.indexIn(ui->timeFormatEntry->text()) >= 0)
+ if (tfillegalchars.indexIn(ui->timeFormatEntry->currentText()) >= 0)
QMessageBox::warning(this, tr("Literal characters"),
tr("Non-special character(s) in time format.\n") + qDateTimeWeb);