This commit is contained in:
Martin Rotter 2021-02-01 09:57:32 +01:00
parent 7f07404525
commit 192c08dbc4
7 changed files with 39 additions and 37 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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() {

View File

@ -13,7 +13,6 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
public:
explicit GmailServiceRoot(RootItem* parent = nullptr);
virtual ~GmailServiceRoot();
void saveAccountDataToDatabase(bool creating_new);

View File

@ -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<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.
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<QString, QStringList> l(msg_cache.m_cachedLabelDeassignments);
QMapIterator<QString, QStringList> 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()) {

View File

@ -6,8 +6,6 @@
#include "services/abstract/cacheforserviceroot.h"
#include "services/abstract/serviceroot.h"
#include <QMap>
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;
}