fully editable datetime format in msg list
This commit is contained in:
parent
5ef90cc691
commit
8cb7c1c496
@ -86,10 +86,12 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
|||||||
connect(m_ui->m_checkUpdateAllFeedsOnStartup, &QCheckBox::toggled, m_ui->m_spinStartupUpdateDelay, &TimeSpinBox::setEnabled);
|
connect(m_ui->m_checkUpdateAllFeedsOnStartup, &QCheckBox::toggled, m_ui->m_spinStartupUpdateDelay, &TimeSpinBox::setEnabled);
|
||||||
connect(m_ui->m_spinFeedUpdateTimeout, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
connect(m_ui->m_spinFeedUpdateTimeout, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||||
&SettingsFeedsMessages::dirtifySettings);
|
&SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_cmbMessagesDateTimeFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
||||||
|
connect(m_ui->m_cmbMessagesDateTimeFormat, &QComboBox::currentTextChanged, this,
|
||||||
&SettingsFeedsMessages::dirtifySettings);
|
&SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_cmbMessagesTimeFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
connect(m_ui->m_cmbMessagesTimeFormat, &QComboBox::currentTextChanged, this,
|
||||||
&SettingsFeedsMessages::dirtifySettings);
|
&SettingsFeedsMessages::dirtifySettings);
|
||||||
|
|
||||||
connect(m_ui->m_cmbCountsFeedList, &QComboBox::currentTextChanged, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_cmbCountsFeedList, &QComboBox::currentTextChanged, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_cmbCountsFeedList, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
connect(m_ui->m_cmbCountsFeedList, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||||
&SettingsFeedsMessages::dirtifySettings);
|
&SettingsFeedsMessages::dirtifySettings);
|
||||||
@ -97,6 +99,11 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
|||||||
connect(m_ui->m_checkMultilineArticleList, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkMultilineArticleList, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_checkMultilineArticleList, &QCheckBox::toggled, this, &SettingsFeedsMessages::requireRestart);
|
connect(m_ui->m_checkMultilineArticleList, &QCheckBox::toggled, this, &SettingsFeedsMessages::requireRestart);
|
||||||
|
|
||||||
|
connect(m_ui->m_cmbMessagesDateTimeFormat, &QComboBox::currentTextChanged,
|
||||||
|
this, &SettingsFeedsMessages::updateDateTimeTooltip);
|
||||||
|
connect(m_ui->m_cmbMessagesTimeFormat, &QComboBox::currentTextChanged,
|
||||||
|
this, &SettingsFeedsMessages::updateDateTimeTooltip);
|
||||||
|
|
||||||
connect(m_ui->m_btnChangeMessagesFont, &QPushButton::clicked, this, [&]() {
|
connect(m_ui->m_btnChangeMessagesFont, &QPushButton::clicked, this, [&]() {
|
||||||
changeFont(*m_ui->m_lblMessagesFont);
|
changeFont(*m_ui->m_lblMessagesFont);
|
||||||
});
|
});
|
||||||
@ -119,32 +126,30 @@ SettingsFeedsMessages::~SettingsFeedsMessages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsFeedsMessages::initializeMessageDateFormats() {
|
void SettingsFeedsMessages::initializeMessageDateFormats() {
|
||||||
QStringList datetime_formats, time_formats;
|
/*
|
||||||
const QDateTime current_dt = QDateTime::currentDateTime();
|
QStringList datetime_formats, time_formats;
|
||||||
const QLocale current_locale = qApp->localization()->loadedLocale();
|
const QDateTime current_dt = QDateTime::currentDateTime();
|
||||||
auto installed_languages = qApp->localization()->installedLanguages();
|
const QLocale current_locale = qApp->localization()->loadedLocale();
|
||||||
|
auto installed_languages = qApp->localization()->installedLanguages();
|
||||||
|
|
||||||
for (const Language& lang : qAsConst(installed_languages)) {
|
for (const Language& lang : qAsConst(installed_languages)) {
|
||||||
QLocale locale(lang.m_code);
|
QLocale locale(lang.m_code);
|
||||||
|
|
||||||
datetime_formats << locale.dateTimeFormat(QLocale::FormatType::LongFormat)
|
datetime_formats << locale.dateTimeFormat(QLocale::FormatType::LongFormat)
|
||||||
<< locale.dateTimeFormat(QLocale::FormatType::ShortFormat)
|
<< locale.dateTimeFormat(QLocale::FormatType::ShortFormat)
|
||||||
<< locale.dateTimeFormat(QLocale::FormatType::NarrowFormat);
|
<< locale.dateTimeFormat(QLocale::FormatType::NarrowFormat);
|
||||||
time_formats << locale.timeFormat(QLocale::FormatType::LongFormat)
|
time_formats << locale.timeFormat(QLocale::FormatType::LongFormat)
|
||||||
<< locale.timeFormat(QLocale::FormatType::ShortFormat)
|
<< locale.timeFormat(QLocale::FormatType::ShortFormat)
|
||||||
<< locale.timeFormat(QLocale::FormatType::NarrowFormat);
|
<< locale.timeFormat(QLocale::FormatType::NarrowFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
datetime_formats.removeDuplicates();
|
datetime_formats.removeDuplicates();
|
||||||
time_formats.removeDuplicates();
|
time_formats.removeDuplicates();*/
|
||||||
|
|
||||||
for (const QString& format : qAsConst(datetime_formats)) {
|
QStringList patterns = TextFactory::dateTimePatterns();
|
||||||
m_ui->m_cmbMessagesDateTimeFormat->addItem(current_locale.toString(current_dt, format), format);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const QString& format : qAsConst(time_formats)) {
|
m_ui->m_cmbMessagesDateTimeFormat->addItems(patterns);
|
||||||
m_ui->m_cmbMessagesTimeFormat->addItem(current_locale.toString(current_dt, format), format);
|
m_ui->m_cmbMessagesTimeFormat->addItems(patterns);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsFeedsMessages::changeFont(QLabel& lbl) {
|
void SettingsFeedsMessages::changeFont(QLabel& lbl) {
|
||||||
@ -199,22 +204,12 @@ void SettingsFeedsMessages::loadSettings() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_ui->m_checkMessagesDateTimeFormat->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool());
|
m_ui->m_checkMessagesDateTimeFormat->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool());
|
||||||
|
m_ui->m_cmbMessagesDateTimeFormat->setCurrentText(settings()->value(GROUP(Messages),
|
||||||
int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(settings()->value(GROUP(Messages),
|
SETTING(Messages::CustomDateFormat)).toString());
|
||||||
SETTING(Messages::CustomDateFormat)).toString());
|
|
||||||
|
|
||||||
if (index_format >= 0) {
|
|
||||||
m_ui->m_cmbMessagesDateTimeFormat->setCurrentIndex(index_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ui->m_checkMessagesTimeFormat->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::UseCustomTime)).toBool());
|
m_ui->m_checkMessagesTimeFormat->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::UseCustomTime)).toBool());
|
||||||
|
m_ui->m_cmbMessagesTimeFormat->setCurrentText(settings()->value(GROUP(Messages),
|
||||||
index_format = m_ui->m_cmbMessagesTimeFormat->findData(settings()->value(GROUP(Messages),
|
SETTING(Messages::CustomTimeFormat)).toString());
|
||||||
SETTING(Messages::CustomTimeFormat)).toString());
|
|
||||||
|
|
||||||
if (index_format >= 0) {
|
|
||||||
m_ui->m_cmbMessagesTimeFormat->setCurrentIndex(index_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
QFont fon;
|
QFont fon;
|
||||||
|
|
||||||
@ -280,11 +275,8 @@ void SettingsFeedsMessages::saveSettings() {
|
|||||||
settings()->setValue(GROUP(Messages), Messages::UseCustomDate, m_ui->m_checkMessagesDateTimeFormat->isChecked());
|
settings()->setValue(GROUP(Messages), Messages::UseCustomDate, m_ui->m_checkMessagesDateTimeFormat->isChecked());
|
||||||
settings()->setValue(GROUP(Messages), Messages::UseCustomTime, m_ui->m_checkMessagesTimeFormat->isChecked());
|
settings()->setValue(GROUP(Messages), Messages::UseCustomTime, m_ui->m_checkMessagesTimeFormat->isChecked());
|
||||||
|
|
||||||
settings()->setValue(GROUP(Messages), Messages::CustomDateFormat,
|
settings()->setValue(GROUP(Messages), Messages::CustomDateFormat, m_ui->m_cmbMessagesDateTimeFormat->currentText());
|
||||||
m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString());
|
settings()->setValue(GROUP(Messages), Messages::CustomTimeFormat, m_ui->m_cmbMessagesTimeFormat->currentText());
|
||||||
|
|
||||||
settings()->setValue(GROUP(Messages), Messages::CustomTimeFormat,
|
|
||||||
m_ui->m_cmbMessagesTimeFormat->itemData(m_ui->m_cmbMessagesTimeFormat->currentIndex()).toString());
|
|
||||||
|
|
||||||
// Save fonts.
|
// Save fonts.
|
||||||
settings()->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString());
|
settings()->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString());
|
||||||
@ -302,3 +294,16 @@ void SettingsFeedsMessages::saveSettings() {
|
|||||||
|
|
||||||
onEndSaveSettings();
|
onEndSaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsFeedsMessages::updateDateTimeTooltip() {
|
||||||
|
QComboBox* sndr = qobject_cast<QComboBox*>(sender());
|
||||||
|
|
||||||
|
if (sndr != nullptr) {
|
||||||
|
if (sndr->currentText().simplified().isEmpty()) {
|
||||||
|
sndr->setToolTip({});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sndr->setToolTip(QDateTime::currentDateTime().toString(sndr->currentText()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,6 +18,9 @@ class SettingsFeedsMessages : public SettingsPanel {
|
|||||||
virtual void loadSettings();
|
virtual void loadSettings();
|
||||||
virtual void saveSettings();
|
virtual void saveSettings();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateDateTimeTooltip();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeFont(QLabel& lbl);
|
void changeFont(QLabel& lbl);
|
||||||
|
|
||||||
|
@ -383,6 +383,9 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="13" column="0">
|
<item row="13" column="0">
|
||||||
@ -406,6 +409,9 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="14" column="0" colspan="2">
|
<item row="14" column="0" colspan="2">
|
||||||
|
@ -73,13 +73,7 @@ QDateTime TextFactory::parseDateTime(const QString& date_time) {
|
|||||||
QTime time_zone_offset;
|
QTime time_zone_offset;
|
||||||
const QLocale locale(QLocale::Language::C);
|
const QLocale locale(QLocale::Language::C);
|
||||||
bool positive_time_zone_offset = false;
|
bool positive_time_zone_offset = false;
|
||||||
QStringList date_patterns;
|
static QStringList date_patterns = dateTimePatterns();
|
||||||
|
|
||||||
date_patterns << QSL("yyyy-MM-ddTHH:mm:ss") << QSL("MMM dd yyyy hh:mm:ss") <<
|
|
||||||
QSL("MMM d yyyy hh:mm:ss") << QSL("ddd, dd MMM yyyy HH:mm:ss") << QSL("ddd, d MMM yyyy HH:mm:ss") <<
|
|
||||||
QSL("dd MMM yyyy") << QSL("yyyy-MM-dd HH:mm:ss.z") << QSL("yyyy-MM-dd") <<
|
|
||||||
QSL("yyyy") << QSL("yyyy-MM") << QSL("yyyy-MM-dd") << QSL("yyyy-MM-ddThh:mm") <<
|
|
||||||
QSL("yyyy-MM-ddThh:mm:ss") << QSL("d MMM yyyy HH:mm:ss");
|
|
||||||
QStringList timezone_offset_patterns;
|
QStringList timezone_offset_patterns;
|
||||||
|
|
||||||
timezone_offset_patterns << QSL("+hh:mm") << QSL("-hh:mm") << QSL("+hhmm")
|
timezone_offset_patterns << QSL("+hh:mm") << QSL("-hh:mm") << QSL("+hhmm")
|
||||||
@ -133,6 +127,15 @@ QDateTime TextFactory::parseDateTime(qint64 milis_from_epoch) {
|
|||||||
return QDateTime::fromMSecsSinceEpoch(milis_from_epoch, Qt::TimeSpec::UTC);
|
return QDateTime::fromMSecsSinceEpoch(milis_from_epoch, Qt::TimeSpec::UTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList TextFactory::dateTimePatterns() {
|
||||||
|
return QStringList() << QSL("yyyy-MM-ddTHH:mm:ss") << QSL("MMM dd yyyy hh:mm:ss") <<
|
||||||
|
QSL("MMM d yyyy hh:mm:ss") << QSL("ddd, dd MMM yyyy HH:mm:ss") << QSL("ddd, d MMM yyyy HH:mm:ss") <<
|
||||||
|
QSL("dd MMM yyyy") << QSL("yyyy-MM-dd HH:mm:ss.z") << QSL("yyyy-MM-dd") <<
|
||||||
|
QSL("yyyy") << QSL("yyyy-MM") << QSL("yyyy-MM-dd") << QSL("yyyy-MM-ddThh:mm") <<
|
||||||
|
QSL("yyyy-MM-ddThh:mm:ss") << QSL("d MMM yyyy HH:mm:ss") << QSL("hh:mm:ss") <<
|
||||||
|
QSL("h:m:s AP") << QSL("h:m") << QSL("h.m");
|
||||||
|
}
|
||||||
|
|
||||||
QString TextFactory::encrypt(const QString& text, quint64 key) {
|
QString TextFactory::encrypt(const QString& text, quint64 key) {
|
||||||
return SimpleCrypt(key == 0 ? initializeSecretEncryptionKey() : key).encryptToString(text);
|
return SimpleCrypt(key == 0 ? initializeSecretEncryptionKey() : key).encryptToString(text);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ class TextFactory {
|
|||||||
// Converts 1970-epoch miliseconds to date/time.
|
// Converts 1970-epoch miliseconds to date/time.
|
||||||
// NOTE: This method tries to always return time in UTC.
|
// NOTE: This method tries to always return time in UTC.
|
||||||
static QDateTime parseDateTime(qint64 milis_from_epoch);
|
static QDateTime parseDateTime(qint64 milis_from_epoch);
|
||||||
|
static QStringList dateTimePatterns();
|
||||||
static QString encrypt(const QString& text, quint64 key = 0);
|
static QString encrypt(const QString& text, quint64 key = 0);
|
||||||
static QString decrypt(const QString& text, quint64 key = 0);
|
static QString decrypt(const QString& text, quint64 key = 0);
|
||||||
static QString newline();
|
static QString newline();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user