diff --git a/rssguard.pro b/rssguard.pro index 86807c80e..2f7865489 100755 --- a/rssguard.pro +++ b/rssguard.pro @@ -334,7 +334,8 @@ HEADERS += src/core/feeddownloader.h \ src/services/tt-rss/ttrssserviceentrypoint.h \ src/services/tt-rss/ttrssserviceroot.h \ src/network-web/httpresponse.h \ - src/services/gmail/gui/formdownloadattachment.h + src/services/gmail/gui/formdownloadattachment.h \ + src/services/gmail/gui/formaddeditemail.h SOURCES += src/core/feeddownloader.cpp \ src/core/feedsmodel.cpp \ @@ -467,7 +468,8 @@ SOURCES += src/core/feeddownloader.cpp \ src/services/tt-rss/ttrssserviceentrypoint.cpp \ src/services/tt-rss/ttrssserviceroot.cpp \ src/network-web/httpresponse.cpp \ - src/services/gmail/gui/formdownloadattachment.cpp + src/services/gmail/gui/formdownloadattachment.cpp \ + src/services/gmail/gui/formaddeditemail.cpp mac { OBJECTIVE_SOURCES += src/miscellaneous/disablewindowtabbing.mm @@ -499,7 +501,8 @@ FORMS += src/gui/dialogs/formabout.ui \ src/services/standard/gui/formstandardcategorydetails.ui \ src/services/standard/gui/formstandardimportexport.ui \ src/services/tt-rss/gui/formeditttrssaccount.ui \ - src/services/gmail/gui/formdownloadattachment.ui + src/services/gmail/gui/formdownloadattachment.ui \ + src/services/gmail/gui/formaddeditemail.ui equals(USE_WEBENGINE, true) { HEADERS += src/gui/locationlineedit.h \ diff --git a/src/services/gmail/gmailserviceroot.cpp b/src/services/gmail/gmailserviceroot.cpp index 6d914a6cd..62a79103b 100755 --- a/src/services/gmail/gmailserviceroot.cpp +++ b/src/services/gmail/gmailserviceroot.cpp @@ -10,6 +10,7 @@ #include "services/gmail/definitions.h" #include "services/gmail/gmailentrypoint.h" #include "services/gmail/gmailfeed.h" +#include "services/gmail/gui/formaddeditemail.h" #include "services/gmail/gui/formdownloadattachment.h" #include "services/gmail/gui/formeditgmailaccount.h" #include "services/gmail/network/gmailnetworkfactory.h" @@ -49,6 +50,10 @@ RootItem* GmailServiceRoot::obtainNewTreeForSyncIn() const { return root; } +void GmailServiceRoot::writeNewEmail() { + FormAddEditEmail(this, qApp->mainFormWidget()).execForAdd(); +} + void GmailServiceRoot::loadFromDatabase() { QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); Assignment categories = DatabaseQueries::getCategories(database, accountId()); @@ -121,6 +126,17 @@ bool GmailServiceRoot::downloadAttachmentOnMyOwn(const QUrl& url) const { return true; } +QList GmailServiceRoot::serviceMenu() { + if (m_serviceMenu.isEmpty()) { + QAction* act_new_email = new QAction(qApp->icons()->fromTheme(QSL("mail-message-new")), tr("Write new e-mail message"), this); + + connect(act_new_email, &QAction::triggered, this, &GmailServiceRoot::writeNewEmail); + m_serviceMenu.append(act_new_email); + } + + return m_serviceMenu; +} + bool GmailServiceRoot::canBeEdited() const { return true; } diff --git a/src/services/gmail/gmailserviceroot.h b/src/services/gmail/gmailserviceroot.h index 63078d09a..00e3c91ec 100755 --- a/src/services/gmail/gmailserviceroot.h +++ b/src/services/gmail/gmailserviceroot.h @@ -22,6 +22,7 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot { void setNetwork(GmailNetworkFactory* network); GmailNetworkFactory* network() const; + QList serviceMenu(); bool canBeEdited() const; bool editViaGui(); bool canBeDeleted() const; @@ -43,6 +44,7 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot { RootItem* obtainNewTreeForSyncIn() const; private: + void writeNewEmail(); void loadFromDatabase(); private: diff --git a/src/services/gmail/gui/formaddeditemail.cpp b/src/services/gmail/gui/formaddeditemail.cpp new file mode 100755 index 000000000..0ebf2e2b8 --- /dev/null +++ b/src/services/gmail/gui/formaddeditemail.cpp @@ -0,0 +1,13 @@ +// For license of this file, see /LICENSE.md. + +#include "services/gmail/gui/formaddeditemail.h" + +#include "services/gmail/gmailserviceroot.h" + +FormAddEditEmail::FormAddEditEmail(GmailServiceRoot* root, QWidget* parent) : QDialog(parent), m_root(root) { + m_ui.setupUi(this); +} + +void FormAddEditEmail::execForAdd() { + exec(); +} diff --git a/src/services/gmail/gui/formaddeditemail.h b/src/services/gmail/gui/formaddeditemail.h new file mode 100755 index 000000000..665ecc61d --- /dev/null +++ b/src/services/gmail/gui/formaddeditemail.h @@ -0,0 +1,31 @@ +// For license of this file, see /LICENSE.md. + +#ifndef FORMADDEDITEMAIL_H +#define FORMADDEDITEMAIL_H + +#include + +#include "ui_formaddeditemail.h" + +namespace Ui { + class FormAddEditEmail; +} + +class GmailServiceRoot; + +class FormAddEditEmail : public QDialog { + Q_OBJECT + + public: + explicit FormAddEditEmail(GmailServiceRoot* root, QWidget* parent = nullptr); + + public slots: + void execForAdd(); + + private: + GmailServiceRoot* m_root; + + Ui::FormAddEditEmail m_ui; +}; + +#endif // FORMADDEDITEMAIL_H diff --git a/src/services/gmail/gui/formaddeditemail.ui b/src/services/gmail/gui/formaddeditemail.ui new file mode 100755 index 000000000..add1c4d29 --- /dev/null +++ b/src/services/gmail/gui/formaddeditemail.ui @@ -0,0 +1,71 @@ + + + + + FormAddEditEmail + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 30 + 240 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + buttonBox + accepted() + FormAddEditEmail + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + FormAddEditEmail + reject() + + + 316 + 260 + + + 286 + 274 + + + + +