Browse Source

fix(uiform): Added format constraints

pull/3774/head
Diadlo 9 years ago
parent
commit
13baf9326d
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
  1. 12
      src/widget/form/settings/userinterfaceform.cpp
  2. 1
      src/widget/form/settings/userinterfaceform.h

12
src/widget/form/settings/userinterfaceform.cpp

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include <QFileDialog>
#include <QFont>
#include <QMessageBox>
#include <QRegularExpressionValidator>
#include <QStandardPaths>
#include <QStyleFactory>
#include <QTime>
@ -124,8 +125,15 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) : @@ -124,8 +125,15 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) :
timeFormats.removeDuplicates();
bodyUI->timestamp->addItems(timeFormats);
QRegularExpression re(QString("^[^\\n]{0,%0}$").arg(MAX_FORMAT_LENGTH));
QRegularExpressionValidator* validator = new QRegularExpressionValidator(re, this);
QString timeFormat = s.getTimestampFormat();
if (!re.match(timeFormat).hasMatch())
timeFormat = timeFormats[0];
bodyUI->timestamp->setCurrentText(timeFormat);
bodyUI->timestamp->setValidator(validator);
on_timestamp_editTextChanged(timeFormat);
QStringList dateFormats;
@ -140,7 +148,11 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) : @@ -140,7 +148,11 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) :
bodyUI->dateFormats->addItems(dateFormats);
QString dateFormat = s.getDateFormat();
if (!re.match(dateFormat).hasMatch())
dateFormat = dateFormats[0];
bodyUI->dateFormats->setCurrentText(dateFormat);
bodyUI->dateFormats->setValidator(validator);
on_dateFormats_editTextChanged(dateFormat);
eventsInit();

1
src/widget/form/settings/userinterfaceform.h

@ -64,6 +64,7 @@ private: @@ -64,6 +64,7 @@ private:
QList<QLabel*> smileLabels;
SettingsWidget* parent;
Ui::UserInterfaceSettings* bodyUI;
const int MAX_FORMAT_LENGTH = 128;
};
#endif

Loading…
Cancel
Save