fix #530
This commit is contained in:
parent
344f8cfe8b
commit
7e1dd31810
6 changed files with 131 additions and 53 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
MessagesModel::MessagesModel(QObject* parent)
|
||||
: QSqlQueryModel(parent), m_cache(new MessagesModelCache(this)), m_messageHighlighter(MessageHighlighter::NoHighlighting),
|
||||
m_customDateFormat(QString()), m_selectedItem(nullptr), m_displayFeedIcons(false) {
|
||||
m_customDateFormat(QString()), m_customTimeFormat(QString()), m_selectedItem(nullptr), m_displayFeedIcons(false) {
|
||||
setupFonts();
|
||||
setupIcons();
|
||||
setupHeaderData();
|
||||
|
@ -186,6 +186,13 @@ void MessagesModel::updateDateFormat() {
|
|||
else {
|
||||
m_customDateFormat = QString();
|
||||
}
|
||||
|
||||
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::UseCustomTime)).toBool()) {
|
||||
m_customTimeFormat = qApp->settings()->value(GROUP(Messages), SETTING(Messages::CustomTimeFormat)).toString();
|
||||
}
|
||||
else {
|
||||
m_customTimeFormat = QString();
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesModel::updateFeedIconsDisplay() {
|
||||
|
@ -290,7 +297,10 @@ QVariant MessagesModel::data(const QModelIndex& idx, int role) const {
|
|||
if (index_column == MSG_DB_DCREATED_INDEX) {
|
||||
QDateTime dt = TextFactory::parseDateTime(QSqlQueryModel::data(idx, role).value<qint64>()).toLocalTime();
|
||||
|
||||
if (m_customDateFormat.isEmpty()) {
|
||||
if (dt.date() == QDate::currentDate() && !m_customTimeFormat.isEmpty()) {
|
||||
return dt.toString(m_customTimeFormat);
|
||||
}
|
||||
else if (m_customDateFormat.isEmpty()) {
|
||||
return QLocale().toString(dt, QLocale::FormatType::ShortFormat);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -91,6 +91,7 @@ class MessagesModel : public QSqlQueryModel, public MessagesModelSqlLayer {
|
|||
MessagesModelCache* m_cache;
|
||||
MessageHighlighter m_messageHighlighter;
|
||||
QString m_customDateFormat;
|
||||
QString m_customTimeFormat;
|
||||
RootItem* m_selectedItem;
|
||||
QList<QString> m_headerData;
|
||||
QList<QString> m_tooltipData;
|
||||
|
|
|
@ -49,8 +49,13 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
|||
connect(m_ui->m_checkAutoUpdateOnlyUnfocused, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkDisplayFeedIcons, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkKeppMessagesInTheMiddle, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
|
||||
connect(m_ui->m_checkMessagesDateTimeFormat, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkMessagesDateTimeFormat, &QCheckBox::toggled, m_ui->m_cmbMessagesDateTimeFormat, &QComboBox::setEnabled);
|
||||
|
||||
connect(m_ui->m_checkMessagesTimeFormat, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkMessagesTimeFormat, &QCheckBox::toggled, m_ui->m_cmbMessagesTimeFormat, &QComboBox::setEnabled);
|
||||
|
||||
connect(m_ui->m_checkRemoveReadMessagesOnExit, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkBringToForegroundAfterMsgOpened, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkUpdateAllFeedsOnStartup, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
|
@ -68,6 +73,8 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
|||
&SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_cmbMessagesDateTimeFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_cmbMessagesTimeFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 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,
|
||||
&SettingsFeedsMessages::dirtifySettings);
|
||||
|
@ -95,7 +102,7 @@ SettingsFeedsMessages::~SettingsFeedsMessages() {
|
|||
}
|
||||
|
||||
void SettingsFeedsMessages::initializeMessageDateFormats() {
|
||||
QStringList best_formats;
|
||||
QStringList datetime_formats, time_formats;
|
||||
const QDateTime current_dt = QDateTime::currentDateTime();
|
||||
const QLocale current_locale = qApp->localization()->loadedLocale();
|
||||
auto installed_languages = qApp->localization()->installedLanguages();
|
||||
|
@ -103,16 +110,24 @@ void SettingsFeedsMessages::initializeMessageDateFormats() {
|
|||
for (const Language& lang : qAsConst(installed_languages)) {
|
||||
QLocale locale(lang.m_code);
|
||||
|
||||
best_formats << locale.dateTimeFormat(QLocale::FormatType::LongFormat)
|
||||
<< locale.dateTimeFormat(QLocale::FormatType::ShortFormat)
|
||||
<< locale.dateTimeFormat(QLocale::FormatType::NarrowFormat);
|
||||
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);
|
||||
}
|
||||
|
||||
best_formats.removeDuplicates();
|
||||
datetime_formats.removeDuplicates();
|
||||
time_formats.removeDuplicates();
|
||||
|
||||
for (const QString& format : qAsConst(best_formats)) {
|
||||
for (const QString& format : qAsConst(datetime_formats)) {
|
||||
m_ui->m_cmbMessagesDateTimeFormat->addItem(current_locale.toString(current_dt, format), format);
|
||||
}
|
||||
|
||||
for (const QString& format : qAsConst(time_formats)) {
|
||||
m_ui->m_cmbMessagesTimeFormat->addItem(current_locale.toString(current_dt, format), format);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsFeedsMessages::changeFont(QLabel& lbl) {
|
||||
|
@ -164,13 +179,23 @@ void SettingsFeedsMessages::loadSettings() {
|
|||
#endif
|
||||
|
||||
m_ui->m_checkMessagesDateTimeFormat->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool());
|
||||
const int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::CustomDateFormat)).toString());
|
||||
|
||||
int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(settings()->value(GROUP(Messages),
|
||||
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());
|
||||
|
||||
index_format = m_ui->m_cmbMessagesTimeFormat->findData(settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::CustomTimeFormat)).toString());
|
||||
|
||||
if (index_format >= 0) {
|
||||
m_ui->m_cmbMessagesTimeFormat->setCurrentIndex(index_format);
|
||||
}
|
||||
|
||||
QFont fon;
|
||||
|
||||
fon.fromString(settings()->value(GROUP(Messages),
|
||||
|
@ -218,7 +243,6 @@ void SettingsFeedsMessages::saveSettings() {
|
|||
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateStartupDelay, m_ui->m_spinStartupUpdateDelay->value());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::CountFormat, m_ui->m_cmbCountsFeedList->currentText());
|
||||
settings()->setValue(GROUP(Messages), Messages::UseCustomDate, m_ui->m_checkMessagesDateTimeFormat->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::EnableTooltipsFeedsMessages, m_ui->m_checkShowTooltips->isChecked());
|
||||
settings()->setValue(GROUP(Messages), Messages::IgnoreContentsChanges, m_ui->m_cmbIgnoreContentsChanges->isChecked());
|
||||
|
||||
|
@ -231,9 +255,15 @@ void SettingsFeedsMessages::saveSettings() {
|
|||
m_ui->m_cbShowEnclosuresDirectly->isChecked());
|
||||
#endif
|
||||
|
||||
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::CustomDateFormat,
|
||||
m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString());
|
||||
|
||||
settings()->setValue(GROUP(Messages), Messages::CustomTimeFormat,
|
||||
m_ui->m_cmbMessagesTimeFormat->itemData(m_ui->m_cmbMessagesTimeFormat->currentIndex()).toString());
|
||||
|
||||
// Save fonts.
|
||||
settings()->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString());
|
||||
settings()->setValue(GROUP(Messages), Messages::ListFont, m_ui->m_lblMessageListFont->font().toString());
|
||||
|
|
|
@ -80,38 +80,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Feed list font</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblFeedListFont">
|
||||
<property name="text">
|
||||
<string>Font preview</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_btnChangeFeedListFont</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="m_btnChangeFeedListFont">
|
||||
<property name="text">
|
||||
<string>&Change font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
|
@ -173,7 +141,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Article count format in feed list</string>
|
||||
|
@ -183,7 +151,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="m_cmbCountsFeedList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
|
@ -199,7 +167,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="font">
|
||||
<font>
|
||||
|
@ -217,21 +185,21 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbHideCountsIfNoUnread">
|
||||
<property name="text">
|
||||
<string>Hide article counts if there are no unread articles</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<item row="11" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_checkShowTooltips">
|
||||
<property name="text">
|
||||
<string>Display tooltips for feeds and articles</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<item row="12" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -244,13 +212,45 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbListsRestrictedShortcuts">
|
||||
<property name="text">
|
||||
<string>Allow only basic keyboard shortcuts for feed/article list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Feed list font</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblFeedListFont">
|
||||
<property name="text">
|
||||
<string>Font preview</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_btnChangeFeedListFont</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="m_btnChangeFeedListFont">
|
||||
<property name="text">
|
||||
<string>&Change font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_tabMessages">
|
||||
|
@ -375,7 +375,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<item row="11" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
|
@ -444,7 +444,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="2">
|
||||
<item row="13" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -464,6 +464,29 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QComboBox" name="m_cmbMessagesTimeFormat">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QCheckBox" name="m_checkMessagesTimeFormat">
|
||||
<property name="text">
|
||||
<string>Show only time for today articles</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -484,9 +507,9 @@
|
|||
<tabstop>m_checkAutoUpdate</tabstop>
|
||||
<tabstop>m_spinAutoUpdateInterval</tabstop>
|
||||
<tabstop>m_checkAutoUpdateOnlyUnfocused</tabstop>
|
||||
<tabstop>m_btnChangeFeedListFont</tabstop>
|
||||
<tabstop>m_spinFeedUpdateTimeout</tabstop>
|
||||
<tabstop>m_spinHeightRowsFeeds</tabstop>
|
||||
<tabstop>m_btnChangeFeedListFont</tabstop>
|
||||
<tabstop>m_cmbCountsFeedList</tabstop>
|
||||
<tabstop>m_cbHideCountsIfNoUnread</tabstop>
|
||||
<tabstop>m_cbListsRestrictedShortcuts</tabstop>
|
||||
|
@ -502,6 +525,8 @@
|
|||
<tabstop>m_spinHeightImageAttachments</tabstop>
|
||||
<tabstop>m_checkMessagesDateTimeFormat</tabstop>
|
||||
<tabstop>m_cmbMessagesDateTimeFormat</tabstop>
|
||||
<tabstop>m_checkMessagesTimeFormat</tabstop>
|
||||
<tabstop>m_cmbMessagesTimeFormat</tabstop>
|
||||
<tabstop>m_btnChangeMessageListFont</tabstop>
|
||||
<tabstop>m_btnChangeMessagesFont</tabstop>
|
||||
</tabstops>
|
||||
|
|
|
@ -105,6 +105,12 @@ DVALUE(bool) Messages::UseCustomDateDef = false;
|
|||
DKEY Messages::CustomDateFormat = "custom_date_format";
|
||||
DVALUE(char*) Messages::CustomDateFormatDef = "";
|
||||
|
||||
DKEY Messages::UseCustomTime = "use_custom_time";
|
||||
DVALUE(bool) Messages::UseCustomTimeDef = false;
|
||||
|
||||
DKEY Messages::CustomTimeFormat = "custom_time_format";
|
||||
DVALUE(QString) Messages::CustomTimeFormatDef = {};
|
||||
|
||||
DKEY Messages::ClearReadOnExit = "clear_read_on_exit";
|
||||
DVALUE(bool) Messages::ClearReadOnExitDef = false;
|
||||
|
||||
|
|
|
@ -122,6 +122,12 @@ namespace Messages {
|
|||
KEY CustomDateFormat;
|
||||
VALUE(char*) CustomDateFormatDef;
|
||||
|
||||
KEY UseCustomTime;
|
||||
VALUE(bool) UseCustomTimeDef;
|
||||
|
||||
KEY CustomTimeFormat;
|
||||
VALUE(QString) CustomTimeFormatDef;
|
||||
|
||||
KEY ClearReadOnExit;
|
||||
VALUE(bool) ClearReadOnExitDef;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue