diff --git a/src/librssguard/miscellaneous/settings.cpp b/src/librssguard/miscellaneous/settings.cpp index 60d7c1fc7..54ec351dd 100755 --- a/src/librssguard/miscellaneous/settings.cpp +++ b/src/librssguard/miscellaneous/settings.cpp @@ -316,7 +316,7 @@ DKEY Browser::CustomExternalBrowserExecutable = "external_browser_executable"; DVALUE(QString) Browser::CustomExternalBrowserExecutableDef = QString(); DKEY Browser::CustomExternalBrowserArguments = "external_browser_arguments"; -DVALUE(char*) Browser::CustomExternalBrowserArgumentsDef = "%1"; +DVALUE(char*) Browser::CustomExternalBrowserArgumentsDef = "\"%1\""; DKEY Browser::CustomExternalEmailEnabled = "custom_external_email"; DVALUE(bool) Browser::CustomExternalEmailEnabledDef = false; diff --git a/src/librssguard/miscellaneous/textfactory.cpp b/src/librssguard/miscellaneous/textfactory.cpp index ddea95671..708c0ecfc 100755 --- a/src/librssguard/miscellaneous/textfactory.cpp +++ b/src/librssguard/miscellaneous/textfactory.cpp @@ -18,6 +18,17 @@ quint64 TextFactory::s_encryptionKey = 0x0; 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) { quint32 color = 0; diff --git a/src/librssguard/miscellaneous/textfactory.h b/src/librssguard/miscellaneous/textfactory.h index 35f32d211..811968c30 100755 --- a/src/librssguard/miscellaneous/textfactory.h +++ b/src/librssguard/miscellaneous/textfactory.h @@ -15,6 +15,7 @@ class TextFactory { TextFactory(); public: + static QString extractUsernameFromEmail(const QString& email_address); static QColor generateColorFromText(const QString& text); static int stringHeight(const QString& string, const QFontMetrics& metrics); static int stringWidth(const QString& string, const QFontMetrics& metrics); diff --git a/src/librssguard/services/gmail/gmailserviceroot.cpp b/src/librssguard/services/gmail/gmailserviceroot.cpp index 83e072837..543f91e6e 100644 --- a/src/librssguard/services/gmail/gmailserviceroot.cpp +++ b/src/librssguard/services/gmail/gmailserviceroot.cpp @@ -24,10 +24,8 @@ GmailServiceRoot::GmailServiceRoot(RootItem* parent) setIcon(GmailEntryPoint().icon()); } -GmailServiceRoot::~GmailServiceRoot() = default; - void GmailServiceRoot::updateTitle() { - setTitle(m_network->username() + QSL(" (Gmail)")); + setTitle(TextFactory::extractUsernameFromEmail(m_network->username()) + QSL(" (Gmail)")); } void GmailServiceRoot::replyToEmail() { diff --git a/src/librssguard/services/gmail/gmailserviceroot.h b/src/librssguard/services/gmail/gmailserviceroot.h index 6c6588a87..1a8301bd2 100644 --- a/src/librssguard/services/gmail/gmailserviceroot.h +++ b/src/librssguard/services/gmail/gmailserviceroot.h @@ -13,7 +13,6 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot { public: explicit GmailServiceRoot(RootItem* parent = nullptr); - virtual ~GmailServiceRoot(); void saveAccountDataToDatabase(bool creating_new); diff --git a/src/librssguard/services/greader/greaderserviceroot.cpp b/src/librssguard/services/greader/greaderserviceroot.cpp index fae7abda1..552ec31b1 100755 --- a/src/librssguard/services/greader/greaderserviceroot.cpp +++ b/src/librssguard/services/greader/greaderserviceroot.cpp @@ -20,8 +20,6 @@ GreaderServiceRoot::GreaderServiceRoot(RootItem* parent) setIcon(GreaderEntryPoint().icon()); } -GreaderServiceRoot::~GreaderServiceRoot() {} - bool GreaderServiceRoot::isSyncable() const { return true; } @@ -106,41 +104,44 @@ void GreaderServiceRoot::saveAllCachedData(bool ignore_errors) { } } - QMapIterator k(msg_cache.m_cachedLabelAssignments); + if (m_network->service() != Service::TheOldReader) { + // The Old Reader does not support labels. + QMapIterator k(msg_cache.m_cachedLabelAssignments); - // Assign label for these messages. - while (k.hasNext()) { - k.next(); - auto label_custom_id = k.key(); - QStringList messages = k.value(); + // Assign label for these messages. + while (k.hasNext()) { + k.next(); + auto label_custom_id = k.key(); + QStringList messages = k.value(); - if (!messages.isEmpty()) { - if (network()->editLabels(label_custom_id, true, messages, networkProxy()) != QNetworkReply::NetworkError::NoError && - !ignore_errors) { - addLabelsAssignmentsToCache(messages, label_custom_id, true); + if (!messages.isEmpty()) { + if (network()->editLabels(label_custom_id, true, messages, networkProxy()) != QNetworkReply::NetworkError::NoError && + !ignore_errors) { + addLabelsAssignmentsToCache(messages, label_custom_id, true); + } } } - } - QMapIterator l(msg_cache.m_cachedLabelDeassignments); + QMapIterator l(msg_cache.m_cachedLabelDeassignments); - // Remove label from these messages. - while (l.hasNext()) { - l.next(); - auto label_custom_id = l.key(); - QStringList messages = l.value(); + // Remove label from these messages. + while (l.hasNext()) { + l.next(); + auto label_custom_id = l.key(); + QStringList messages = l.value(); - if (!messages.isEmpty()) { - if (network()->editLabels(label_custom_id, false, messages, networkProxy()) != QNetworkReply::NetworkError::NoError && - !ignore_errors) { - addLabelsAssignmentsToCache(messages, label_custom_id, false); + if (!messages.isEmpty()) { + if (network()->editLabels(label_custom_id, false, messages, networkProxy()) != QNetworkReply::NetworkError::NoError && + !ignore_errors) { + addLabelsAssignmentsToCache(messages, label_custom_id, false); + } } } } } 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()))); switch (m_network->service()) { diff --git a/src/librssguard/services/greader/greaderserviceroot.h b/src/librssguard/services/greader/greaderserviceroot.h index 57c091797..297e31305 100755 --- a/src/librssguard/services/greader/greaderserviceroot.h +++ b/src/librssguard/services/greader/greaderserviceroot.h @@ -6,8 +6,6 @@ #include "services/abstract/cacheforserviceroot.h" #include "services/abstract/serviceroot.h" -#include - class GreaderNetwork; class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot { @@ -21,7 +19,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot { }; explicit GreaderServiceRoot(RootItem* parent = nullptr); - virtual ~GreaderServiceRoot(); virtual bool isSyncable() const; virtual bool canBeEdited() const; @@ -32,7 +29,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot { virtual QString code() const; virtual void saveAllCachedData(bool ignore_errors); - void setNetwork(GreaderNetwork* network); GreaderNetwork* network() const; void updateTitleIcon(); @@ -50,10 +46,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot { Q_DECLARE_METATYPE(GreaderServiceRoot::Service) -inline void GreaderServiceRoot::setNetwork(GreaderNetwork* network) { - m_network = network; -} - inline GreaderNetwork* GreaderServiceRoot::network() const { return m_network; }