Configurable delay for feeds update after app start - fixes #193.
This commit is contained in:
parent
db4947eb4b
commit
35f8936292
@ -52,7 +52,7 @@
|
||||
#define MIN_CATEGORY_NAME_LENGTH 1
|
||||
#define DEFAULT_AUTO_UPDATE_INTERVAL 15
|
||||
#define AUTO_UPDATE_INTERVAL 60000
|
||||
#define STARTUP_UPDATE_DELAY 30000
|
||||
#define STARTUP_UPDATE_DELAY 3.0 // In seconds.
|
||||
#define TIMEZONE_OFFSET_LIMIT 6
|
||||
#define CHANGE_EVENT_DELAY 250
|
||||
#define FLAG_ICON_SUBFOLDER "flags"
|
||||
|
@ -20,6 +20,8 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsFeedsMessages) {
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->m_spinStartupUpdateDelay->setMode(TimeSpinBox::Mode::MinutesSeconds);
|
||||
|
||||
initializeMessageDateFormats();
|
||||
GuiUtilities::setLabelAsNotice(*m_ui->label_9, false);
|
||||
|
||||
@ -44,6 +46,8 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
connect(m_ui->m_checkUpdateAllFeedsOnStartup, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinAutoUpdateInterval, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinStartupUpdateDelay, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinHeightImageAttachments, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinHeightRowsMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
@ -51,6 +55,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
connect(m_ui->m_spinHeightRowsFeeds, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkAutoUpdate, &QCheckBox::toggled, m_ui->m_spinAutoUpdateInterval, &TimeSpinBox::setEnabled);
|
||||
connect(m_ui->m_checkUpdateAllFeedsOnStartup, &QCheckBox::toggled, m_ui->m_spinStartupUpdateDelay, &TimeSpinBox::setEnabled);
|
||||
connect(m_ui->m_spinFeedUpdateTimeout, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
&SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_cmbMessagesDateTimeFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
@ -126,6 +131,10 @@ void SettingsFeedsMessages::loadSettings() {
|
||||
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_checkUpdateAllFeedsOnStartup->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());
|
||||
|
||||
auto aa = settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateStartupDelay)).toDouble();
|
||||
|
||||
m_ui->m_spinStartupUpdateDelay->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateStartupDelay)).toDouble());
|
||||
m_ui->m_cmbCountsFeedList->addItems(QStringList() << "(%unread)" << "[%unread]" << "%unread/%all" << "%unread-%all" << "[%unread|%all]");
|
||||
m_ui->m_cmbCountsFeedList->setEditText(settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString());
|
||||
m_ui->m_spinHeightImageAttachments->setValue(settings()->value(GROUP(Messages), SETTING(Messages::MessageHeadImageHeight)).toInt());
|
||||
@ -181,6 +190,7 @@ void SettingsFeedsMessages::saveSettings() {
|
||||
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::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(Messages), Messages::MessageHeadImageHeight, m_ui->m_spinHeightImageAttachments->value());
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>651</width>
|
||||
<height>478</height>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
@ -34,30 +34,16 @@
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_checkUpdateAllFeedsOnStartup">
|
||||
<property name="text">
|
||||
<string>Update all feed on application startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_checkAutoUpdateNotification">
|
||||
<property name="text">
|
||||
<string>Enable "auto-update started" notification</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_checkAutoUpdate">
|
||||
<widget class="QCheckBox" name="m_checkUpdateAllFeedsOnStartup">
|
||||
<property name="text">
|
||||
<string>Auto-update all feeds every</string>
|
||||
<string>Update all feed on application startup with initial delay of</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="TimeSpinBox" name="m_spinAutoUpdateInterval">
|
||||
<widget class="TimeSpinBox" name="m_spinStartupUpdateDelay">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -77,6 +63,20 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_checkAutoUpdateNotification">
|
||||
<property name="text">
|
||||
<string>Enable "auto-update started" notification</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="m_checkAutoUpdateOnlyUnfocused">
|
||||
<property name="text">
|
||||
<string>Only auto-update when application is unfocused</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
@ -88,6 +88,9 @@
|
||||
<property name="text">
|
||||
<string>Font preview</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_btnChangeFeedListFont</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -181,6 +184,36 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_checkAutoUpdate">
|
||||
<property name="text">
|
||||
<string>Auto-update all feeds every</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="TimeSpinBox" name="m_spinAutoUpdateInterval">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="font">
|
||||
@ -199,12 +232,18 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="m_checkAutoUpdateOnlyUnfocused">
|
||||
<property name="text">
|
||||
<string>Only auto-update when application is unfocused</string>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -311,6 +350,9 @@
|
||||
<property name="text">
|
||||
<string>Font preview</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_btnChangeMessageListFont</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -334,6 +376,9 @@
|
||||
<property name="text">
|
||||
<string>Font preview</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_btnChangeMessagesFont</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -348,6 +393,19 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -364,9 +422,11 @@
|
||||
<tabstops>
|
||||
<tabstop>m_tabFeedsMessages</tabstop>
|
||||
<tabstop>m_checkUpdateAllFeedsOnStartup</tabstop>
|
||||
<tabstop>m_spinStartupUpdateDelay</tabstop>
|
||||
<tabstop>m_checkAutoUpdateNotification</tabstop>
|
||||
<tabstop>m_checkAutoUpdate</tabstop>
|
||||
<tabstop>m_spinAutoUpdateInterval</tabstop>
|
||||
<tabstop>m_checkAutoUpdateOnlyUnfocused</tabstop>
|
||||
<tabstop>m_btnChangeFeedListFont</tabstop>
|
||||
<tabstop>m_spinFeedUpdateTimeout</tabstop>
|
||||
<tabstop>m_spinHeightRowsFeeds</tabstop>
|
||||
|
@ -5,10 +5,10 @@
|
||||
#include <QStringList>
|
||||
|
||||
TimeSpinBox::TimeSpinBox(QWidget* parent) : QDoubleSpinBox(parent) {
|
||||
setMinimum(3.0);
|
||||
setAccelerated(true);
|
||||
setDecimals(0);
|
||||
setMinimum(3.0);
|
||||
setMaximum(10000000.0);
|
||||
setMode(TimeSpinBox::Mode::HoursMinutes);
|
||||
}
|
||||
|
||||
double TimeSpinBox::valueFromText(const QString& text) const {
|
||||
@ -44,13 +44,26 @@ double TimeSpinBox::valueFromText(const QString& text) const {
|
||||
}
|
||||
|
||||
QString TimeSpinBox::textFromValue(double val) const {
|
||||
int minutes_total = int(val);
|
||||
int minutes_val = minutes_total % 60;
|
||||
int hours_val = (minutes_total - minutes_val) / 60;
|
||||
QString hours = tr("%n hour(s)", "", hours_val);
|
||||
QString minutes = tr("%n minute(s)", "", minutes_val);
|
||||
if (mode() == TimeSpinBox::Mode::HoursMinutes) {
|
||||
// "val" is number of minutes.
|
||||
int minutes_total = int(val);
|
||||
int minutes_val = minutes_total % 60;
|
||||
int hours_val = (minutes_total - minutes_val) / 60;
|
||||
QString hours = tr("%n hour(s)", "", hours_val);
|
||||
QString minutes = tr("%n minute(s)", "", minutes_val);
|
||||
|
||||
return hours + tr(" and ") + minutes;
|
||||
return hours + tr(" and ") + minutes;
|
||||
}
|
||||
else {
|
||||
// "val" is number of seconds.
|
||||
int seconds_val = int(val);
|
||||
int minutes_total = seconds_val / 60;
|
||||
int seconds_total = seconds_val - (minutes_total * 60);
|
||||
QString seconds = tr("%n seconds(s)", "", seconds_total);
|
||||
QString minutes = tr("%n minute(s)", "", minutes_total);
|
||||
|
||||
return minutes + tr(" and ") + seconds;
|
||||
}
|
||||
}
|
||||
|
||||
void TimeSpinBox::fixup(QString& input) const {
|
||||
@ -66,3 +79,13 @@ QValidator::State TimeSpinBox::validate(QString& input, int& pos) const {
|
||||
Q_UNUSED(pos)
|
||||
return (valueFromText(input) != -1.0) ? QValidator::Acceptable : QValidator::Intermediate;
|
||||
}
|
||||
|
||||
TimeSpinBox::Mode TimeSpinBox::mode() const {
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
void TimeSpinBox::setMode(const TimeSpinBox::Mode& mode) {
|
||||
m_mode = mode;
|
||||
|
||||
setValue(value());
|
||||
}
|
||||
|
@ -9,12 +9,23 @@ class TimeSpinBox : public QDoubleSpinBox {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class Mode {
|
||||
HoursMinutes,
|
||||
MinutesSeconds
|
||||
};
|
||||
|
||||
explicit TimeSpinBox(QWidget* parent = nullptr);
|
||||
|
||||
double valueFromText(const QString& text) const;
|
||||
QString textFromValue(double val) const;
|
||||
void fixup(QString& input) const;
|
||||
QValidator::State validate(QString& input, int& pos) const;
|
||||
|
||||
Mode mode() const;
|
||||
void setMode(const TimeSpinBox::Mode& mode);
|
||||
|
||||
private:
|
||||
Mode m_mode;
|
||||
};
|
||||
|
||||
#endif // TIMESPINBOX_H
|
||||
|
@ -35,7 +35,9 @@ FeedReader::FeedReader(QObject* parent)
|
||||
|
||||
if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()) {
|
||||
qDebug("Requesting update for all feeds on application startup.");
|
||||
QTimer::singleShot(STARTUP_UPDATE_DELAY, this, SLOT(updateAllFeeds()));
|
||||
QTimer::singleShot(qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateStartupDelay)).toDouble() * 1000,
|
||||
this,
|
||||
&FeedReader::updateAllFeeds);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,15 +57,11 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
|
||||
int autoUpdateInitialInterval() const;
|
||||
|
||||
public slots:
|
||||
|
||||
// Schedules all feeds from all accounts for update.
|
||||
void updateAllFeeds();
|
||||
void stopRunningFeedUpdate();
|
||||
void quit();
|
||||
|
||||
private slots:
|
||||
|
||||
// Is executed when next auto-update round could be done.
|
||||
void executeNextAutoUpdate();
|
||||
void checkServicesForAsyncOperations();
|
||||
void asyncCacheSaveFinished();
|
||||
|
@ -55,6 +55,10 @@ DKEY Feeds::FeedsUpdateOnStartup = "feeds_update_on_startup";
|
||||
|
||||
DVALUE(bool) Feeds::FeedsUpdateOnStartupDef = false;
|
||||
|
||||
DKEY Feeds::FeedsUpdateStartupDelay = "feeds_update_on_startup_delay";
|
||||
|
||||
DVALUE(double) Feeds::FeedsUpdateStartupDelayDef = STARTUP_UPDATE_DELAY;
|
||||
|
||||
DKEY Feeds::ShowOnlyUnreadFeeds = "show_only_unread_feeds";
|
||||
|
||||
DVALUE(bool) Feeds::ShowOnlyUnreadFeedsDef = false;
|
||||
@ -446,7 +450,6 @@ SettingsProperties Settings::determineProperties() {
|
||||
// We will use PORTABLE settings only and only if it is available and NON-PORTABLE
|
||||
// settings was not initialized before.
|
||||
#if defined (Q_OS_LINUX) || defined (Q_OS_ANDROID) || defined (Q_OS_MACOS)
|
||||
|
||||
// DO NOT use portable settings for Linux, it is really not used on that platform.
|
||||
const bool will_we_use_portable_settings = false;
|
||||
#else
|
||||
|
@ -76,6 +76,10 @@ namespace Feeds {
|
||||
|
||||
VALUE(bool) FeedsUpdateOnStartupDef;
|
||||
|
||||
KEY FeedsUpdateStartupDelay;
|
||||
|
||||
VALUE(double) FeedsUpdateStartupDelayDef;
|
||||
|
||||
KEY ShowOnlyUnreadFeeds;
|
||||
|
||||
VALUE(bool) ShowOnlyUnreadFeedsDef;
|
||||
|
Loading…
x
Reference in New Issue
Block a user