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

feat(uiform): Separated time and date format and examples

This commit is contained in:
Diadlo 2016-10-04 11:08:07 +03:00
parent 661388d731
commit d909d99bd2
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
3 changed files with 74 additions and 69 deletions

View File

@ -122,13 +122,11 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) :
<< ql.timeFormat(QLocale::LongFormat)
<< "hh:mm AP" << "hh:mm:ss AP" << "hh:mm:ss";
timeFormats.removeDuplicates();
bodyUI->timestamp->addItems(timeFormats);
for (QString format : timeFormats)
{
QString timeExample = QTime::currentTime().toString(format);
QString element = QString("%1 - %2").arg(format, timeExample);
bodyUI->timestamp->addItem(element, format);
}
QString timeFormat = s.getTimestampFormat();
bodyUI->timestamp->setCurrentText(timeFormat);
on_timestamp_editTextChanged(timeFormat);
QStringList dateFormats;
dateFormats << QStringLiteral("yyyy-MM-dd") // ISO 8601
@ -139,16 +137,11 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) :
<< "dd-MM-yyyy" << "d-MM-yyyy" << "dddd dd-MM-yyyy" << "dddd d-MM";
dateFormats.removeDuplicates();
bodyUI->dateFormats->addItems(dateFormats);
for (QString format : dateFormats)
{
QString dateExample = QDate::currentDate().toString(format);
QString element = QString("%1 - %2").arg(format, dateExample);
bodyUI->dateFormats->addItem(element, format);
}
bodyUI->timestamp->setCurrentText(QString("%1 - %2").arg(s.getTimestampFormat(), QTime::currentTime().toString(s.getTimestampFormat())));
bodyUI->dateFormats->setCurrentText(QString("%1 - %2").arg(s.getDateFormat(), QDate::currentDate().toString(s.getDateFormat())));
QString dateFormat = s.getDateFormat();
bodyUI->dateFormats->setCurrentText(dateFormat);
on_dateFormats_editTextChanged(dateFormat);
eventsInit();
Translator::registerHandler(std::bind(&UserInterfaceForm::retranslateUi, this), this);
@ -176,32 +169,20 @@ void UserInterfaceForm::on_emoticonSize_editingFinished()
Settings::getInstance().setEmojiFontPointSize(bodyUI->emoticonSize->value());
}
void UserInterfaceForm::on_timestamp_currentIndexChanged(int index)
void UserInterfaceForm::on_timestamp_editTextChanged(const QString& format)
{
Q_UNUSED(index)
QString format = bodyUI->timestamp->currentData().toString();
QString timeExample = QTime::currentTime().toString(format);
bodyUI->timeExample->setText(timeExample);
Settings::getInstance().setTimestampFormat(format);
Translator::translate();
}
void UserInterfaceForm::on_timestamp_editTextChanged(const QString &format)
void UserInterfaceForm::on_dateFormats_editTextChanged(const QString& format)
{
Settings::getInstance().setTimestampFormat(format);
Translator::translate();
}
QString dateExample = QDate::currentDate().toString(format);
bodyUI->dateExample->setText(dateExample);
void UserInterfaceForm::on_dateFormats_currentIndexChanged()
{
QString format = bodyUI->dateFormats->currentData().toString();
qDebug() << format;
Settings::getInstance().setDateFormat(format);
Translator::translate();
}
void UserInterfaceForm::on_dateFormats_editTextChanged()
{
QString format = bodyUI->dateFormats->currentText();
qDebug() << format;
Settings::getInstance().setDateFormat(format);
Translator::translate();
}

View File

@ -39,10 +39,8 @@ private slots:
void on_smileyPackBrowser_currentIndexChanged(int index);
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_dateFormats_editTextChanged(const QString& format);
void on_textStyleComboBox_currentTextChanged();
void on_useEmoticons_stateChanged();
void on_showWindow_stateChanged();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1312</width>
<height>1025</height>
<width>671</width>
<height>800</height>
</rect>
</property>
<property name="windowTitle">
@ -39,8 +39,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1298</width>
<height>1011</height>
<width>657</width>
<height>786</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,0,0,0">
@ -465,6 +465,36 @@
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="timestamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="timeExample">
<property name="text">
<string notr="true">Time Example</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="timestampLabel">
<property name="text">
@ -472,39 +502,37 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="timestamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="dateFormats">
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dateExample">
<property name="text">
<string notr="true">Date Example</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="dateformatLabel">
<property name="text">
<string>Date format:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="dateFormats">
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -539,8 +567,6 @@
<tabstop>scrollArea</tabstop>
<tabstop>styleBrowser</tabstop>
<tabstop>themeColorCBox</tabstop>
<tabstop>timestamp</tabstop>
<tabstop>dateFormats</tabstop>
</tabstops>
<resources/>
<connections/>