separate message count limit setting to own widget
This commit is contained in:
parent
706e1c8750
commit
d09c28ed50
@ -30,7 +30,7 @@
|
||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="3.9.0" date="2021-04-01"/>
|
||||
<release version="3.9.0" date="2021-04-06"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
25
src/librssguard/gui/messagecountspinbox.cpp
Executable file
25
src/librssguard/gui/messagecountspinbox.cpp
Executable file
@ -0,0 +1,25 @@
|
||||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#include "gui/messagecountspinbox.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
MessageCountSpinBox::MessageCountSpinBox(QWidget* parent) : QSpinBox(parent) {
|
||||
connect(this, QOverload<int>::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);
|
||||
}
|
13
src/librssguard/gui/messagecountspinbox.h
Executable file
13
src/librssguard/gui/messagecountspinbox.h
Executable file
@ -0,0 +1,13 @@
|
||||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#ifndef MESSAGECOUNTSPINBOX_H
|
||||
#define MESSAGECOUNTSPINBOX_H
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
class MessageCountSpinBox : public QSpinBox {
|
||||
public:
|
||||
explicit MessageCountSpinBox(QWidget* parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // MESSAGECOUNTSPINBOX_H
|
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -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<void (QSpinBox::*)(int)>(&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);
|
||||
|
@ -65,16 +65,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="m_spinLimitMessages">
|
||||
<widget class="MessageCountSpinBox" name="m_spinLimitMessages">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>140</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> message(s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -145,6 +142,11 @@
|
||||
<header>labelwithstatus.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>MessageCountSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>messagecountspinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -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"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QRegularExpression>
|
||||
#include <QThread>
|
||||
#include <QUrl>
|
||||
|
||||
GmailNetworkFactory::GmailNetworkFactory(QObject* parent) : QObject(parent),
|
||||
@ -186,6 +187,7 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id,
|
||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||
QString next_page_token;
|
||||
QList<Message> messages;
|
||||
ulong msecs_wait_between_batches = 1500;
|
||||
|
||||
if (bearer.isEmpty()) {
|
||||
error = Feed::Status::AuthError;
|
||||
@ -236,6 +238,7 @@ QList<Message> 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<Message> GmailNetworkFactory::messages(const QString& stream_id,
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
error = Feed::Status::NetworkError;
|
||||
return messages;
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>258</height>
|
||||
<height>259</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
@ -128,16 +128,13 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="m_spinLimitMessages">
|
||||
<widget class="MessageCountSpinBox" name="m_spinLimitMessages">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>140</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> message(s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -195,6 +192,11 @@
|
||||
<header>labelwithstatus.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>MessageCountSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>messagecountspinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_btnRegisterApi</tabstop>
|
||||
|
@ -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.
|
||||
|
@ -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<void (QSpinBox::*)(int)>(&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);
|
||||
|
@ -47,20 +47,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="m_spinLimitMessages">
|
||||
<property name="suffix">
|
||||
<string> = unlimited</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="MessageCountSpinBox" name="m_spinLimitMessages"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -177,6 +164,11 @@
|
||||
<header>labelwithstatus.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>MessageCountSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>messagecountspinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_spinLimitMessages</tabstop>
|
||||
|
@ -165,6 +165,12 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user