Skip to content

Commit

Permalink
fixed #970
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Nov 7, 2024
1 parent 3f41aeb commit c0e8f91
Show file tree
Hide file tree
Showing 8 changed files with 541 additions and 456 deletions.
933 changes: 490 additions & 443 deletions localization/rssguard_en.ts

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions src/librssguard/gui/dialogs/formmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@

FormMain::FormMain(QWidget* parent, Qt::WindowFlags f)
: QMainWindow(parent, f), m_ui(new Ui::FormMain), m_trayMenu(nullptr), m_statusBar(nullptr) {
qDebugNN << LOGSEC_GUI
<< "Creating main application form in thread:" << QUOTE_W_SPACE_DOT(getThreadID());
qDebugNN << LOGSEC_GUI << "Creating main application form in thread:" << QUOTE_W_SPACE_DOT(getThreadID());
// setAttribute(Qt::WA_WindowPropagation, true);
m_ui->setupUi(this);
qApp->setMainForm(this);
Expand Down Expand Up @@ -190,6 +189,7 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionPlaySelectedArticlesInMediaPlayer;
actions << m_ui->m_actionOpenSelectedMessagesInternallyNoTab;
actions << m_ui->m_actionAlternateColorsInLists;
actions << m_ui->m_actionPauseFeedFetching;
actions << m_ui->m_actionMessagePreviewEnabled;
actions << m_ui->m_actionMarkAllItemsRead;
actions << m_ui->m_actionMarkSelectedItemsAsRead;
Expand Down Expand Up @@ -598,6 +598,8 @@ void FormMain::setupIcons() {
// Feeds/messages.
m_ui->m_menuAddItem->setIcon(icon_theme_factory->fromTheme(QSL("list-add")));
m_ui->m_actionStopRunningItemsUpdate->setIcon(icon_theme_factory->fromTheme(QSL("process-stop")));
m_ui->m_actionPauseFeedFetching->setIcon(icon_theme_factory->fromTheme(QSL("media-playback-pause"),
QSL("player_pause")));
m_ui->m_actionUpdateAllItems->setIcon(icon_theme_factory->fromTheme(QSL("download"), QSL("browser-download")));
m_ui->m_actionUpdateSelectedItems->setIcon(icon_theme_factory->fromTheme(QSL("download"), QSL("browser-download")));
m_ui->m_actionUpdateSelectedItemsWithCustomTimers->setIcon(icon_theme_factory->fromTheme(QSL("download"),
Expand Down Expand Up @@ -711,7 +713,7 @@ void FormMain::loadSize() {
->setChecked(settings->value(GROUP(GUI), SETTING(GUI::MessageViewerToolbarsVisible)).toBool());
m_ui->m_actionSwitchStatusBar->setChecked(settings->value(GROUP(GUI), SETTING(GUI::StatusBarVisible)).toBool());

// Other startup GUI-related settings.
// Other startup GUI-related or misc settings.
m_ui->m_actionSortFeedsAlphabetically
->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::SortAlphabetically)).toBool());
m_ui->m_actionShowOnlyUnreadItems
Expand All @@ -721,6 +723,8 @@ void FormMain::loadSize() {
->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::AutoExpandOnSelection)).toBool());
m_ui->m_actionAlternateColorsInLists
->setChecked(settings->value(GROUP(GUI), SETTING(GUI::AlternateRowColorsInLists)).toBool());
m_ui->m_actionPauseFeedFetching
->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::PauseFeedFetching)).toBool());
}

