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

View File

@ -39,10 +39,8 @@ private slots:
void on_smileyPackBrowser_currentIndexChanged(int index); void on_smileyPackBrowser_currentIndexChanged(int index);
void on_emoticonSize_editingFinished(); void on_emoticonSize_editingFinished();
void on_styleBrowser_currentIndexChanged(QString style); void on_styleBrowser_currentIndexChanged(QString style);
void on_timestamp_currentIndexChanged(int index);
void on_timestamp_editTextChanged(const QString& format); void on_timestamp_editTextChanged(const QString& format);
void on_dateFormats_currentIndexChanged(); void on_dateFormats_editTextChanged(const QString& format);
void on_dateFormats_editTextChanged();
void on_textStyleComboBox_currentTextChanged(); void on_textStyleComboBox_currentTextChanged();
void on_useEmoticons_stateChanged(); void on_useEmoticons_stateChanged();
void on_showWindow_stateChanged(); void on_showWindow_stateChanged();

View File

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