Lang sync + some code quality fixes + work on #102.

This commit is contained in:
Martin Rotter 2020-10-25 19:49:18 +01:00
parent 1618562295
commit 7f49c2883b
13 changed files with 133 additions and 94 deletions

View File

@ -3077,39 +3077,39 @@ Tokeny vyprší: %2</translation>
<name>MessageBrowser</name> <name>MessageBrowser</name>
<message> <message>
<source>You clicked some link. You can download the link contents or open it in external web browser.</source> <source>You clicked some link. You can download the link contents or open it in external web browser.</source>
<translation type="unfinished"/> <translation>Klikli jste na odkaz. Můžete stáhnout obsah odkazu nebo ho otevřít v externím webovém prohlížeči.</translation>
</message> </message>
<message> <message>
<source>What action do you want to take?</source> <source>What action do you want to take?</source>
<translation type="unfinished"/> <translation>Co chcete dělat?</translation>
</message> </message>
<message> <message>
<source>Open in external browser</source> <source>Open in external browser</source>
<translation type="unfinished"/> <translation>Otevřít v externím webovém prohlížeči</translation>
</message> </message>
<message> <message>
<source>Download</source> <source>Download</source>
<translation type="unfinished"/> <translation>Stáhnout</translation>
</message> </message>
<message> <message>
<source>Always open links in external browser.</source> <source>Always open links in external browser.</source>
<translation type="unfinished"/> <translation>Vždy otevírat odkazy v ext. prohlížeči.</translation>
</message> </message>
<message> <message>
<source>Incorrect link</source> <source>Incorrect link</source>
<translation type="unfinished"/> <translation>Špatný odkaz</translation>
</message> </message>
<message> <message>
<source>Selected hyperlink is invalid.</source> <source>Selected hyperlink is invalid.</source>
<translation type="unfinished"/> <translation>Vybraný odkaz je neplatný</translation>
</message> </message>
<message> <message>
<source>Click this link to download it or open it with external browser.</source> <source>Click this link to download it or open it with external browser.</source>
<translation type="unfinished"/> <translation>Klikněte na tento odkaz pro stáhnutí jeho obsahu nebo pro jeho otevření v externím webovém prohlížeči.</translation>
</message> </message>
<message> <message>
<source>image</source> <source>image</source>
<translation type="unfinished"/> <translation>obrázek</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -198,11 +198,11 @@
<name>ColorToolButton</name> <name>ColorToolButton</name>
<message> <message>
<source>Click me to change color!</source> <source>Click me to change color!</source>
<translation type="unfinished"/> <translation>Clique aqui para mudar a cor!</translation>
</message> </message>
<message> <message>
<source>Select new color</source> <source>Select new color</source>
<translation type="unfinished"/> <translation>Selecione a nova cor</translation>
</message> </message>
</context> </context>
<context> <context>
@ -310,7 +310,7 @@ Este site contêm %n feed(s).</numerusform></translation>
</message> </message>
<message> <message>
<source>Feeds were detected, but no suitable accounts are configured.</source> <source>Feeds were detected, but no suitable accounts are configured.</source>
<translation type="unfinished"/> <translation>Feeds foram detectados, mas nenhuma conta adequada foi configurada.</translation>
</message> </message>
</context> </context>
<context> <context>
@ -671,7 +671,7 @@ ou esta função ainda não foi implementada.</translation>
</message> </message>
<message> <message>
<source>Context menu for label</source> <source>Context menu for label</source>
<translation type="unfinished"/> <translation>Menu de contexto para etiqueta</translation>
</message> </message>
</context> </context>
<context> <context>
@ -819,27 +819,27 @@ ou esta função ainda não foi implementada.</translation>
</message> </message>
<message> <message>
<source>Name for your label</source> <source>Name for your label</source>
<translation type="unfinished"/> <translation>Nome para a sua etiqueta</translation>
</message> </message>
<message> <message>
<source>Label&apos;s name cannot be empty.</source> <source>Label&apos;s name cannot be empty.</source>
<translation type="unfinished"/> <translation>O nome da etiqueta não pode estar vazio.</translation>
</message> </message>
<message> <message>
<source>Perfect!</source> <source>Perfect!</source>
<translation type="unfinished"/> <translation>Perfeito!</translation>
</message> </message>
<message> <message>
<source>Hot stuff</source> <source>Hot stuff</source>
<translation type="unfinished"/> <translation>Conteúdo em alta</translation>
</message> </message>
<message> <message>
<source>Create new label</source> <source>Create new label</source>
<translation type="unfinished"/> <translation>Criar nova etiqueta</translation>
</message> </message>
<message> <message>
<source>Edit label &apos;%1&apos;</source> <source>Edit label &apos;%1&apos;</source>
<translation type="unfinished"/> <translation>Editar etiqueta &apos;%1&apos;</translation>
</message> </message>
</context> </context>
<context> <context>
@ -3068,7 +3068,7 @@ Expiração dos tokens de login: %2</translation>
</message> </message>
<message> <message>
<source>New label</source> <source>New label</source>
<translation type="unfinished"/> <translation>Nova etiqueta</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -198,11 +198,11 @@
<name>ColorToolButton</name> <name>ColorToolButton</name>
<message> <message>
<source>Click me to change color!</source> <source>Click me to change color!</source>
<translation type="unfinished"/> <translation>Klicka för att ändra färg</translation>
</message> </message>
<message> <message>
<source>Select new color</source> <source>Select new color</source>
<translation type="unfinished"/> <translation>Välj ny färg</translation>
</message> </message>
</context> </context>
<context> <context>
@ -310,7 +310,7 @@ Denna webbsida innehåller %n flöden.</numerusform></translation>
</message> </message>
<message> <message>
<source>Feeds were detected, but no suitable accounts are configured.</source> <source>Feeds were detected, but no suitable accounts are configured.</source>
<translation type="unfinished"/> <translation>Flöden har identifierats, men inget passande konto är konfigurerat.</translation>
</message> </message>
</context> </context>
<context> <context>
@ -671,7 +671,7 @@ att funktionen inte är implementerad än.</translation>
</message> </message>
<message> <message>
<source>Context menu for label</source> <source>Context menu for label</source>
<translation type="unfinished"/> <translation>Kontextmeny för etikett</translation>
</message> </message>
</context> </context>
<context> <context>
@ -819,27 +819,27 @@ att funktionen inte är implementerad än.</translation>
</message> </message>
<message> <message>
<source>Name for your label</source> <source>Name for your label</source>
<translation type="unfinished"/> <translation>Etikettnamn</translation>
</message> </message>
<message> <message>
<source>Label&apos;s name cannot be empty.</source> <source>Label&apos;s name cannot be empty.</source>
<translation type="unfinished"/> <translation>Etikettnamnet kan inte lämnas tomt.</translation>
</message> </message>
<message> <message>
<source>Perfect!</source> <source>Perfect!</source>
<translation type="unfinished"/> <translation>Perfekt!</translation>
</message> </message>
<message> <message>
<source>Hot stuff</source> <source>Hot stuff</source>
<translation type="unfinished"/> <translation>Hett material</translation>
</message> </message>
<message> <message>
<source>Create new label</source> <source>Create new label</source>
<translation type="unfinished"/> <translation>Skapa ny etikett</translation>
</message> </message>
<message> <message>
<source>Edit label &apos;%1&apos;</source> <source>Edit label &apos;%1&apos;</source>
<translation type="unfinished"/> <translation>Redigera etiketten &quot;%1&quot;</translation>
</message> </message>
</context> </context>
<context> <context>
@ -3067,7 +3067,7 @@ Inloggningstoken upphör: %2</translation>
</message> </message>
<message> <message>
<source>New label</source> <source>New label</source>
<translation type="unfinished"/> <translation>Ny etikett</translation>
</message> </message>
</context> </context>
<context> <context>

