Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(uiform): Separated time and date format and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Diadlo committed Oct 7, 2016
1 parent 661388d commit d909d99
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 68 deletions.
47 changes: 14 additions & 33 deletions src/widget/form/settings/userinterfaceform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Settings::getInstance().setTimestampFormat(format);
Translator::translate();
}
QString timeExample = QTime::currentTime().toString(format);
bodyUI->timeExample->setText(timeExample);

void UserInterfaceForm::on_timestamp_editTextChanged(const QString &format)
{
Settings::getInstance().setTimestampFormat(format);
Translator::translate();
}

void UserInterfaceForm::on_dateFormats_currentIndexChanged()
void UserInterfaceForm::on_dateFormats_editTextChanged(const QString& format)
{
QString format = bodyUI->dateFormats->currentData().toString();
qDebug() << format;
Settings::getInstance().setDateFormat(format);
Translator::translate();
}
QString dateExample = QDate::currentDate().toString(format);
bodyUI->dateExample->setText(dateExample);

void UserInterfaceForm::on_dateFormats_editTextChanged()
{
QString format = bodyUI->dateFormats->currentText();
qDebug() << format;
Settings::getInstance().setDateFormat(format);
Translator::translate();
}
Expand Down
4 changes: 1 addition & 3 deletions src/widget/form/settings/userinterfaceform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
90 changes: 58 additions & 32 deletions src/widget/form/settings/userinterfacesettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -465,46 +465,74 @@
</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">
<string>Timestamp format:</string>
</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>
Expand Down Expand Up @@ -539,8 +567,6 @@
<tabstop>scrollArea</tabstop>
<tabstop>styleBrowser</tabstop>
<tabstop>themeColorCBox</tabstop>
<tabstop>timestamp</tabstop>
<tabstop>dateFormats</tabstop>
</tabstops>
<resources/>
<connections/>
Expand Down

0 comments on commit d909d99

Please sign in to comment.