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>
<message>
<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>
<source>What action do you want to take?</source>
<translation type="unfinished"/>
<translation>Co chcete dělat?</translation>
</message>
<message>
<source>Open in external browser</source>
<translation type="unfinished"/>
<translation>Otevřít v externím webovém prohlížeči</translation>
</message>
<message>
<source>Download</source>
<translation type="unfinished"/>
<translation>Stáhnout</translation>
</message>
<message>
<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>
<source>Incorrect link</source>
<translation type="unfinished"/>
<translation>Špatný odkaz</translation>
</message>
<message>
<source>Selected hyperlink is invalid.</source>
<translation type="unfinished"/>
<translation>Vybraný odkaz je neplatný</translation>
</message>
<message>
<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>
<source>image</source>
<translation type="unfinished"/>
<translation>obrázek</translation>
</message>
</context>
<context>

View File

@ -198,11 +198,11 @@
<name>ColorToolButton</name>
<message>
<source>Click me to change color!</source>
<translation type="unfinished"/>
<translation>Clique aqui para mudar a cor!</translation>
</message>
<message>
<source>Select new color</source>
<translation type="unfinished"/>
<translation>Selecione a nova cor</translation>
</message>
</context>
<context>
@ -310,7 +310,7 @@ Este site contêm %n feed(s).</numerusform></translation>
</message>
<message>
<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>
</context>
<context>
@ -671,7 +671,7 @@ ou esta função ainda não foi implementada.</translation>
</message>
<message>
<source>Context menu for label</source>
<translation type="unfinished"/>
<translation>Menu de contexto para etiqueta</translation>
</message>
</context>
<context>
@ -819,27 +819,27 @@ ou esta função ainda não foi implementada.</translation>
</message>
<message>
<source>Name for your label</source>
<translation type="unfinished"/>
<translation>Nome para a sua etiqueta</translation>
</message>
<message>
<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>
<source>Perfect!</source>
<translation type="unfinished"/>
<translation>Perfeito!</translation>
</message>
<message>
<source>Hot stuff</source>
<translation type="unfinished"/>
<translation>Conteúdo em alta</translation>
</message>
<message>
<source>Create new label</source>
<translation type="unfinished"/>
<translation>Criar nova etiqueta</translation>
</message>
<message>
<source>Edit label &apos;%1&apos;</source>
<translation type="unfinished"/>
<translation>Editar etiqueta &apos;%1&apos;</translation>
</message>
</context>
<context>
@ -3068,7 +3068,7 @@ Expiração dos tokens de login: %2</translation>
</message>
<message>
<source>New label</source>
<translation type="unfinished"/>
<translation>Nova etiqueta</translation>
</message>
</context>
<context>

View File

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

View File

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

View File

@ -54,6 +54,7 @@ QList<QAction*> LabelsNode::contextMenuFeedsList() {
}
void LabelsNode::createLabel() {
if ((getParentServiceRoot()->supportedLabelOperations() & ServiceRoot::LabelOperation::Adding) == ServiceRoot::LabelOperation::Adding) {
FormAddEditLabel frm(qApp->mainFormWidget());
Label* new_lbl = frm.execForAdd();
@ -65,3 +66,11 @@ void LabelsNode::createLabel() {
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;
}
ServiceRoot::LabelOperation ServiceRoot::supportedLabelOperations() const {
return LabelOperation::Adding | LabelOperation::Editing | LabelOperation::Deleting;
}
void ServiceRoot::itemChanged(const QList<RootItem*>& 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 {
Q_OBJECT
public:
enum class LabelOperation {
Adding = 1,
Editing = 2,
Deleting = 4
};
public:
explicit ServiceRoot(RootItem* parent = nullptr);
virtual ~ServiceRoot();
@ -43,6 +50,7 @@ class ServiceRoot : public RootItem {
virtual QList<Message> undeletedMessages() const;
virtual bool supportsFeedAdding() const;
virtual bool supportsCategoryAdding() const;
virtual LabelOperation supportedLabelOperations() const;
// Returns list of specific actions for "Add new item" main window menu.
// So typical list of returned actions could look like:
@ -238,4 +246,7 @@ class ServiceRoot : public RootItem {
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

View File

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

View File

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

View File

@ -20,26 +20,25 @@ class InoreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
void setNetwork(InoreaderNetworkFactory* network);
InoreaderNetworkFactory* network() const;
bool isSyncable() const;
bool canBeEdited() const;
bool editViaGui();
bool canBeDeleted() const;
bool deleteViaGui();
bool supportsFeedAdding() const;
bool supportsCategoryAdding() const;
void start(bool freshly_activated);
void stop();
QString code() const;
virtual LabelOperation supportedLabelOperations() const;
virtual bool isSyncable() const;
virtual bool canBeEdited() const;
virtual bool editViaGui();
virtual bool canBeDeleted() const;
virtual bool deleteViaGui();
virtual bool supportsFeedAdding() const;
virtual bool supportsCategoryAdding() const;
virtual void start(bool freshly_activated);
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();
protected:
virtual RootItem* obtainNewTreeForSyncIn() const;
private:
void loadFromDatabase();

View File

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

View File

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

View File

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