1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(timeformat): Fixed list of available time formats

This commit is contained in:
Nils Fenner 2015-09-13 17:51:06 +02:00 committed by Diadlo
parent b3083250ff
commit 35e7da85d3
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
3 changed files with 27 additions and 11 deletions

View File

@ -118,13 +118,18 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) :
bodyUI->themeColorCBox->setCurrentIndex(s.getThemeColor());
bodyUI->emoticonSize->setValue(s.getEmojiFontPointSize());
QStringList timestamps;
for (QString timestamp : timeFormats)
timestamps << QString("%1 - %2").arg(timestamp, QTime::currentTime().toString(timestamp));
bodyUI->timestamp->addItems(timestamps);
QLocale ql;
timeFormats << ql.timeFormat(QLocale::ShortFormat)
<< ql.timeFormat(QLocale::LongFormat);
timeFormats.removeDuplicates();
for (QString format : timeFormats)
{
QString timeExample = QTime::currentTime().toString(format);
QString element = QString("%1 - %2").arg(format, timeExample);
bodyUI->timestamp->addItem(element, format);
}
QStringList dateFormats;
dateFormats << QStringLiteral("yyyy-MM-dd") // ISO 8601
@ -134,10 +139,6 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) :
<< ql.dateFormat(QLocale::NarrowFormat);
dateFormats.removeDuplicates();
timeFormats.append(ql.timeFormat());
timeFormats.append(ql.timeFormat(QLocale::LongFormat));
timeFormats.removeDuplicates();
for (QString format : dateFormats)
{
QString dateExample = QDate::currentDate().toString(format);
@ -176,7 +177,15 @@ void UserInterfaceForm::on_emoticonSize_editingFinished()
void UserInterfaceForm::on_timestamp_currentIndexChanged(int index)
{
Settings::getInstance().setTimestampFormat(timeFormats.at(index));
Q_UNUSED(index)
QString format = bodyUI->timestamp->currentData().toString();
Settings::getInstance().setTimestampFormat(format);
Translator::translate();
}
void UserInterfaceForm::on_timestamp_editTextChanged(const QString &format)
{
Settings::getInstance().setTimestampFormat(format);
Translator::translate();
}

View File

@ -40,6 +40,7 @@ private slots:
void on_emoticonSize_editingFinished();
void on_styleBrowser_currentIndexChanged(QString style);
void on_timestamp_currentIndexChanged(int index);
void on_timestamp_editTextChanged(const QString& format);
void on_dateFormats_currentIndexChanged();
void on_dateFormats_editTextChanged();
void on_textStyleComboBox_currentTextChanged();

View File

@ -480,6 +480,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
<item row="6" column="0">