View File

@ -41,7 +41,8 @@ int Label::countOfAllMessages() const {
} }
bool Label::canBeEdited() const { bool Label::canBeEdited() const {
return true; return (getParentServiceRoot()->supportedLabelOperations() & ServiceRoot::LabelOperation::Editing) ==
ServiceRoot::LabelOperation::Editing;
} }
bool Label::editViaGui() { bool Label::editViaGui() {
@ -58,7 +59,8 @@ bool Label::editViaGui() {
} }
bool Label::canBeDeleted() const { bool Label::canBeDeleted() const {
return true; return (getParentServiceRoot()->supportedLabelOperations() & ServiceRoot::LabelOperation::Deleting) ==
ServiceRoot::LabelOperation::Deleting;
} }
bool Label::deleteViaGui() { bool Label::deleteViaGui() {

View File

@ -54,6 +54,7 @@ QList<QAction*> LabelsNode::contextMenuFeedsList() {
} }
void LabelsNode::createLabel() { void LabelsNode::createLabel() {
if ((getParentServiceRoot()->supportedLabelOperations() & ServiceRoot::LabelOperation::Adding) == ServiceRoot::LabelOperation::Adding) {
FormAddEditLabel frm(qApp->mainFormWidget()); FormAddEditLabel frm(qApp->mainFormWidget());
Label* new_lbl = frm.execForAdd(); Label* new_lbl = frm.execForAdd();
@ -64,4 +65,12 @@ void LabelsNode::createLabel() {
getParentServiceRoot()->requestItemReassignment(new_lbl, this); getParentServiceRoot()->requestItemReassignment(new_lbl, this);
} }
}
else {
qApp->showGuiMessage(tr("This account does not allow you to create labels."),
tr("Not allowed"),
QSystemTrayIcon::MessageIcon::Critical,
qApp->mainFormWidget(),
true);
}
} }

View File

@ -223,6 +223,10 @@ bool ServiceRoot::supportsCategoryAdding() const {
return false; return false;
} }
ServiceRoot::LabelOperation ServiceRoot::supportedLabelOperations() const {
return LabelOperation::Adding | LabelOperation::Editing | LabelOperation::Deleting;
}
void ServiceRoot::itemChanged(const QList<RootItem*>& items) { void ServiceRoot::itemChanged(const QList<RootItem*>& items) {
emit dataChanged(items); emit dataChanged(items);
} }
@ -703,3 +707,11 @@ void ServiceRoot::assembleCategories(Assignment categories) {
} }
} }
} }
ServiceRoot::LabelOperation operator|(ServiceRoot::LabelOperation lhs, ServiceRoot::LabelOperation rhs) {
return static_cast<ServiceRoot::LabelOperation>(static_cast<char>(lhs) | static_cast<char>(rhs));
}
ServiceRoot::LabelOperation operator&(ServiceRoot::LabelOperation lhs, ServiceRoot::LabelOperation rhs) {
return static_cast<ServiceRoot::LabelOperation>(static_cast<char>(lhs) & static_cast<char>(rhs));
}