void FormMain::saveSize() {
Expand Down Expand Up @@ -1027,6 +1031,7 @@ void FormMain::createConnections() {
&QAction::toggled,
tabWidget()->feedMessageViewer(),
&FeedMessageViewer::alternateRowColorsInLists);
connect(m_ui->m_actionPauseFeedFetching, &QAction::toggled, qApp->feedReader(), &FeedReader::pauseUnpaseFeedFetching);
connect(m_ui->m_actionRestoreSelectedMessages,
&QAction::triggered,
tabWidget()->feedMessageViewer()->messagesView(),
Expand Down
13 changes: 11 additions & 2 deletions src/librssguard/gui/dialogs/formmain.ui
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<addaction name="m_actionUpdateSelectedItems"/>
<addaction name="m_actionUpdateSelectedItemsWithCustomTimers"/>
<addaction name="m_actionStopRunningItemsUpdate"/>
<addaction name="m_actionPauseFeedFetching"/>
<addaction name="separator"/>
<addaction name="m_menuAddItem"/>
<addaction name="m_actionEditSelectedItem"/>
Expand Down Expand Up @@ -233,7 +234,7 @@
<string notr="true">Ctrl+Q</string>
</property>
<property name="menuRole">
<enum>QAction::QuitRole</enum>
<enum>QAction::MenuRole::QuitRole</enum>
</property>
</action>
<action name="m_actionSettings">
Expand All @@ -258,7 +259,7 @@
<string notr="true"/>
</property>
<property name="menuRole">
<enum>QAction::AboutRole</enum>
<enum>QAction::MenuRole::AboutRole</enum>
</property>
</action>
<action name="m_actionFullscreen">
Expand Down Expand Up @@ -951,6 +952,14 @@
<string>Play in &amp;media player</string>
</property>
</action>
<action name="m_actionPauseFeedFetching">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Pause automatic feed fetching</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
25 changes: 19 additions & 6 deletions src/librssguard/miscellaneous/feedreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <QTimer>

FeedReader::FeedReader(QObject* parent)
: QObject(parent), m_autoUpdateTimer(new QTimer(this)), m_feedDownloader(nullptr) {
: QObject(parent), m_autoUpdateTimer(new QTimer(this)), m_feedDownloader(nullptr), m_feedFetchingPaused(false) {
m_feedsModel = new FeedsModel(this);
m_feedsProxyModel = new FeedsProxyModel(m_feedsModel, this);
m_messagesModel = new MessagesModel(this);
Expand Down Expand Up @@ -268,6 +268,20 @@ void FeedReader::stopRunningFeedUpdate() {
}
}

void FeedReader::pauseUnpaseFeedFetching(bool pause) {
m_feedFetchingPaused = pause;
qApp->settings()->setValue(GROUP(Feeds), Feeds::PauseFeedFetching, pause);
}

void FeedReader::warnAboutPausedFetching() const {
if (m_feedFetchingPaused) {
qApp->showGuiMessage(Notification::Event::GeneralEvent,
GuiMessage(tr("Feed fetching is paused"),
tr("Automatic feed fetching based on time interval is currently paused."),
QSystemTrayIcon::MessageIcon::Warning));
}
}

bool FeedReader::isFeedUpdateRunning() const {
return m_feedDownloader != nullptr && m_feedDownloader->isUpdateRunning();
}
Expand Down Expand Up @@ -307,10 +321,10 @@ void FeedReader::executeNextAutoUpdate() {

// Skip this round of auto-updating, but only if user disabled it when main window is active
// and there are no caches to synchronize.
if (disable_update_with_window && full_caches.empty()) {
if ((m_feedFetchingPaused || disable_update_with_window) && full_caches.empty()) {
qDebugNN << LOGSEC_CORE << "Delaying scheduled feed auto-download for some time since window "
<< "is focused and updates while focused are disabled by the "
<< "user and all account caches are empty.";
<< "user (or paused) and all account caches are empty.";

// Cannot update, quit.
return;
Expand All @@ -319,7 +333,6 @@ void FeedReader::executeNextAutoUpdate() {
if (!qApp->feedUpdateLock()->tryLock()) {
qDebugNN << LOGSEC_CORE << "Delaying scheduled feed auto-downloads and message state synchronization for "
<< "some time due to another running update.";

// Cannot update, quit.
return;
}
Expand All @@ -333,9 +346,9 @@ void FeedReader::executeNextAutoUpdate() {
synchronizeMessageData(caches);
}

if (disable_update_with_window) {
if (m_feedFetchingPaused || disable_update_with_window) {
qDebugNN << LOGSEC_CORE << "Delaying scheduled feed auto-download for some time since window "
<< "is focused. Article cache was synchronised nonetheless.";
<< "is focused or feed fetching is paused. Article cache was synchronised nonetheless.";
return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/librssguard/miscellaneous/feedreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
FeedsProxyModel* feedsProxyModel() const;
MessagesProxyModel* messagesProxyModel() const;

void warnAboutPausedFetching() const;

// Update feeds in extra thread.
void updateFeeds(const QList<Feed*>& feeds, bool update_switched_off_too = false);

Expand Down Expand Up @@ -66,6 +68,7 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
void updateAllFeeds();
void updateManuallyIntervaledFeeds();
void stopRunningFeedUpdate();
void pauseUnpaseFeedFetching(bool pause);
void quit();

private slots:
Expand Down Expand Up @@ -97,6 +100,7 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
QDateTime m_lastAutoUpdate;
QThread* m_feedDownloaderThread;
FeedDownloader* m_feedDownloader;
bool m_feedFetchingPaused;
};

#endif // FEEDREADER_H
7 changes: 5 additions & 2 deletions src/librssguard/miscellaneous/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ DVALUE(char*) Feeds::CountFormatDef = "(%unread)";
DKEY Feeds::EnableTooltipsFeedsMessages = "show_tooltips";
DVALUE(bool) Feeds::EnableTooltipsFeedsMessagesDef = true;

DKEY Feeds::PauseFeedFetching = "pause_feed_fetching";
DVALUE(bool) Feeds::PauseFeedFetchingDef = false;

DKEY Feeds::AutoUpdateInterval = "auto_update_interval";
DVALUE(int) Feeds::AutoUpdateIntervalDef = DEFAULT_AUTO_UPDATE_INTERVAL;

Expand Down Expand Up @@ -290,8 +293,8 @@ DVALUE(int) GUI::HeightRowFeedsDef = -1;

DKEY GUI::FeedsToolbarActions = "feeds_toolbar";
DVALUE(char*)
GUI::FeedsToolbarActionsDef =
"m_actionUpdateAllItems,m_actionStopRunningItemsUpdate,m_actionMarkAllItemsRead,spacer,search";
GUI::FeedsToolbarActionsDef = "m_actionUpdateAllItems,m_actionStopRunningItemsUpdate,m_actionPauseFeedFetching,m_"
"actionMarkAllItemsRead,spacer,search";

DKEY GUI::StatusbarActions = "status_bar";
DVALUE(char*)
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 @@ -94,6 +94,9 @@ namespace Feeds {
KEY EnableTooltipsFeedsMessages;
VALUE(bool) EnableTooltipsFeedsMessagesDef;

KEY PauseFeedFetching;
VALUE(bool) PauseFeedFetchingDef;

KEY AutoUpdateInterval;
VALUE(int) AutoUpdateIntervalDef;

Expand Down
1 change: 1 addition & 0 deletions src/rssguard/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ int main(int argc, char* argv[]) {

qApp->loadDynamicShortcuts();
qApp->hideOrShowMainForm();
qApp->feedReader()->warnAboutPausedFetching();
qApp->feedReader()->loadSavedMessageFilters();
qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts();
qApp->showTrayIcon();
Expand Down

0 comments on commit c0e8f91

Please sign in to comment.