added option to postpone auto updates, if window is focused
This commit is contained in:
parent
d2223c8e6d
commit
2e1c5e9d0a
@ -37,6 +37,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
|||||||
|
|
||||||
connect(m_ui->m_checkAutoUpdateNotification, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkAutoUpdateNotification, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
|
connect(m_ui->m_checkAutoUpdateOnlyUnfocused, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_checkKeppMessagesInTheMiddle, &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, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
connect(m_ui->m_checkRemoveReadMessagesOnExit, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
connect(m_ui->m_checkRemoveReadMessagesOnExit, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||||
@ -121,6 +122,7 @@ void SettingsFeedsMessages::loadSettings() {
|
|||||||
m_ui->m_checkKeppMessagesInTheMiddle->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool());
|
m_ui->m_checkKeppMessagesInTheMiddle->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool());
|
||||||
m_ui->m_checkRemoveReadMessagesOnExit->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).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());
|
m_ui->m_checkAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool());
|
||||||
|
m_ui->m_checkAutoUpdateOnlyUnfocused->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateOnlyUnfocused)).toBool());
|
||||||
m_ui->m_spinAutoUpdateInterval->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt());
|
m_ui->m_spinAutoUpdateInterval->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt());
|
||||||
m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
|
m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
|
||||||
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());
|
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());
|
||||||
@ -175,6 +177,7 @@ void SettingsFeedsMessages::saveSettings() {
|
|||||||
settings()->setValue(GROUP(Messages), Messages::KeepCursorInCenter, m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
|
settings()->setValue(GROUP(Messages), Messages::KeepCursorInCenter, m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
|
||||||
settings()->setValue(GROUP(Messages), Messages::ClearReadOnExit, m_ui->m_checkRemoveReadMessagesOnExit->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::AutoUpdateEnabled, m_ui->m_checkAutoUpdate->isChecked());
|
||||||
|
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateOnlyUnfocused, m_ui->m_checkAutoUpdateOnlyUnfocused->isChecked());
|
||||||
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value());
|
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value());
|
||||||
settings()->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value());
|
settings()->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value());
|
||||||
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
|
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox_6">
|
<widget class="QGroupBox" name="groupBox_6">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Feed list font</string>
|
<string>Feed list font</string>
|
||||||
@ -100,7 +100,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
@ -133,7 +133,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="6" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
@ -157,7 +157,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
@ -181,7 +181,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="2">
|
<item row="8" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_9">
|
<widget class="QLabel" name="label_9">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
@ -199,6 +199,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="m_checkAutoUpdateOnlyUnfocused">
|
||||||
|
<property name="text">
|
||||||
|
<string>Only update when application is unfocused</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="m_tabMessages">
|
<widget class="QWidget" name="m_tabMessages">
|
||||||
|
@ -88,6 +88,7 @@ void FeedReader::updateAutoUpdateStatus() {
|
|||||||
m_globalAutoUpdateInitialInterval = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt();
|
m_globalAutoUpdateInitialInterval = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt();
|
||||||
m_globalAutoUpdateRemainingInterval = m_globalAutoUpdateInitialInterval;
|
m_globalAutoUpdateRemainingInterval = m_globalAutoUpdateInitialInterval;
|
||||||
m_globalAutoUpdateEnabled = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool();
|
m_globalAutoUpdateEnabled = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool();
|
||||||
|
m_globalAutoUpdateOnlyUnfocused = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateOnlyUnfocused)).toBool();
|
||||||
|
|
||||||
// Start global auto-update timer if it is not running yet.
|
// Start global auto-update timer if it is not running yet.
|
||||||
// NOTE: The timer must run even if global auto-update
|
// NOTE: The timer must run even if global auto-update
|
||||||
@ -144,6 +145,14 @@ MessagesModel* FeedReader::messagesModel() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedReader::executeNextAutoUpdate() {
|
void FeedReader::executeNextAutoUpdate() {
|
||||||
|
if (qApp->mainFormWidget()->isActiveWindow() && m_globalAutoUpdateOnlyUnfocused) {
|
||||||
|
qDebug("Delaying scheduled feed auto-update for one minute since window is focused and updates"
|
||||||
|
"while focused are disabled by the user.");
|
||||||
|
|
||||||
|
// Cannot update, quit.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!qApp->feedUpdateLock()->tryLock()) {
|
if (!qApp->feedUpdateLock()->tryLock()) {
|
||||||
qDebug("Delaying scheduled feed auto-updates for one minute due to another running update.");
|
qDebug("Delaying scheduled feed auto-updates for one minute due to another running update.");
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
|
|||||||
// Auto-update stuff.
|
// Auto-update stuff.
|
||||||
QTimer* m_autoUpdateTimer;
|
QTimer* m_autoUpdateTimer;
|
||||||
bool m_globalAutoUpdateEnabled{};
|
bool m_globalAutoUpdateEnabled{};
|
||||||
|
bool m_globalAutoUpdateOnlyUnfocused{};
|
||||||
int m_globalAutoUpdateInitialInterval{};
|
int m_globalAutoUpdateInitialInterval{};
|
||||||
int m_globalAutoUpdateRemainingInterval{};
|
int m_globalAutoUpdateRemainingInterval{};
|
||||||
FeedDownloader* m_feedDownloader;
|
FeedDownloader* m_feedDownloader;
|
||||||
|
@ -47,6 +47,10 @@ DKEY Feeds::AutoUpdateEnabled = "auto_update_enabled";
|
|||||||
|
|
||||||
DVALUE(bool) Feeds::AutoUpdateEnabledDef = false;
|
DVALUE(bool) Feeds::AutoUpdateEnabledDef = false;
|
||||||
|
|
||||||
|
DKEY Feeds::AutoUpdateOnlyUnfocused = "auto_update_only_unfocused";
|
||||||
|
|
||||||
|
DVALUE(bool) Feeds::AutoUpdateOnlyUnfocusedDef = false;
|
||||||
|
|
||||||
DKEY Feeds::FeedsUpdateOnStartup = "feeds_update_on_startup";
|
DKEY Feeds::FeedsUpdateOnStartup = "feeds_update_on_startup";
|
||||||
|
|
||||||
DVALUE(bool) Feeds::FeedsUpdateOnStartupDef = false;
|
DVALUE(bool) Feeds::FeedsUpdateOnStartupDef = false;
|
||||||
|
@ -68,6 +68,10 @@ namespace Feeds {
|
|||||||
|
|
||||||
VALUE(bool) AutoUpdateEnabledDef;
|
VALUE(bool) AutoUpdateEnabledDef;
|
||||||
|
|
||||||
|
KEY AutoUpdateOnlyUnfocused;
|
||||||
|
|
||||||
|
VALUE(bool) AutoUpdateOnlyUnfocusedDef;
|
||||||
|
|
||||||
KEY FeedsUpdateOnStartup;
|
KEY FeedsUpdateOnStartup;
|
||||||
|
|
||||||
VALUE(bool) FeedsUpdateOnStartupDef;
|
VALUE(bool) FeedsUpdateOnStartupDef;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user