From d09c28ed50aca8e0c6d991f0822654e8df9b3aa1 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 6 Apr 2021 07:21:55 +0200 Subject: [PATCH] separate message count limit setting to own widget --- .../desktop/com.github.rssguard.appdata.xml | 2 +- src/librssguard/gui/messagecountspinbox.cpp | 25 +++++++++++++++++++ src/librssguard/gui/messagecountspinbox.h | 13 ++++++++++ src/librssguard/librssguard.pro | 2 ++ src/librssguard/services/feedly/definitions.h | 1 - .../feedly/gui/feedlyaccountdetails.cpp | 13 ---------- .../feedly/gui/feedlyaccountdetails.ui | 10 +++++--- src/librssguard/services/gmail/definitions.h | 1 - .../services/gmail/gmailnetworkfactory.cpp | 4 ++- .../gmail/gui/gmailaccountdetails.cpp | 4 --- .../services/gmail/gui/gmailaccountdetails.ui | 12 +++++---- .../services/greader/definitions.h | 1 - .../greader/gui/greaderaccountdetails.cpp | 9 ------- .../greader/gui/greaderaccountdetails.ui | 20 +++++---------- .../inoreader/gui/inoreaderaccountdetails.ui | 6 +++++ 15 files changed, 69 insertions(+), 54 deletions(-) create mode 100755 src/librssguard/gui/messagecountspinbox.cpp create mode 100755 src/librssguard/gui/messagecountspinbox.h diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml index f6045e0cd..9469a5bd3 100644 --- a/resources/desktop/com.github.rssguard.appdata.xml +++ b/resources/desktop/com.github.rssguard.appdata.xml @@ -30,7 +30,7 @@ https://martinrotter.github.io/donate/ - + none diff --git a/src/librssguard/gui/messagecountspinbox.cpp b/src/librssguard/gui/messagecountspinbox.cpp new file mode 100755 index 000000000..e62406bc3 --- /dev/null +++ b/src/librssguard/gui/messagecountspinbox.cpp @@ -0,0 +1,25 @@ +// For license of this file, see /LICENSE.md. + +#include "gui/messagecountspinbox.h" + +#include "definitions/definitions.h" + +#include + +MessageCountSpinBox::MessageCountSpinBox(QWidget* parent) : QSpinBox(parent) { + connect(this, QOverload::of(&QSpinBox::valueChanged), this, [=](int value) { + if (value <= 0) { + setSuffix(QSL(" ") + tr("= unlimited")); + } + else if (value == 1) { + setSuffix(QSL(" ") + tr("message")); + } + else { + setSuffix(QSL(" ") + tr("messages")); + } + }); + + setMinimum(-1); + setMaximum(999999); + setValue(200); +} diff --git a/src/librssguard/gui/messagecountspinbox.h b/src/librssguard/gui/messagecountspinbox.h new file mode 100755 index 000000000..cfb399808 --- /dev/null +++ b/src/librssguard/gui/messagecountspinbox.h @@ -0,0 +1,13 @@ +// For license of this file, see /LICENSE.md. + +#ifndef MESSAGECOUNTSPINBOX_H +#define MESSAGECOUNTSPINBOX_H + +#include + +class MessageCountSpinBox : public QSpinBox { + public: + explicit MessageCountSpinBox(QWidget* parent = nullptr); +}; + +#endif // MESSAGECOUNTSPINBOX_H diff --git a/src/librssguard/librssguard.pro b/src/librssguard/librssguard.pro index df488f832..7da9b96d8 100644 --- a/src/librssguard/librssguard.pro +++ b/src/librssguard/librssguard.pro @@ -83,6 +83,7 @@ HEADERS += core/feeddownloader.h \ gui/labelwithstatus.h \ gui/lineeditwithstatus.h \ gui/messagebox.h \ + gui/messagecountspinbox.h \ gui/messagepreviewer.h \ gui/messagessearchlineedit.h \ gui/messagestoolbar.h \ @@ -261,6 +262,7 @@ SOURCES += core/feeddownloader.cpp \ gui/labelwithstatus.cpp \ gui/lineeditwithstatus.cpp \ gui/messagebox.cpp \ + gui/messagecountspinbox.cpp \ gui/messagepreviewer.cpp \ gui/messagessearchlineedit.cpp \ gui/messagestoolbar.cpp \ diff --git a/src/librssguard/services/feedly/definitions.h b/src/librssguard/services/feedly/definitions.h index 2beea8eb0..b0abfe989 100755 --- a/src/librssguard/services/feedly/definitions.h +++ b/src/librssguard/services/feedly/definitions.h @@ -1,7 +1,6 @@ #ifndef FEEDLY_DEFINITIONS_H #define FEEDLY_DEFINITIONS_H -#define FEEDLY_UNLIMITED_BATCH_SIZE -1 #define FEEDLY_DEFAULT_BATCH_SIZE 100 #define FEEDLY_MAX_BATCH_SIZE 500 #define FEEDLY_MAX_TOTAL_SIZE 5000 diff --git a/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp b/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp index 12c6d3aca..84f7aec65 100755 --- a/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp +++ b/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp @@ -45,15 +45,6 @@ FeedlyAccountDetails::FeedlyAccountDetails(QWidget* parent) : QWidget(parent) { "Feedly automagically caches ALL messages of a feed forever so you might " "end with thousands of messages you will never read anyway.")); - connect(m_ui.m_spinLimitMessages, static_cast(&QSpinBox::valueChanged), this, [=](int value) { - if (value <= 0) { - m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("= unlimited")); - } - else { - m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("messages")); - } - }); - GuiUtilities::setLabelAsNotice(*m_ui.m_lblInfo, true); GuiUtilities::setLabelAsNotice(*m_ui.m_lblLimitMessagesInfo, true); @@ -62,10 +53,6 @@ FeedlyAccountDetails::FeedlyAccountDetails(QWidget* parent) : QWidget(parent) { connect(m_ui.m_txtDeveloperAccessToken->lineEdit(), &BaseLineEdit::textChanged, this, &FeedlyAccountDetails::onDeveloperAccessTokenChanged); - m_ui.m_spinLimitMessages->setMinimum(FEEDLY_UNLIMITED_BATCH_SIZE); - m_ui.m_spinLimitMessages->setMaximum(FEEDLY_MAX_BATCH_SIZE); - m_ui.m_spinLimitMessages->setValue(FEEDLY_DEFAULT_BATCH_SIZE); - setTabOrder(m_ui.m_txtUsername->lineEdit(), m_ui.m_btnGetToken); setTabOrder(m_ui.m_btnGetToken, m_ui.m_txtDeveloperAccessToken->lineEdit()); setTabOrder(m_ui.m_txtDeveloperAccessToken->lineEdit(), m_ui.m_checkDownloadOnlyUnreadMessages); diff --git a/src/librssguard/services/feedly/gui/feedlyaccountdetails.ui b/src/librssguard/services/feedly/gui/feedlyaccountdetails.ui index 36d7022a2..50290d681 100755 --- a/src/librssguard/services/feedly/gui/feedlyaccountdetails.ui +++ b/src/librssguard/services/feedly/gui/feedlyaccountdetails.ui @@ -65,16 +65,13 @@ - + 140 16777215 - - message(s) - @@ -145,6 +142,11 @@
labelwithstatus.h
1 + + MessageCountSpinBox + QSpinBox +
messagecountspinbox.h
+
diff --git a/src/librssguard/services/gmail/definitions.h b/src/librssguard/services/gmail/definitions.h index aa6fbd8a9..49782611a 100644 --- a/src/librssguard/services/gmail/definitions.h +++ b/src/librssguard/services/gmail/definitions.h @@ -21,7 +21,6 @@ #define GMAIL_DEFAULT_BATCH_SIZE 100 #define GMAIL_MAX_BATCH_SIZE 999 -#define GMAIL_MIN_BATCH_SIZE 20 #define GMAIL_SYSTEM_LABEL_UNREAD "UNREAD" #define GMAIL_SYSTEM_LABEL_INBOX "INBOX" diff --git a/src/librssguard/services/gmail/gmailnetworkfactory.cpp b/src/librssguard/services/gmail/gmailnetworkfactory.cpp index ceab3dcd1..411ccfa82 100755 --- a/src/librssguard/services/gmail/gmailnetworkfactory.cpp +++ b/src/librssguard/services/gmail/gmailnetworkfactory.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include GmailNetworkFactory::GmailNetworkFactory(QObject* parent) : QObject(parent), @@ -186,6 +187,7 @@ QList GmailNetworkFactory::messages(const QString& stream_id, QString bearer = m_oauth2->bearer().toLocal8Bit(); QString next_page_token; QList messages; + ulong msecs_wait_between_batches = 1500; if (bearer.isEmpty()) { error = Feed::Status::AuthError; @@ -236,6 +238,7 @@ QList GmailNetworkFactory::messages(const QString& stream_id, if (obtained) { messages.append(more_messages); + QThread::msleep(msecs_wait_between_batches); // New batch of messages was obtained, check if we have enough. if (batchSize() > 0 && batchSize() <= messages.size()) { @@ -244,7 +247,6 @@ QList GmailNetworkFactory::messages(const QString& stream_id, } } else { - error = Feed::Status::NetworkError; return messages; } diff --git a/src/librssguard/services/gmail/gui/gmailaccountdetails.cpp b/src/librssguard/services/gmail/gui/gmailaccountdetails.cpp index 88d7bfa43..ea262274b 100644 --- a/src/librssguard/services/gmail/gui/gmailaccountdetails.cpp +++ b/src/librssguard/services/gmail/gui/gmailaccountdetails.cpp @@ -43,10 +43,6 @@ GmailAccountDetails::GmailAccountDetails(QWidget* parent) connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &GmailAccountDetails::testSetup); connect(m_ui.m_btnRegisterApi, &QPushButton::clicked, this, &GmailAccountDetails::registerApi); - m_ui.m_spinLimitMessages->setValue(GMAIL_DEFAULT_BATCH_SIZE); - m_ui.m_spinLimitMessages->setMinimum(GMAIL_MIN_BATCH_SIZE); - m_ui.m_spinLimitMessages->setMaximum(GMAIL_MAX_BATCH_SIZE); - emit m_ui.m_txtUsername->lineEdit()->textChanged(m_ui.m_txtUsername->lineEdit()->text()); emit m_ui.m_txtAppId->lineEdit()->textChanged(m_ui.m_txtAppId->lineEdit()->text()); emit m_ui.m_txtAppKey->lineEdit()->textChanged(m_ui.m_txtAppKey->lineEdit()->text()); diff --git a/src/librssguard/services/gmail/gui/gmailaccountdetails.ui b/src/librssguard/services/gmail/gui/gmailaccountdetails.ui index 3ef0f0112..cebbddd10 100644 --- a/src/librssguard/services/gmail/gui/gmailaccountdetails.ui +++ b/src/librssguard/services/gmail/gui/gmailaccountdetails.ui @@ -7,7 +7,7 @@ 0 0 431 - 258 + 259 @@ -128,16 +128,13 @@ - + 140 16777215 - - message(s) - @@ -195,6 +192,11 @@
labelwithstatus.h
1 + + MessageCountSpinBox + QSpinBox +
messagecountspinbox.h
+
m_btnRegisterApi diff --git a/src/librssguard/services/greader/definitions.h b/src/librssguard/services/greader/definitions.h index 2c13ddf58..289cae29c 100755 --- a/src/librssguard/services/greader/definitions.h +++ b/src/librssguard/services/greader/definitions.h @@ -1,7 +1,6 @@ #ifndef GREADER_DEFINITIONS_H #define GREADER_DEFINITIONS_H -#define GREADER_UNLIMITED_BATCH_SIZE -1 #define GREADER_DEFAULT_BATCH_SIZE 100 // URLs. diff --git a/src/librssguard/services/greader/gui/greaderaccountdetails.cpp b/src/librssguard/services/greader/gui/greaderaccountdetails.cpp index ab25a5bed..e0b4d56d3 100755 --- a/src/librssguard/services/greader/gui/greaderaccountdetails.cpp +++ b/src/librssguard/services/greader/gui/greaderaccountdetails.cpp @@ -31,15 +31,6 @@ GreaderAccountDetails::GreaderAccountDetails(QWidget* parent) : QWidget(parent) "than specified limit, then some older messages might not be " "downloaded during feed update.")); - connect(m_ui.m_spinLimitMessages, static_cast(&QSpinBox::valueChanged), this, [=](int value) { - if (value <= 0) { - m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("= unlimited")); - } - else { - m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("messages")); - } - }); - GuiUtilities::setLabelAsNotice(*m_ui.m_lblLimitMessages, true); connect(m_ui.m_checkShowPassword, &QCheckBox::toggled, this, &GreaderAccountDetails::displayPassword); diff --git a/src/librssguard/services/greader/gui/greaderaccountdetails.ui b/src/librssguard/services/greader/gui/greaderaccountdetails.ui index f575497fd..7b8843d76 100755 --- a/src/librssguard/services/greader/gui/greaderaccountdetails.ui +++ b/src/librssguard/services/greader/gui/greaderaccountdetails.ui @@ -47,20 +47,7 @@ - - - = unlimited - - - -1 - - - 1000 - - - -1 - - + @@ -177,6 +164,11 @@
labelwithstatus.h
1 + + MessageCountSpinBox + QSpinBox +
messagecountspinbox.h
+
m_spinLimitMessages diff --git a/src/librssguard/services/inoreader/gui/inoreaderaccountdetails.ui b/src/librssguard/services/inoreader/gui/inoreaderaccountdetails.ui index ec8c04f38..2bdca0600 100755 --- a/src/librssguard/services/inoreader/gui/inoreaderaccountdetails.ui +++ b/src/librssguard/services/inoreader/gui/inoreaderaccountdetails.ui @@ -165,6 +165,12 @@ Qt::Vertical + + + 0 + 0 + +