Save
This commit is contained in:
parent
7f07404525
commit
192c08dbc4
src/librssguard
miscellaneous
services
@ -316,7 +316,7 @@ DKEY Browser::CustomExternalBrowserExecutable = "external_browser_executable";
|
|||||||
DVALUE(QString) Browser::CustomExternalBrowserExecutableDef = QString();
|
DVALUE(QString) Browser::CustomExternalBrowserExecutableDef = QString();
|
||||||
|
|
||||||
DKEY Browser::CustomExternalBrowserArguments = "external_browser_arguments";
|
DKEY Browser::CustomExternalBrowserArguments = "external_browser_arguments";
|
||||||
DVALUE(char*) Browser::CustomExternalBrowserArgumentsDef = "%1";
|
DVALUE(char*) Browser::CustomExternalBrowserArgumentsDef = "\"%1\"";
|
||||||
|
|
||||||
DKEY Browser::CustomExternalEmailEnabled = "custom_external_email";
|
DKEY Browser::CustomExternalEmailEnabled = "custom_external_email";
|
||||||
DVALUE(bool) Browser::CustomExternalEmailEnabledDef = false;
|
DVALUE(bool) Browser::CustomExternalEmailEnabledDef = false;
|
||||||
|
@ -18,6 +18,17 @@ quint64 TextFactory::s_encryptionKey = 0x0;
|
|||||||
|
|
||||||
TextFactory::TextFactory() = default;
|
TextFactory::TextFactory() = default;
|
||||||
|
|
||||||
|
QString TextFactory::extractUsernameFromEmail(const QString& email_address) {
|
||||||
|
const int zav = email_address.indexOf('@');
|
||||||
|
|
||||||
|
if (zav >= 0) {
|
||||||
|
return email_address.mid(0, zav);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return email_address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QColor TextFactory::generateColorFromText(const QString& text) {
|
QColor TextFactory::generateColorFromText(const QString& text) {
|
||||||
quint32 color = 0;
|
quint32 color = 0;
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ class TextFactory {
|
|||||||
TextFactory();
|
TextFactory();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static QString extractUsernameFromEmail(const QString& email_address);
|
||||||
static QColor generateColorFromText(const QString& text);
|
static QColor generateColorFromText(const QString& text);
|
||||||
static int stringHeight(const QString& string, const QFontMetrics& metrics);
|
static int stringHeight(const QString& string, const QFontMetrics& metrics);
|
||||||
static int stringWidth(const QString& string, const QFontMetrics& metrics);
|
static int stringWidth(const QString& string, const QFontMetrics& metrics);
|
||||||
|
@ -24,10 +24,8 @@ GmailServiceRoot::GmailServiceRoot(RootItem* parent)
|
|||||||
setIcon(GmailEntryPoint().icon());
|
setIcon(GmailEntryPoint().icon());
|
||||||
}
|
}
|
||||||
|
|
||||||
GmailServiceRoot::~GmailServiceRoot() = default;
|
|
||||||
|
|
||||||
void GmailServiceRoot::updateTitle() {
|
void GmailServiceRoot::updateTitle() {
|
||||||
setTitle(m_network->username() + QSL(" (Gmail)"));
|
setTitle(TextFactory::extractUsernameFromEmail(m_network->username()) + QSL(" (Gmail)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GmailServiceRoot::replyToEmail() {
|
void GmailServiceRoot::replyToEmail() {
|
||||||
|
@ -13,7 +13,6 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GmailServiceRoot(RootItem* parent = nullptr);
|
explicit GmailServiceRoot(RootItem* parent = nullptr);
|
||||||
virtual ~GmailServiceRoot();
|
|
||||||
|
|
||||||
void saveAccountDataToDatabase(bool creating_new);
|
void saveAccountDataToDatabase(bool creating_new);
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ GreaderServiceRoot::GreaderServiceRoot(RootItem* parent)
|
|||||||
setIcon(GreaderEntryPoint().icon());
|
setIcon(GreaderEntryPoint().icon());
|
||||||
}
|
}
|
||||||
|
|
||||||
GreaderServiceRoot::~GreaderServiceRoot() {}
|
|
||||||
|
|
||||||
bool GreaderServiceRoot::isSyncable() const {
|
bool GreaderServiceRoot::isSyncable() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -106,41 +104,44 @@ void GreaderServiceRoot::saveAllCachedData(bool ignore_errors) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMapIterator<QString, QStringList> k(msg_cache.m_cachedLabelAssignments);
|
if (m_network->service() != Service::TheOldReader) {
|
||||||
|
// The Old Reader does not support labels.
|
||||||
|
QMapIterator<QString, QStringList> k(msg_cache.m_cachedLabelAssignments);
|
||||||
|
|
||||||
// Assign label for these messages.
|
// Assign label for these messages.
|
||||||
while (k.hasNext()) {
|
while (k.hasNext()) {
|
||||||
k.next();
|
k.next();
|
||||||
auto label_custom_id = k.key();
|
auto label_custom_id = k.key();
|
||||||
QStringList messages = k.value();
|
QStringList messages = k.value();
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
if (network()->editLabels(label_custom_id, true, messages, networkProxy()) != QNetworkReply::NetworkError::NoError &&
|
if (network()->editLabels(label_custom_id, true, messages, networkProxy()) != QNetworkReply::NetworkError::NoError &&
|
||||||
!ignore_errors) {
|
!ignore_errors) {
|
||||||
addLabelsAssignmentsToCache(messages, label_custom_id, true);
|
addLabelsAssignmentsToCache(messages, label_custom_id, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QMapIterator<QString, QStringList> l(msg_cache.m_cachedLabelDeassignments);
|
QMapIterator<QString, QStringList> l(msg_cache.m_cachedLabelDeassignments);
|
||||||
|
|
||||||
// Remove label from these messages.
|
// Remove label from these messages.
|
||||||
while (l.hasNext()) {
|
while (l.hasNext()) {
|
||||||
l.next();
|
l.next();
|
||||||
auto label_custom_id = l.key();
|
auto label_custom_id = l.key();
|
||||||
QStringList messages = l.value();
|
QStringList messages = l.value();
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
if (network()->editLabels(label_custom_id, false, messages, networkProxy()) != QNetworkReply::NetworkError::NoError &&
|
if (network()->editLabels(label_custom_id, false, messages, networkProxy()) != QNetworkReply::NetworkError::NoError &&
|
||||||
!ignore_errors) {
|
!ignore_errors) {
|
||||||
addLabelsAssignmentsToCache(messages, label_custom_id, false);
|
addLabelsAssignmentsToCache(messages, label_custom_id, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GreaderServiceRoot::updateTitleIcon() {
|
void GreaderServiceRoot::updateTitleIcon() {
|
||||||
setTitle(QString("%1 (%2)").arg(m_network->username(),
|
setTitle(QString("%1 (%2)").arg(TextFactory::extractUsernameFromEmail(m_network->username()),
|
||||||
m_network->serviceToString(m_network->service())));
|
m_network->serviceToString(m_network->service())));
|
||||||
|
|
||||||
switch (m_network->service()) {
|
switch (m_network->service()) {
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#include "services/abstract/cacheforserviceroot.h"
|
#include "services/abstract/cacheforserviceroot.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
class GreaderNetwork;
|
class GreaderNetwork;
|
||||||
|
|
||||||
class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
@ -21,7 +19,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit GreaderServiceRoot(RootItem* parent = nullptr);
|
explicit GreaderServiceRoot(RootItem* parent = nullptr);
|
||||||
virtual ~GreaderServiceRoot();
|
|
||||||
|
|
||||||
virtual bool isSyncable() const;
|
virtual bool isSyncable() const;
|
||||||
virtual bool canBeEdited() const;
|
virtual bool canBeEdited() const;
|
||||||
@ -32,7 +29,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
virtual QString code() const;
|
virtual QString code() const;
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
|
|
||||||
void setNetwork(GreaderNetwork* network);
|
|
||||||
GreaderNetwork* network() const;
|
GreaderNetwork* network() const;
|
||||||
|
|
||||||
void updateTitleIcon();
|
void updateTitleIcon();
|
||||||
@ -50,10 +46,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(GreaderServiceRoot::Service)
|
Q_DECLARE_METATYPE(GreaderServiceRoot::Service)
|
||||||
|
|
||||||
inline void GreaderServiceRoot::setNetwork(GreaderNetwork* network) {
|
|
||||||
m_network = network;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline GreaderNetwork* GreaderServiceRoot::network() const {
|
inline GreaderNetwork* GreaderServiceRoot::network() const {
|
||||||
return m_network;
|
return m_network;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user