show combobox tooltips for datetime formats for all items

This commit is contained in:
Martin Rotter 2022-02-06 19:57:19 +01:00
parent 617040c275
commit 4616488e1d

View file

@ -104,6 +104,9 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
connect(m_ui->m_cmbMessagesTimeFormat, &QComboBox::currentTextChanged, connect(m_ui->m_cmbMessagesTimeFormat, &QComboBox::currentTextChanged,
this, &SettingsFeedsMessages::updateDateTimeTooltip); this, &SettingsFeedsMessages::updateDateTimeTooltip);
emit m_ui->m_cmbMessagesDateTimeFormat->currentTextChanged({});
emit m_ui->m_cmbMessagesTimeFormat->currentTextChanged({});
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);
}); });
@ -126,30 +129,19 @@ SettingsFeedsMessages::~SettingsFeedsMessages() {
} }
void SettingsFeedsMessages::initializeMessageDateFormats() { void SettingsFeedsMessages::initializeMessageDateFormats() {
/*
QStringList datetime_formats, time_formats;
const QDateTime current_dt = QDateTime::currentDateTime();
const QLocale current_locale = qApp->localization()->loadedLocale();
auto installed_languages = qApp->localization()->installedLanguages();
for (const Language& lang : qAsConst(installed_languages)) {
QLocale locale(lang.m_code);
datetime_formats << locale.dateTimeFormat(QLocale::FormatType::LongFormat)
<< locale.dateTimeFormat(QLocale::FormatType::ShortFormat)
<< locale.dateTimeFormat(QLocale::FormatType::NarrowFormat);
time_formats << locale.timeFormat(QLocale::FormatType::LongFormat)
<< locale.timeFormat(QLocale::FormatType::ShortFormat)
<< locale.timeFormat(QLocale::FormatType::NarrowFormat);
}
datetime_formats.removeDuplicates();
time_formats.removeDuplicates();*/
QStringList patterns = TextFactory::dateTimePatterns(); QStringList patterns = TextFactory::dateTimePatterns();
m_ui->m_cmbMessagesDateTimeFormat->addItems(patterns); m_ui->m_cmbMessagesDateTimeFormat->addItems(patterns);
m_ui->m_cmbMessagesTimeFormat->addItems(patterns); m_ui->m_cmbMessagesTimeFormat->addItems(patterns);
for (int i = 0; i < patterns.size(); i++) {
m_ui->m_cmbMessagesDateTimeFormat->setItemData(i,
QDateTime::currentDateTime().toString(patterns.at(i)),
Qt::ItemDataRole::ToolTipRole);
m_ui->m_cmbMessagesTimeFormat->setItemData(i,
QDateTime::currentDateTime().toString(patterns.at(i)),
Qt::ItemDataRole::ToolTipRole);
}
} }
void SettingsFeedsMessages::changeFont(QLabel& lbl) { void SettingsFeedsMessages::changeFont(QLabel& lbl) {