View File

@ -28,6 +28,13 @@ typedef QPair<Message, RootItem::Importance> ImportanceChange;
class ServiceRoot : public RootItem { class ServiceRoot : public RootItem {
Q_OBJECT Q_OBJECT
public:
enum class LabelOperation {
Adding = 1,
Editing = 2,
Deleting = 4
};
public: public:
explicit ServiceRoot(RootItem* parent = nullptr); explicit ServiceRoot(RootItem* parent = nullptr);
virtual ~ServiceRoot(); virtual ~ServiceRoot();
@ -43,6 +50,7 @@ class ServiceRoot : public RootItem {
virtual QList<Message> undeletedMessages() const; virtual QList<Message> undeletedMessages() const;
virtual bool supportsFeedAdding() const; virtual bool supportsFeedAdding() const;
virtual bool supportsCategoryAdding() const; virtual bool supportsCategoryAdding() const;
virtual LabelOperation supportedLabelOperations() const;
// Returns list of specific actions for "Add new item" main window menu. // Returns list of specific actions for "Add new item" main window menu.
// So typical list of returned actions could look like: // So typical list of returned actions could look like:
@ -238,4 +246,7 @@ class ServiceRoot : public RootItem {
QList<QAction*> m_serviceMenu; QList<QAction*> m_serviceMenu;
}; };
ServiceRoot::LabelOperation operator|(ServiceRoot::LabelOperation lhs, ServiceRoot::LabelOperation rhs);
ServiceRoot::LabelOperation operator&(ServiceRoot::LabelOperation lhs, ServiceRoot::LabelOperation rhs);
#endif // SERVICEROOT_H #endif // SERVICEROOT_H

View File

@ -17,36 +17,32 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
void saveAccountDataToDatabase(); void saveAccountDataToDatabase();
bool downloadAttachmentOnMyOwn(const QUrl& url) const;
void setNetwork(GmailNetworkFactory* network); void setNetwork(GmailNetworkFactory* network);
GmailNetworkFactory* network() const; GmailNetworkFactory* network() const;
QList<QAction*> contextMenuMessagesList(const QList<Message>& messages); virtual bool downloadAttachmentOnMyOwn(const QUrl& url) const;
QList<QAction*> serviceMenu(); virtual QList<QAction*> contextMenuMessagesList(const QList<Message>& messages);
bool isSyncable() const; virtual QList<QAction*> serviceMenu();
bool canBeEdited() const; virtual bool isSyncable() const;
bool editViaGui(); virtual bool canBeEdited() const;
bool canBeDeleted() const; virtual bool editViaGui();
bool deleteViaGui(); virtual bool canBeDeleted() const;
bool supportsFeedAdding() const; virtual bool deleteViaGui();
bool supportsCategoryAdding() const; virtual bool supportsFeedAdding() const;
void start(bool freshly_activated); virtual bool supportsCategoryAdding() const;
void stop(); virtual void start(bool freshly_activated);
QString code() const; virtual void stop();
virtual QString code() const;
virtual QString additionalTooltip() const;
virtual void saveAllCachedData(bool async = true);
QString additionalTooltip() const;
void saveAllCachedData(bool async = true);
public slots:
void updateTitle(); void updateTitle();
private slots: private slots:
void replyToEmail(); void replyToEmail();
protected: protected:
RootItem* obtainNewTreeForSyncIn() const; virtual RootItem* obtainNewTreeForSyncIn() const;
private: private:
void writeNewEmail(); void writeNewEmail();

View File

@ -77,6 +77,10 @@ void InoreaderServiceRoot::saveAccountDataToDatabase() {
} }
} }
ServiceRoot::LabelOperation InoreaderServiceRoot::supportedLabelOperations() const {
return ServiceRoot::LabelOperation(0);
}
bool InoreaderServiceRoot::isSyncable() const { bool InoreaderServiceRoot::isSyncable() const {
return true; return true;
} }

