Skip to content

Commit

Permalink
effectivelly implemented #1371 - added a switch to switch entire arti…
Browse files Browse the repository at this point in the history
…cle list if all selected items are RTL
  • Loading branch information
martinrotter committed Oct 8, 2024
1 parent 4e698c9 commit a57a6ab
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 25 deletions.
18 changes: 12 additions & 6 deletions src/librssguard/gui/messagesview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,19 +582,25 @@ void MessagesView::loadItem(RootItem* item) {
sort(col, ord, false, true, false, true);
m_sourceModel->loadMessages(item);

/*
if (item->kind() == RootItem::Kind::Feed) {
if (item->toFeed()->isRtl()) {
setLayoutDirection(Qt::LayoutDirection::RightToLeft);
bool switch_entire_rtl_list =
qApp->settings()->value(GROUP(Messages), SETTING(Messages::SwitchArticleListRtl)).toBool();

if (switch_entire_rtl_list && item != nullptr) {
if (item->kind() == RootItem::Kind::Feed) {
setLayoutDirection(item->toFeed()->isRtl() ? Qt::LayoutDirection::RightToLeft : Qt::LayoutDirection::LeftToRight);
}
else {
setLayoutDirection(Qt::LayoutDirection::LeftToRight);
auto fds = item->getSubTreeFeeds();
bool all_feeds_rtl = !fds.isEmpty() && std::all_of(fds.begin(), fds.end(), [](Feed* fd) {
return fd->isRtl();
});

setLayoutDirection(all_feeds_rtl ? Qt::LayoutDirection::RightToLeft : Qt::LayoutDirection::LeftToRight);
}
}
else {
setLayoutDirection(Qt::LayoutDirection::LeftToRight);
}
*/

// Messages are loaded, make sure that previously
// active message is not shown in browser.
Expand Down
4 changes: 4 additions & 0 deletions src/librssguard/gui/settings/settingsfeedsmessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
connect(m_ui->m_cmbIgnoreContentsChanges, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_cbHideCountsIfNoUnread, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_checkSwitchArticleListRtl, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_cbUpdateFeedListDuringFetching, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_checkAutoUpdateOnlyUnfocused, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
connect(m_ui->m_cmbUnreadIconType,
Expand Down Expand Up @@ -322,6 +323,8 @@ void SettingsFeedsMessages::loadSettings() {
.toBool());
m_ui->m_checkKeppMessagesInTheMiddle
->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool());
m_ui->m_checkSwitchArticleListRtl
->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::SwitchArticleListRtl)).toBool());
m_ui->m_checkRemoveReadMessagesOnExit
->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool());
m_ui->m_checkAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool());
Expand Down Expand Up @@ -457,6 +460,7 @@ void SettingsFeedsMessages::saveSettings() {
settings()->setValue(GROUP(Messages),
Messages::KeepCursorInCenter,
m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
settings()->setValue(GROUP(Messages), Messages::SwitchArticleListRtl, m_ui->m_checkSwitchArticleListRtl->isChecked());
settings()->setValue(GROUP(Messages), Messages::ClearReadOnExit, m_ui->m_checkRemoveReadMessagesOnExit->isChecked());
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateEnabled, m_ui->m_checkAutoUpdate->isChecked());
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateOnlyUnfocused, m_ui->m_checkAutoUpdateOnlyUnfocused->isChecked());
Expand Down
50 changes: 32 additions & 18 deletions src/librssguard/gui/settings/settingsfeedsmessages.ui
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -349,7 +349,7 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -392,7 +392,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -448,14 +448,14 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QCheckBox" name="m_checkMultilineArticleList">
<property name="text">
<string>Enable multiline items</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="HelpSpoiler" name="m_helpMultilineArticleList" native="true">
<property name="minimumSize">
<size>
Expand All @@ -465,7 +465,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Row height</string>
Expand All @@ -475,7 +475,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QSpinBox" name="m_spinHeightRowsMessages">
<property name="minimumSize">
<size>
Expand All @@ -494,7 +494,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Top/bottom row padding</string>
Expand All @@ -504,7 +504,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QSpinBox" name="m_spinPaddingRowsMessages">
<property name="minimumSize">
<size>
Expand All @@ -523,7 +523,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QCheckBox" name="m_checkMessagesDateTimeFormat">
<property name="text">
<string>Use custom date/time format</string>
Expand All @@ -536,7 +536,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormat">
<property name="minimumSize">
<size>
Expand All @@ -549,7 +549,7 @@
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QCheckBox" name="m_checkMessagesDateTimeFormatForDatesOnly">
<property name="text">
<string>Use custom date/time format for dates-only</string>
Expand All @@ -562,7 +562,7 @@
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QComboBox" name="m_cmbMessagesDateTimeFormatForDatesOnly">
<property name="minimumSize">
<size>
Expand All @@ -575,7 +575,7 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QCheckBox" name="m_checkMessagesTimeFormat">
<property name="text">
<string>Custom date/time format for today's articles</string>
Expand All @@ -588,7 +588,7 @@
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QComboBox" name="m_cmbMessagesTimeFormat">
<property name="minimumSize">
<size>
Expand All @@ -601,14 +601,14 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Show relative time for articles not older than</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QSpinBox" name="m_spinRelativeArticleTime">
<property name="minimum">
<number>-1</number>
Expand All @@ -618,7 +618,7 @@
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QGroupBox" name="m_gbArticleListFont">
<property name="title">
<string>Article list font</string>
Expand Down Expand Up @@ -680,6 +680,13 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkSwitchArticleListRtl">
<property name="text">
<string>Switch article list to RTL layout if all selected feeds are RTL</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down Expand Up @@ -730,6 +737,7 @@
<tabstop>m_btnChangeMessagesFont</tabstop>
<tabstop>m_cmbUnreadIconType</tabstop>
<tabstop>m_checkKeppMessagesInTheMiddle</tabstop>
<tabstop>m_checkSwitchArticleListRtl</tabstop>
<tabstop>m_checkMultilineArticleList</tabstop>
<tabstop>m_spinHeightRowsMessages</tabstop>
<tabstop>m_spinPaddingRowsMessages</tabstop>
Expand All @@ -741,6 +749,12 @@
<tabstop>m_btnChangeMessageListFont</tabstop>
<tabstop>m_gbFeedListFont</tabstop>
<tabstop>m_gbArticleListFont</tabstop>
<tabstop>m_tabFeedsMessages</tabstop>
<tabstop>m_cbLegacyArticleFormatting</tabstop>
<tabstop>m_checkMessagesDateTimeFormatForDatesOnly</tabstop>
<tabstop>m_cmbMessagesDateTimeFormatForDatesOnly</tabstop>
<tabstop>m_cmbArticleMarkingPolicy</tabstop>
<tabstop>m_spinArticleMarkingPolicy</tabstop>
</tabstops>
<resources/>
<connections/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,15 @@ QVariant TextBrowserViewer::loadOneResource(int type, const QUrl& name) {
QByteArray save_arr;
QBuffer save_buf(&save_arr, this);

if (img.save(&save_buf, "PNG", 100)) {
if (img.save(&save_buf, "JPG", 100)) {
save_buf.close();

IOFactory::writeFile(QSL("%1%2.jpg")
.arg(name.toString(QUrl::ComponentFormattingOption::FullyEncoded),
QString::number(acceptable_width))
.remove(QRegularExpression(":|\\/")),
save_arr);

resource_data_all_sizes.insert(acceptable_width, save_arr);
}
else {
Expand Down
3 changes: 3 additions & 0 deletions src/librssguard/miscellaneous/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ DVALUE(int) Messages::ArticleListPaddingDef = -1;
DKEY Messages::MultilineArticleList = "multiline_article_list";
DVALUE(bool) Messages::MultilineArticleListDef = false;

DKEY Messages::SwitchArticleListRtl = "switch_article_list_rtl";
DVALUE(bool) Messages::SwitchArticleListRtlDef = true;

DKEY Messages::UseCustomTime = "use_custom_time";
DVALUE(bool) Messages::UseCustomTimeDef = false;

Expand Down
3 changes: 3 additions & 0 deletions src/librssguard/miscellaneous/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ namespace Messages {
KEY MultilineArticleList;
VALUE(bool) MultilineArticleListDef;

KEY SwitchArticleListRtl;
VALUE(bool) SwitchArticleListRtlDef;

KEY CustomTimeFormat;
VALUE(QString) CustomTimeFormatDef;

Expand Down

0 comments on commit a57a6ab

Please sign in to comment.