optionally enable ot= option
This commit is contained in:
parent
3480e1974a
commit
bc64407213
@ -30,7 +30,7 @@
|
||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="4.0.0" date="2021-08-10"/>
|
||||
<release version="4.0.0" date="2021-08-11"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
@ -10,8 +10,10 @@
|
||||
#include <QSize>
|
||||
#endif
|
||||
|
||||
void GuiUtilities::setLabelAsNotice(QLabel& label, bool is_warning) {
|
||||
label.setMargin(6);
|
||||
void GuiUtilities::setLabelAsNotice(QLabel& label, bool is_warning, bool set_margins) {
|
||||
if (set_margins) {
|
||||
label.setMargin(6);
|
||||
}
|
||||
|
||||
if (is_warning) {
|
||||
label.setStyleSheet(QSL("font-weight: bold; font-style: italic; color: red"));
|
||||
@ -23,9 +25,9 @@ void GuiUtilities::setLabelAsNotice(QLabel& label, bool is_warning) {
|
||||
|
||||
void GuiUtilities::applyDialogProperties(QWidget& widget, const QIcon& icon, const QString& title) {
|
||||
#if defined(Q_OS_WIN)
|
||||
widget.setWindowFlags(Qt::Dialog | Qt::WindowTitleHint);
|
||||
widget.setWindowFlags(Qt::WindowType::Dialog | Qt::WindowType::WindowTitleHint);
|
||||
#else
|
||||
widget.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
widget.setWindowFlags(Qt::WindowType::Dialog | Qt::WindowType::CustomizeWindowHint | Qt::WindowType::WindowCloseButtonHint);
|
||||
#endif
|
||||
|
||||
widget.setWindowIcon(icon);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
class GuiUtilities {
|
||||
public:
|
||||
static void setLabelAsNotice(QLabel& label, bool is_warning);
|
||||
static void setLabelAsNotice(QLabel& label, bool is_warning, bool set_margins = true);
|
||||
static void applyDialogProperties(QWidget& widget, const QIcon& icon = QIcon(), const QString& title = QString());
|
||||
static void applyResponsiveDialogResize(QWidget& widget, double factor = 0.6);
|
||||
|
||||
|
@ -23,6 +23,7 @@ GreaderNetwork::GreaderNetwork(QObject* parent)
|
||||
: QObject(parent), m_root(nullptr), m_service(GreaderServiceRoot::Service::FreshRss), m_username(QString()),
|
||||
m_password(QString()), m_baseUrl(QString()), m_batchSize(GREADER_DEFAULT_BATCH_SIZE), m_downloadOnlyUnreadMessages(false),
|
||||
m_prefetchedMessages({}), m_performGlobalFetching(false), m_intelligentSynchronization(false),
|
||||
m_newerThanFilter(QDate::currentDate().addYears(-1)),
|
||||
m_oauth2(new OAuth2Service(INO_OAUTH_AUTH_URL, INO_OAUTH_TOKEN_URL,
|
||||
{}, {}, INO_OAUTH_SCOPE, this)) {
|
||||
initializeOauth();
|
||||
@ -147,7 +148,7 @@ void GreaderNetwork::prepareFeedFetching(GreaderServiceRoot* root,
|
||||
<< "Percentage of feeds for fetching:"
|
||||
<< QUOTE_W_SPACE_DOT(perc_of_fetching);
|
||||
|
||||
auto remote_starred_ids_list = itemIds(GREADER_API_FULL_STATE_IMPORTANT, false, proxy);
|
||||
auto remote_starred_ids_list = itemIds(GREADER_API_FULL_STATE_IMPORTANT, false, proxy, -1, m_newerThanFilter);
|
||||
|
||||
for (int i = 0; i < remote_starred_ids_list.size(); i++) {
|
||||
remote_starred_ids_list.replace(i, convertShortStreamIdToLongStreamId(remote_starred_ids_list.at(i)));
|
||||
@ -171,8 +172,8 @@ void GreaderNetwork::prepareFeedFetching(GreaderServiceRoot* root,
|
||||
|
||||
QStringList remote_all_ids_list = m_downloadOnlyUnreadMessages
|
||||
? QStringList()
|
||||
: itemIds(GREADER_API_FULL_STATE_READING_LIST, false, proxy);
|
||||
QStringList remote_unread_ids_list = itemIds(GREADER_API_FULL_STATE_READING_LIST, true, proxy);
|
||||
: itemIds(GREADER_API_FULL_STATE_READING_LIST, false, proxy, -1, m_newerThanFilter);
|
||||
QStringList remote_unread_ids_list = itemIds(GREADER_API_FULL_STATE_READING_LIST, true, proxy, -1, m_newerThanFilter);
|
||||
|
||||
for (int i = 0; i < remote_all_ids_list.size(); i++) {
|
||||
remote_all_ids_list.replace(i, convertShortStreamIdToLongStreamId(remote_all_ids_list.at(i)));
|
||||
@ -248,8 +249,8 @@ QList<Message> GreaderNetwork::getMessagesIntelligently(ServiceRoot* root,
|
||||
// 4. Add prefetched starred msgs.
|
||||
QStringList remote_all_ids_list = m_downloadOnlyUnreadMessages
|
||||
? QStringList()
|
||||
: itemIds(stream_id, false, proxy);
|
||||
QStringList remote_unread_ids_list = itemIds(stream_id, true, proxy);
|
||||
: itemIds(stream_id, false, proxy, -1, m_newerThanFilter);
|
||||
QStringList remote_unread_ids_list = itemIds(stream_id, true, proxy, -1, m_newerThanFilter);
|
||||
|
||||
// Convert item IDs to long form.
|
||||
for (int i = 0; i < remote_all_ids_list.size(); i++) {
|
||||
@ -335,7 +336,8 @@ QNetworkReply::NetworkError GreaderNetwork::markMessagesStarred(RootItem::Import
|
||||
return editLabels(GREADER_API_FULL_STATE_IMPORTANT, importance == RootItem::Importance::Important, msg_custom_ids, proxy);
|
||||
}
|
||||
|
||||
QStringList GreaderNetwork::itemIds(const QString& stream_id, bool unread_only, const QNetworkProxy& proxy, int max_count) {
|
||||
QStringList GreaderNetwork::itemIds(const QString& stream_id, bool unread_only, const QNetworkProxy& proxy,
|
||||
int max_count, const QDate& newer_than) {
|
||||
QString continuation;
|
||||
|
||||
if (!ensureLogin(proxy)) {
|
||||
@ -361,6 +363,10 @@ QStringList GreaderNetwork::itemIds(const QString& stream_id, bool unread_only,
|
||||
full_url += QSL("&c=%1").arg(continuation);
|
||||
}
|
||||
|
||||
if (newer_than.isValid()) {
|
||||
full_url += QSL("&ot=%1").arg(QDateTime(newer_than).toSecsSinceEpoch());
|
||||
}
|
||||
|
||||
QByteArray output_stream;
|
||||
auto result_stream = NetworkFactory::performNetworkOperation(full_url,
|
||||
timeout,
|
||||
@ -486,6 +492,10 @@ QList<Message> GreaderNetwork::streamContents(ServiceRoot* root, const QString&
|
||||
full_url += QSL("&c=%1").arg(continuation);
|
||||
}
|
||||
|
||||
if (m_newerThanFilter.isValid()) {
|
||||
full_url += QSL("&ot=%1").arg(QDateTime(m_newerThanFilter).toSecsSinceEpoch());
|
||||
}
|
||||
|
||||
QByteArray output_stream;
|
||||
auto result_stream = NetworkFactory::performNetworkOperation(full_url,
|
||||
timeout,
|
||||
@ -1107,6 +1117,14 @@ void GreaderNetwork::initializeOauth() {
|
||||
});
|
||||
}
|
||||
|
||||
QDate GreaderNetwork::newerThanFilter() const {
|
||||
return m_newerThanFilter;
|
||||
}
|
||||
|
||||
void GreaderNetwork::setNewerThanFilter(const QDate& newer_than) {
|
||||
m_newerThanFilter = newer_than;
|
||||
}
|
||||
|
||||
OAuth2Service* GreaderNetwork::oauth() const {
|
||||
return m_oauth2;
|
||||
}
|
||||
|
@ -86,13 +86,17 @@ class GreaderNetwork : public QObject {
|
||||
QNetworkReply::NetworkError editLabels(const QString& state, bool assign,
|
||||
const QStringList& msg_custom_ids, const QNetworkProxy& proxy);
|
||||
QVariantHash userInfo(const QNetworkProxy& proxy);
|
||||
QStringList itemIds(const QString& stream_id, bool unread_only, const QNetworkProxy& proxy, int max_count = -1);
|
||||
QStringList itemIds(const QString& stream_id, bool unread_only, const QNetworkProxy& proxy, int max_count = -1,
|
||||
const QDate& newer_than = {});
|
||||
QList<Message> itemContents(ServiceRoot* root, const QList<QString>& stream_ids,
|
||||
Feed::Status& error, const QNetworkProxy& proxy);
|
||||
QList<Message> streamContents(ServiceRoot* root, const QString& stream_id,
|
||||
Feed::Status& error, const QNetworkProxy& proxy);
|
||||
QNetworkReply::NetworkError clientLogin(const QNetworkProxy& proxy);
|
||||
|
||||
QDate newerThanFilter() const;
|
||||
void setNewerThanFilter(const QDate& newer_than);
|
||||
|
||||
private slots:
|
||||
void onTokensError(const QString& error, const QString& error_description);
|
||||
void onAuthFailed();
|
||||
@ -130,6 +134,7 @@ class GreaderNetwork : public QObject {
|
||||
QList<Message> m_prefetchedMessages;
|
||||
bool m_performGlobalFetching;
|
||||
bool m_intelligentSynchronization;
|
||||
QDate m_newerThanFilter;
|
||||
OAuth2Service* m_oauth2;
|
||||
};
|
||||
|
||||
|
@ -48,6 +48,10 @@ QVariantHash GreaderServiceRoot::customDatabaseData() const {
|
||||
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
|
||||
data["intelligent_synchronization"] = m_network->intelligentSynchronization();
|
||||
|
||||
if (m_network->newerThanFilter().isValid()) {
|
||||
data["fetch_newer_than"] = m_network->newerThanFilter();
|
||||
}
|
||||
|
||||
if (m_network->service() == Service::Inoreader) {
|
||||
data["client_id"] = m_network->oauth()->clientId();
|
||||
data["client_secret"] = m_network->oauth()->clientSecret();
|
||||
@ -69,6 +73,10 @@ void GreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
|
||||
m_network->setIntelligentSynchronization(data["intelligent_synchronization"].toBool());
|
||||
|
||||
if (data["fetch_newer_than"].toDate().isValid()) {
|
||||
m_network->setNewerThanFilter(data["fetch_newer_than"].toDate());
|
||||
}
|
||||
|
||||
if (m_network->service() == Service::Inoreader) {
|
||||
m_network->oauth()->setClientId(data["client_id"].toString());
|
||||
m_network->oauth()->setClientSecret(data["client_secret"].toString());
|
||||
|
@ -33,6 +33,7 @@ void FormEditGreaderAccount::apply() {
|
||||
existing_root->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_cbDownloadOnlyUnreadMessages->isChecked());
|
||||
existing_root->network()->setService(m_details->service());
|
||||
existing_root->network()->setIntelligentSynchronization(m_details->m_ui.m_cbNewAlgorithm->isChecked());
|
||||
existing_root->network()->setNewerThanFilter(m_details->m_ui.m_dateNewerThan->date());
|
||||
|
||||
existing_root->network()->oauth()->logout(true);
|
||||
|
||||
@ -73,6 +74,7 @@ void FormEditGreaderAccount::loadAccountData() {
|
||||
m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize());
|
||||
m_details->m_ui.m_cbDownloadOnlyUnreadMessages->setChecked(existing_root->network()->downloadOnlyUnreadMessages());
|
||||
m_details->m_ui.m_cbNewAlgorithm->setChecked(existing_root->network()->intelligentSynchronization());
|
||||
m_details->m_ui.m_dateNewerThan->setDate(existing_root->network()->newerThanFilter());
|
||||
}
|
||||
|
||||
void FormEditGreaderAccount::performTest() {
|
||||
|
@ -27,6 +27,12 @@ GreaderAccountDetails::GreaderAccountDetails(QWidget* parent) : QWidget(parent),
|
||||
m_ui.m_cmbService->addItem(GreaderServiceRoot::serviceToString(serv), QVariant::fromValue(serv));
|
||||
}
|
||||
|
||||
m_ui.m_dateNewerThan->setMinimumDate(QDate(2000, 1, 1));
|
||||
m_ui.m_dateNewerThan->setMaximumDate(QDate::currentDate());
|
||||
|
||||
//m_ui.m_dateNewerThan->setDate(QDate::currentDate().addYears(-1));
|
||||
m_ui.m_dateNewerThan->setDisplayFormat(qApp->localization()->loadedLocale().dateFormat());
|
||||
|
||||
m_ui.m_lblTestResult->label()->setWordWrap(true);
|
||||
m_ui.m_txtPassword->lineEdit()->setPasswordMode(true);
|
||||
m_ui.m_txtPassword->lineEdit()->setPlaceholderText(tr("Password for your account"));
|
||||
@ -76,7 +82,8 @@ GreaderAccountDetails::GreaderAccountDetails(QWidget* parent) : QWidget(parent),
|
||||
setTabOrder(m_ui.m_cmbService, m_ui.m_txtUrl->lineEdit());
|
||||
setTabOrder(m_ui.m_txtUrl->lineEdit(), m_ui.m_cbDownloadOnlyUnreadMessages);
|
||||
setTabOrder(m_ui.m_cbDownloadOnlyUnreadMessages, m_ui.m_cbNewAlgorithm);
|
||||
setTabOrder(m_ui.m_cbNewAlgorithm, m_ui.m_spinLimitMessages);
|
||||
setTabOrder(m_ui.m_cbNewAlgorithm, m_ui.m_dateNewerThan);
|
||||
setTabOrder(m_ui.m_dateNewerThan, m_ui.m_spinLimitMessages);
|
||||
setTabOrder(m_ui.m_spinLimitMessages, m_ui.m_txtUsername->lineEdit());
|
||||
setTabOrder(m_ui.m_txtUsername->lineEdit(), m_ui.m_txtPassword->lineEdit());
|
||||
setTabOrder(m_ui.m_txtPassword->lineEdit(), m_ui.m_txtAppId);
|
||||
|
@ -21,7 +21,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_cmbService"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_lblTitle">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
@ -31,31 +31,42 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbDownloadOnlyUnreadMessages">
|
||||
<property name="text">
|
||||
<string>Download unread articles only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbNewAlgorithm">
|
||||
<property name="text">
|
||||
<string>Intelligent synchronization algorithm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLabel" name="m_lblNewAlgorithm">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Fetch articles newer than</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateEdit" name="m_dateNewerThan">
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="m_lblLimitMessagesShort">
|
||||
@ -72,51 +83,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QLabel" name="m_lblLimitMessages">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnTestSetup">
|
||||
<property name="text">
|
||||
<string>&Test setup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LabelWithStatus" name="m_lblTestResult" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="14" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>409</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="m_gbAuth">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
@ -308,6 +275,57 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnTestSetup">
|
||||
<property name="text">
|
||||
<string>&Test setup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LabelWithStatus" name="m_lblTestResult" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>409</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QLabel" name="m_lblLimitMessages">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QLabel" name="m_lblNewAlgorithm">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
Loading…
x
Reference in New Issue
Block a user