View File

@ -20,26 +20,25 @@ class InoreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
void setNetwork(InoreaderNetworkFactory* network); void setNetwork(InoreaderNetworkFactory* network);
InoreaderNetworkFactory* network() const; InoreaderNetworkFactory* network() const;
bool isSyncable() const; virtual LabelOperation supportedLabelOperations() const;
bool canBeEdited() const; virtual bool isSyncable() const;
bool editViaGui(); virtual bool canBeEdited() const;
bool canBeDeleted() const; virtual bool editViaGui();
bool deleteViaGui(); virtual bool canBeDeleted() const;
bool supportsFeedAdding() const; virtual bool deleteViaGui();
bool supportsCategoryAdding() const; virtual bool supportsFeedAdding() const;
void start(bool freshly_activated); virtual bool supportsCategoryAdding() const;
void stop(); virtual void start(bool freshly_activated);
QString code() const; virtual void stop();
virtual QString code() const;
virtual QString additionalTooltip() const;
virtual void saveAllCachedData(bool async = true);
QString additionalTooltip() const;
RootItem* obtainNewTreeForSyncIn() const;
void saveAllCachedData(bool async = true);
public slots:
void updateTitle(); void updateTitle();
protected:
virtual RootItem* obtainNewTreeForSyncIn() const;
private: private:
void loadFromDatabase(); void loadFromDatabase();

View File

@ -39,8 +39,10 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
public slots: public slots:
void addNewFeed(RootItem* selected_item, const QString& url); void addNewFeed(RootItem* selected_item, const QString& url);
protected:
virtual RootItem* obtainNewTreeForSyncIn() const;
private: private:
RootItem* obtainNewTreeForSyncIn() const;
void loadFromDatabase(); void loadFromDatabase();
OwnCloudNetworkFactory* m_network; OwnCloudNetworkFactory* m_network;

View File

@ -32,6 +32,10 @@ TtRssServiceRoot::~TtRssServiceRoot() {
delete m_network; delete m_network;
} }
ServiceRoot::LabelOperation TtRssServiceRoot::supportedLabelOperations() const {
return ServiceRoot::LabelOperation(0);
}
void TtRssServiceRoot::start(bool freshly_activated) { void TtRssServiceRoot::start(bool freshly_activated) {
Q_UNUSED(freshly_activated) Q_UNUSED(freshly_activated)
loadFromDatabase(); loadFromDatabase();

View File

@ -19,21 +19,19 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
explicit TtRssServiceRoot(RootItem* parent = nullptr); explicit TtRssServiceRoot(RootItem* parent = nullptr);
virtual ~TtRssServiceRoot(); virtual ~TtRssServiceRoot();
void start(bool freshly_activated); virtual LabelOperation supportedLabelOperations() const;
void stop(); virtual void start(bool freshly_activated);
QString code() const; virtual void stop();
virtual QString code() const;
bool isSyncable() const; virtual bool isSyncable() const;
bool canBeEdited() const; virtual bool canBeEdited() const;
bool canBeDeleted() const; virtual bool canBeDeleted() const;
bool editViaGui(); virtual bool editViaGui();
bool deleteViaGui(); virtual bool deleteViaGui();
bool supportsFeedAdding() const; virtual bool supportsFeedAdding() const;
bool supportsCategoryAdding() const; virtual bool supportsCategoryAdding() const;
virtual QString additionalTooltip() const;
QString additionalTooltip() const; virtual void saveAllCachedData(bool async = true);
void saveAllCachedData(bool async = true);
// Access to network. // Access to network.
TtRssNetworkFactory* network() const; TtRssNetworkFactory* network() const;
@ -42,10 +40,12 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
void updateTitle(); void updateTitle();
public slots: public slots:
void addNewFeed(RootItem* selected_item, const QString& url = QString()); virtual void addNewFeed(RootItem* selected_item, const QString& url = QString());
protected:
virtual RootItem* obtainNewTreeForSyncIn() const;
private: private:
RootItem* obtainNewTreeForSyncIn() const;
void loadFromDatabase(); void loadFromDatabase();
TtRssNetworkFactory* m_network; TtRssNetworkFactory* m_network;