From 00dee012f1c0e3d12718d2cce88927c62f725923 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 1 Nov 2021 13:59:21 +0100 Subject: [PATCH] implement temporary status bar messages --- src/librssguard/core/feedsmodel.cpp | 9 +- src/librssguard/core/messagesmodel.cpp | 9 +- src/librssguard/gui/dialogs/formmain.cpp | 17 ++- src/librssguard/gui/dialogs/formupdate.cpp | 11 +- src/librssguard/gui/feedsview.cpp | 63 +++++------ src/librssguard/gui/messagesview.cpp | 8 +- src/librssguard/gui/newspaperpreviewer.cpp | 9 +- .../gui/reusable/discoverfeedsbutton.cpp | 9 +- src/librssguard/gui/systemtrayicon.cpp | 9 +- src/librssguard/gui/webviewer.cpp | 4 + src/librssguard/miscellaneous/application.cpp | 105 +++++++++--------- src/librssguard/miscellaneous/application.h | 38 ++++++- src/librssguard/miscellaneous/feedreader.cpp | 17 ++- .../miscellaneous/systemfactory.cpp | 16 +-- .../network-web/downloadmanager.cpp | 30 +++-- src/librssguard/network-web/oauth2service.cpp | 26 ++--- .../services/abstract/gui/formfeeddetails.cpp | 10 +- .../services/abstract/labelsnode.cpp | 9 +- .../services/feedly/feedlynetwork.cpp | 44 ++++---- .../services/gmail/gmailnetworkfactory.cpp | 40 +++---- .../services/greader/greadernetwork.cpp | 40 +++---- .../services/standard/standardcategory.cpp | 9 +- .../services/standard/standardfeed.cpp | 19 ++-- .../services/standard/standardserviceroot.cpp | 18 ++- .../tt-rss/gui/formttrssfeeddetails.cpp | 8 +- .../services/tt-rss/ttrssserviceroot.cpp | 9 +- 26 files changed, 301 insertions(+), 285 deletions(-) diff --git a/src/librssguard/core/feedsmodel.cpp b/src/librssguard/core/feedsmodel.cpp index 243296c9a..12e163e50 100644 --- a/src/librssguard/core/feedsmodel.cpp +++ b/src/librssguard/core/feedsmodel.cpp @@ -117,11 +117,10 @@ bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int if (dragged_item_root != target_item_root) { // Transferring of items between different accounts is not possible. - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot perform drag & drop operation"), - tr("You can't transfer dragged item into different account, this is not supported."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot perform drag & drop operation"), + tr("You can't transfer dragged item into different account, this is not supported."), + QSystemTrayIcon::MessageIcon::Warning }); qDebugNN << LOGSEC_FEEDMODEL << "Dragged item cannot be dragged into different account. Cancelling drag-drop action."; return false; diff --git a/src/librssguard/core/messagesmodel.cpp b/src/librssguard/core/messagesmodel.cpp index 0aa49c92a..c0af1f00f 100644 --- a/src/librssguard/core/messagesmodel.cpp +++ b/src/librssguard/core/messagesmodel.cpp @@ -142,11 +142,10 @@ void MessagesModel::loadMessages(RootItem* item) { qCriticalNN << LOGSEC_MESSAGEMODEL << "Loading of messages from item '" << item->title() << "' failed."; - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Loading of articles from item '%1' failed.").arg(item->title()), - tr("Loading of articles failed, maybe messages could not be downloaded."), - QSystemTrayIcon::MessageIcon::Critical, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Loading of articles from item '%1' failed").arg(item->title()), + tr("Loading of articles failed, maybe messages could not be downloaded."), + QSystemTrayIcon::MessageIcon::Critical }); } } diff --git a/src/librssguard/gui/dialogs/formmain.cpp b/src/librssguard/gui/dialogs/formmain.cpp index e522a0d6c..9f2f5be11 100644 --- a/src/librssguard/gui/dialogs/formmain.cpp +++ b/src/librssguard/gui/dialogs/formmain.cpp @@ -119,11 +119,10 @@ void FormMain::showDbCleanupAssistant() { qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel(); } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot cleanup database"), - tr("Cannot cleanup database, because another critical action is running."), - QSystemTrayIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot cleanup database"), + tr("Cannot cleanup database, because another critical action is running."), + QSystemTrayIcon::Warning }); } } @@ -464,10 +463,10 @@ void FormMain::switchVisibility(bool force_hide) { if (SystemTrayIcon::isSystemTrayDesired() && SystemTrayIcon::isSystemTrayAreaAvailable()) { if (QApplication::activeModalWidget() != nullptr) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - QSL(APP_LONG_NAME), - tr("Close opened modal dialogs first."), - QSystemTrayIcon::Warning, true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Close dialogs"), + tr("Close opened modal dialogs first."), + QSystemTrayIcon::Warning }); } else { hide(); diff --git a/src/librssguard/gui/dialogs/formupdate.cpp b/src/librssguard/gui/dialogs/formupdate.cpp index 7861d9b70..93c2f93a1 100644 --- a/src/librssguard/gui/dialogs/formupdate.cpp +++ b/src/librssguard/gui/dialogs/formupdate.cpp @@ -225,12 +225,11 @@ void FormUpdate::startUpdate() { if (exec_result <= HINSTANCE(32)) { qDebugNN << LOGSEC_GUI << "External updater was not launched due to error."; - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot update application"), - tr("Cannot launch external updater. Update application manually."), - QSystemTrayIcon::MessageIcon::Warning, - true, - this); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot update application"), + tr("Cannot launch external updater. Update application manually."), + QSystemTrayIcon::MessageIcon::Warning }, + {}, {}, this); } else { qApp->quit(); diff --git a/src/librssguard/gui/feedsview.cpp b/src/librssguard/gui/feedsview.cpp index cc506c014..264358081 100644 --- a/src/librssguard/gui/feedsview.cpp +++ b/src/librssguard/gui/feedsview.cpp @@ -169,11 +169,10 @@ void FeedsView::addFeedIntoSelectedAccount() { root->addNewFeed(selected, QGuiApplication::clipboard()->text(QClipboard::Mode::Clipboard)); } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Not supported"), - tr("Selected account does not support adding of new feeds."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Not supported by account"), + tr("Selected account does not support adding of new feeds."), + QSystemTrayIcon::MessageIcon::Warning }); } } } @@ -188,11 +187,10 @@ void FeedsView::addCategoryIntoSelectedAccount() { root->addNewCategory(selectedItem()); } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Not supported"), - tr("Selected account does not support adding of new categories."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Not supported by account"), + tr("Selected account does not support adding of new categories."), + QSystemTrayIcon::MessageIcon::Warning }); } } } @@ -252,11 +250,10 @@ void FeedsView::editSelectedItem() { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot edit item"), - tr("Selected item cannot be edited because another critical operation is ongoing."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot edit item"), + tr("Selected item cannot be edited because another critical operation is ongoing."), + QSystemTrayIcon::MessageIcon::Warning }); // Thus, cannot delete and quit the method. return; @@ -266,11 +263,10 @@ void FeedsView::editSelectedItem() { selectedItem()->editViaGui(); } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot edit item"), - tr("Selected item cannot be edited, this is not (yet?) supported."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot edit item"), + tr("Selected item cannot be edited, this is not (yet?) supported."), + QSystemTrayIcon::MessageIcon::Warning }); } // Changes are done, unlock the update master lock. @@ -282,11 +278,10 @@ void FeedsView::deleteSelectedItem() { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot delete item"), - tr("Selected item cannot be deleted because another critical operation is ongoing."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot delete item"), + tr("Selected item cannot be deleted because another critical operation is ongoing."), + QSystemTrayIcon::MessageIcon::Warning }); // Thus, cannot delete and quit the method. return; @@ -317,19 +312,17 @@ void FeedsView::deleteSelectedItem() { // We have deleteable item selected, remove it via GUI. if (!selected_item->deleteViaGui()) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot delete \"%1\"").arg(selected_item->title()), - tr("This item cannot be deleted because something critically failed. Submit bug report."), - QSystemTrayIcon::MessageIcon::Critical, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot delete \"%1\"").arg(selected_item->title()), + tr("This item cannot be deleted because something critically failed. Submit bug report."), + QSystemTrayIcon::MessageIcon::Critical }); } } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot delete \"%1\"").arg(selected_item->title()), - tr("This item cannot be deleted, because it does not support it\nor this functionality is not implemented yet."), - QSystemTrayIcon::MessageIcon::Critical, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot delete \"%1\"").arg(selected_item->title()), + tr("This item cannot be deleted, because it does not support it\nor this functionality is not implemented yet."), + QSystemTrayIcon::MessageIcon::Critical }); } } diff --git a/src/librssguard/gui/messagesview.cpp b/src/librssguard/gui/messagesview.cpp index 26ce4873b..f751ab7c7 100644 --- a/src/librssguard/gui/messagesview.cpp +++ b/src/librssguard/gui/messagesview.cpp @@ -723,10 +723,10 @@ void MessagesView::openSelectedMessagesWithExternalTool() { if (!link.isEmpty()) { if (!tool.run(link)) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot run external tool"), - tr("External tool '%1' could not be started.").arg(tool.executable()), - QSystemTrayIcon::MessageIcon::Critical); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot run external tool"), + tr("External tool '%1' could not be started.").arg(tool.executable()), + QSystemTrayIcon::MessageIcon::Critical }); } } } diff --git a/src/librssguard/gui/newspaperpreviewer.cpp b/src/librssguard/gui/newspaperpreviewer.cpp index c02b2d450..5a3b9cee8 100644 --- a/src/librssguard/gui/newspaperpreviewer.cpp +++ b/src/librssguard/gui/newspaperpreviewer.cpp @@ -47,10 +47,9 @@ void NewspaperPreviewer::showMoreMessages() { m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll); } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot show more articles"), - tr("Cannot show more articles because parent feed was removed."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot show more articles"), + tr("Cannot show more articles because parent feed was removed."), + QSystemTrayIcon::MessageIcon::Warning }); } } diff --git a/src/librssguard/gui/reusable/discoverfeedsbutton.cpp b/src/librssguard/gui/reusable/discoverfeedsbutton.cpp index 677555fb2..5f257c00e 100644 --- a/src/librssguard/gui/reusable/discoverfeedsbutton.cpp +++ b/src/librssguard/gui/reusable/discoverfeedsbutton.cpp @@ -51,11 +51,10 @@ void DiscoverFeedsButton::linkTriggered(QAction* action) { root->addNewFeed(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->selectedItem(), url); } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Not supported"), - tr("Given account does not support adding feeds."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Not supported by account"), + tr("Given account does not support adding feeds."), + QSystemTrayIcon::MessageIcon::Warning }); } } diff --git a/src/librssguard/gui/systemtrayicon.cpp b/src/librssguard/gui/systemtrayicon.cpp index 2dc30939b..6c5b8f67e 100644 --- a/src/librssguard/gui/systemtrayicon.cpp +++ b/src/librssguard/gui/systemtrayicon.cpp @@ -17,11 +17,10 @@ TrayIconMenu::TrayIconMenu(const QString& title, QWidget* parent) : QMenu(title, bool TrayIconMenu::event(QEvent* event) { if (event->type() == QEvent::Type::Show && Application::activeModalWidget() != nullptr) { QTimer::singleShot(0, this, &TrayIconMenu::hide); - qApp->showGuiMessage(Notification::Event::GeneralEvent, - QSL(APP_LONG_NAME), - tr("Close opened modal dialogs first."), - QSystemTrayIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Close dialogs"), + tr("Close opened modal dialogs first."), + QSystemTrayIcon::Warning }); } return QMenu::event(event); diff --git a/src/librssguard/gui/webviewer.cpp b/src/librssguard/gui/webviewer.cpp index 5fd5b329e..e0651103e 100644 --- a/src/librssguard/gui/webviewer.cpp +++ b/src/librssguard/gui/webviewer.cpp @@ -318,6 +318,10 @@ bool WebViewer::eventFilter(QObject* object, QEvent* event) { void WebViewer::onLinkHovered(const QString& url) { qDebugNN << LOGSEC_GUI << "Hovered link:" << QUOTE_W_SPACE_DOT(url); + qApp->showGuiMessage(Notification::Event::GeneralEvent, + { url, url, QSystemTrayIcon::MessageIcon::NoIcon }, + { false, false, true }); + QToolTip::showText(QCursor::pos(), url, {}, {}, 6000); } diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index 82ad2106c..8320b0b79 100644 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -199,28 +199,29 @@ void Application::loadDynamicShortcuts() { void Application::showPolls() const { if(isFirstRunCurrentVersion()) { - qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, - tr("RSS Guard has Discord server!"), - tr("You can visit it now! Click me!"), - QSystemTrayIcon::MessageIcon::Information, - true, - {}, - tr("Go to Discord!"), - [this]() { - web()->openUrlInExternalBrowser(QSL("https://discord.gg/7xbVMPPNqH")); - }); + qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, { + tr("RSS Guard has Discord server!"), + tr("You can visit it now! Click me!"), + QSystemTrayIcon::MessageIcon::Information }, + {}, { + tr("Go to Discord!"), + [this]() { + web()->openUrlInExternalBrowser(QSL("https://discord.gg/7xbVMPPNqH")); + } }); } } void Application::offerChanges() const { if (isFirstRunCurrentVersion()) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - QSL(APP_NAME), - QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n" - "version by clicking this popup notification.").arg(QSL(APP_LONG_NAME)), - QSystemTrayIcon::MessageIcon::NoIcon, {}, {}, tr("Go to changelog"), [] { - FormAbout(qApp->mainForm()).exec(); - }); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Welcome"), + tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n" + "version by clicking this popup notification.").arg(QSL(APP_LONG_NAME)), + QSystemTrayIcon::MessageIcon::NoIcon }, + {}, + { tr("Go to changelog"), [] { + FormAbout(qApp->mainForm()).exec(); + } }); } } @@ -489,11 +490,13 @@ void Application::deleteTrayIcon() { } } -void Application::showGuiMessage(Notification::Event event, const QString& title, - const QString& message, QSystemTrayIcon::MessageIcon message_type, bool show_at_least_msgbox, - QWidget* parent, const QString& functor_heading, std::function functor) { +void Application::showGuiMessage(Notification::Event event, + const GuiMessage& msg, + const GuiMessageDestination& dest, + const GuiAction& action, + QWidget* parent) { - if (SystemTrayIcon::areNotificationsEnabled()) { + if (SystemTrayIcon::areNotificationsEnabled() && dest.m_tray) { auto notification = m_notifications->notificationForEvent(event); notification.playSound(this); @@ -501,19 +504,23 @@ void Application::showGuiMessage(Notification::Event event, const QString& title if (SystemTrayIcon::isSystemTrayDesired() && SystemTrayIcon::isSystemTrayAreaAvailable() && notification.balloonEnabled()) { - trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, std::move(functor)); - + trayIcon()->showMessage(msg.m_title, msg.m_message, msg.m_type, TRAY_ICON_BUBBLE_TIMEOUT, std::move(action.m_action)); return; } } - if (show_at_least_msgbox) { + if (dest.m_messageBox) { // Tray icon or OSD is not available, display simple text box. - MessageBox::show(parent == nullptr ? mainFormWidget() : parent, QMessageBox::Icon(message_type), title, message, - {}, {}, QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok, {}, functor_heading, functor); + MessageBox::show(parent == nullptr ? mainFormWidget() : parent, + QMessageBox::Icon(msg.m_type), msg.m_title, msg.m_message, + {}, {}, QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok, {}, + action.m_title, action.m_action); + } + else if (dest.m_statusBar && mainForm()->statusBar() != nullptr && mainForm()->statusBar()->isVisible()) { + mainForm()->statusBar()->showMessage(msg.m_message); } else { - qDebugNN << LOGSEC_CORE << "Silencing GUI message:" << QUOTE_W_SPACE_DOT(message); + qDebugNN << LOGSEC_CORE << "Silencing GUI message:" << QUOTE_W_SPACE_DOT(msg.m_message); } } @@ -622,16 +629,15 @@ void Application::downloadRequested(QWebEngineDownloadItem* download_item) { } void Application::onAdBlockFailure() { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("AdBlock needs to be configured"), - tr("AdBlock component is not configured properly."), - QSystemTrayIcon::MessageIcon::Critical, - true, - {}, - tr("Configure now"), - [=]() { - m_webFactory->adBlock()->showDialog(); - }); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("AdBlock needs to be configured"), + tr("AdBlock component is not configured properly."), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Configure now"), + [=]() { + m_webFactory->adBlock()->showDialog(); + } }); qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled, false); } @@ -641,10 +647,10 @@ void Application::onAdBlockFailure() { void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) { if (!results.updatedFeeds().isEmpty()) { // Now, inform about results via GUI message/notification. - qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched, - tr("Unread articles fetched"), - results.overview(10), - QSystemTrayIcon::MessageIcon::NoIcon); + qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched, { + tr("Unread articles fetched"), + results.overview(10), + QSystemTrayIcon::MessageIcon::NoIcon }); } } @@ -711,10 +717,10 @@ void Application::parseCmdArgumentsFromOtherInstance(const QString& message) { return; } else if (cmd_parser.isSet(QSL(CLI_IS_RUNNING))) { - showGuiMessage(Notification::Event::GeneralEvent, - QSL(APP_NAME), - tr("Application is already running."), - QSystemTrayIcon::MessageIcon::Information); + showGuiMessage(Notification::Event::GeneralEvent, { + tr("Already running"), + tr("Application is already running."), + QSystemTrayIcon::MessageIcon::Information }); mainForm()->display(); } @@ -730,11 +736,10 @@ void Application::parseCmdArgumentsFromOtherInstance(const QString& message) { rt->addNewFeed(nullptr, msg); } else { - showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot add feed"), - tr("Feed cannot be added because there is no active account which can add feeds."), - QSystemTrayIcon::MessageIcon::Warning, - true); + showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot add feed"), + tr("Feed cannot be added because there is no active account which can add feeds."), + QSystemTrayIcon::MessageIcon::Warning }); } } } diff --git a/src/librssguard/miscellaneous/application.h b/src/librssguard/miscellaneous/application.h index 958c295d0..535e690ba 100644 --- a/src/librssguard/miscellaneous/application.h +++ b/src/librssguard/miscellaneous/application.h @@ -43,6 +43,35 @@ class QWebEngineDownloadItem; class WebFactory; class NotificationFactory; +struct GuiMessage { + public: + GuiMessage(QString title, QString message, QSystemTrayIcon::MessageIcon type) + : m_title(std::move(title)), m_message(std::move(message)), m_type(type) {} + + QString m_title; + QString m_message; + QSystemTrayIcon::MessageIcon m_type; +}; + +struct GuiMessageDestination { + public: + GuiMessageDestination(bool tray = true, bool message_box = true, bool status_bar = false) + : m_tray(tray), m_messageBox(message_box), m_statusBar(status_bar) {} + + bool m_tray; + bool m_messageBox; + bool m_statusBar; +}; + +struct GuiAction { + public: + GuiAction(QString title = {}, const std::function& action = nullptr) + : m_title(std::move(title)), m_action(action) {} + + QString m_title; + std::function m_action; +}; + class RSSGUARD_DLLSPEC Application : public SingleApplication { Q_OBJECT @@ -119,10 +148,11 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication { // Displays given simple message in tray icon bubble or OSD // or in message box if tray icon is disabled. - void showGuiMessage(Notification::Event event, const QString& title, const QString& message, - QSystemTrayIcon::MessageIcon message_type, bool show_at_least_msgbox = false, - QWidget* parent = nullptr, const QString& functor_heading = {}, - std::function functor = nullptr); + void showGuiMessage(Notification::Event event, + const GuiMessage& msg, + const GuiMessageDestination& dest = {}, + const GuiAction& action = {}, + QWidget* parent = nullptr); // Returns pointer to "GOD" application singleton. static Application* instance(); diff --git a/src/librssguard/miscellaneous/feedreader.cpp b/src/librssguard/miscellaneous/feedreader.cpp index e947d93d2..cad1a441a 100644 --- a/src/librssguard/miscellaneous/feedreader.cpp +++ b/src/librssguard/miscellaneous/feedreader.cpp @@ -69,11 +69,10 @@ QList FeedReader::feedServices() { void FeedReader::updateFeeds(const QList& feeds) { if (!qApp->feedUpdateLock()->tryLock()) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot fetch articles at this point"), - tr("You cannot fetch new articles now because another critical operation is ongoing."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot fetch articles at this point"), + tr("You cannot fetch new articles now because another critical operation is ongoing."), + QSystemTrayIcon::MessageIcon::Warning }); return; } @@ -315,10 +314,10 @@ void FeedReader::executeNextAutoUpdate() { updateFeeds(feeds_for_update); // NOTE: OSD/bubble informing about performing of scheduled update can be shown now. - qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted, - tr("Starting auto-download of some feeds' articles"), - tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()), - QSystemTrayIcon::MessageIcon::Information); + qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted, { + tr("Starting auto-download of some feeds' articles"), + tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()), + QSystemTrayIcon::MessageIcon::Information }); } } diff --git a/src/librssguard/miscellaneous/systemfactory.cpp b/src/librssguard/miscellaneous/systemfactory.cpp index 078aac7e1..6f4598a77 100644 --- a/src/librssguard/miscellaneous/systemfactory.cpp +++ b/src/librssguard/miscellaneous/systemfactory.cpp @@ -211,14 +211,14 @@ void SystemFactory::checkForUpdatesOnStartup() { if (!updates.first.isEmpty() && updates.second == QNetworkReply::NetworkError::NoError && SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, QSL(APP_VERSION))) { - qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, - QObject::tr("New version available"), - QObject::tr("Click the bubble for more information."), - QSystemTrayIcon::Information, {}, {}, - tr("See new version info"), - [] { - FormUpdate(qApp->mainForm()).exec(); - }); + qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, { + QObject::tr("New version available"), + QObject::tr("Click the bubble for more information."), + QSystemTrayIcon::Information }, {}, { + tr("See new version info"), + [] { + FormUpdate(qApp->mainForm()).exec(); + } }); } }); qApp->system()->checkForUpdates(); diff --git a/src/librssguard/network-web/downloadmanager.cpp b/src/librssguard/network-web/downloadmanager.cpp index 21d1cc922..347716af6 100644 --- a/src/librssguard/network-web/downloadmanager.cpp +++ b/src/librssguard/network-web/downloadmanager.cpp @@ -194,11 +194,10 @@ void DownloadItem::stop() { void DownloadItem::openFile() { if (!QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()))) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot open file"), - tr("Cannot open output file. Open it manually."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot open file"), + tr("Cannot open output file. Open it manually."), + QSystemTrayIcon::MessageIcon::Warning }); } } @@ -415,17 +414,16 @@ void DownloadItem::finished() { emit downloadFinished(); if (downloadedSuccessfully()) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Download finished"), - tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators( - m_output.fileName())), - QSystemTrayIcon::MessageIcon::Information, - {}, - {}, - tr("Open folder"), - [this] { - openFolder(); - }); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Download finished"), + tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators( + m_output.fileName())), + QSystemTrayIcon::MessageIcon::Information }, + {}, { + tr("Open folder"), + [this] { + openFolder(); + } }); } } diff --git a/src/librssguard/network-web/oauth2service.cpp b/src/librssguard/network-web/oauth2service.cpp index 5258def4f..3f9c1ce29 100644 --- a/src/librssguard/network-web/oauth2service.cpp +++ b/src/librssguard/network-web/oauth2service.cpp @@ -80,15 +80,15 @@ OAuth2Service::~OAuth2Service() { QString OAuth2Service::bearer() { if (!isFullyLoggedIn()) { - qApp->showGuiMessage(Notification::Event::LoginFailure, - tr("You have to login first"), - tr("Click here to login."), - QSystemTrayIcon::MessageIcon::Critical, - {}, {}, - tr("Login"), - [this]() { - login(); - }); + qApp->showGuiMessage(Notification::Event::LoginFailure, { + tr("You have to login first"), + tr("Click here to login."), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Login"), + [this]() { + login(); + } }); return {}; } else { @@ -189,10 +189,10 @@ void OAuth2Service::refreshAccessToken(const QString& refresh_token) { real_refresh_token, QSL("refresh_token")); - qApp->showGuiMessage(Notification::Event::LoginDataRefreshed, - tr("Logging in via OAuth 2.0..."), - tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()), - QSystemTrayIcon::MessageIcon::Information); + qApp->showGuiMessage(Notification::Event::LoginDataRefreshed, { + tr("Logging in via OAuth 2.0..."), + tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()), + QSystemTrayIcon::MessageIcon::Information }); qDebugNN << LOGSEC_OAUTH << "Posting data for access token refreshing:" << QUOTE_W_SPACE_DOT(content); m_networkManager.post(networkRequest, content.toUtf8()); diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.cpp b/src/librssguard/services/abstract/gui/formfeeddetails.cpp index eaf2678d0..731adf219 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.cpp +++ b/src/librssguard/services/abstract/gui/formfeeddetails.cpp @@ -98,11 +98,11 @@ void FormFeedDetails::acceptIfPossible() { accept(); } catch (const ApplicationException& ex) { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Error"), - tr("Cannot save changes: %1").arg(ex.message()), - QSystemTrayIcon::MessageIcon::Critical, - true, + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot save feed properties"), + tr("Cannot save changes: %1").arg(ex.message()), + QSystemTrayIcon::MessageIcon::Critical }, + {}, {}, this); } } diff --git a/src/librssguard/services/abstract/labelsnode.cpp b/src/librssguard/services/abstract/labelsnode.cpp index 30d52c508..bf04bc12a 100644 --- a/src/librssguard/services/abstract/labelsnode.cpp +++ b/src/librssguard/services/abstract/labelsnode.cpp @@ -67,10 +67,9 @@ void LabelsNode::createLabel() { } } else { - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("This account does not allow you to create labels."), - tr("Not allowed"), - QSystemTrayIcon::MessageIcon::Critical, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("This account does not allow you to create labels."), + tr("Not allowed"), + QSystemTrayIcon::MessageIcon::Critical }); } } diff --git a/src/librssguard/services/feedly/feedlynetwork.cpp b/src/librssguard/services/feedly/feedlynetwork.cpp index 54104aea4..f8b2e95a6 100644 --- a/src/librssguard/services/feedly/feedlynetwork.cpp +++ b/src/librssguard/services/feedly/feedlynetwork.cpp @@ -508,32 +508,32 @@ void FeedlyNetwork::setBatchSize(int batch_size) { void FeedlyNetwork::onTokensError(const QString& error, const QString& error_description) { Q_UNUSED(error) - qApp->showGuiMessage(Notification::Event::LoginFailure, - tr("Feedly: authentication error"), - tr("Click this to login again. Error is: '%1'").arg(error_description), - QSystemTrayIcon::MessageIcon::Critical, - {}, {}, - tr("Login"), - [this]() { - m_oauth->setAccessToken(QString()); - m_oauth->setRefreshToken(QString()); + qApp->showGuiMessage(Notification::Event::LoginFailure, { + tr("Feedly: authentication error"), + tr("Click this to login again. Error is: '%1'").arg(error_description), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Login"), + [this]() { + m_oauth->setAccessToken(QString()); + m_oauth->setRefreshToken(QString()); - //m_oauth->logout(false); - m_oauth->login(); - }); + //m_oauth->logout(false); + m_oauth->login(); + } }); } void FeedlyNetwork::onAuthFailed() { - qApp->showGuiMessage(Notification::Event::LoginFailure, - tr("Feedly: authorization denied"), - tr("Click this to login again."), - QSystemTrayIcon::MessageIcon::Critical, - {}, {}, - tr("Login"), - [this]() { - //m_oauth->logout(false); - m_oauth->login(); - }); + qApp->showGuiMessage(Notification::Event::LoginFailure, { + tr("Feedly: authorization denied"), + tr("Click this to login again."), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Login"), + [this]() { + //m_oauth->logout(false); + m_oauth->login(); + } }); } void FeedlyNetwork::onTokensRetrieved(const QString& access_token, const QString& refresh_token, int expires_in) { diff --git a/src/librssguard/services/gmail/gmailnetworkfactory.cpp b/src/librssguard/services/gmail/gmailnetworkfactory.cpp index df5d64114..8aefcf374 100644 --- a/src/librssguard/services/gmail/gmailnetworkfactory.cpp +++ b/src/librssguard/services/gmail/gmailnetworkfactory.cpp @@ -420,29 +420,29 @@ QVariantHash GmailNetworkFactory::getProfile(const QNetworkProxy& custom_proxy) void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) { Q_UNUSED(error) - qApp->showGuiMessage(Notification::Event::LoginFailure, - tr("Gmail: authentication error"), - tr("Click this to login again. Error is: '%1'").arg(error_description), - QSystemTrayIcon::MessageIcon::Critical, - {}, {}, - tr("Login"), - [this]() { - m_oauth2->setAccessToken(QString()); - m_oauth2->setRefreshToken(QString()); - m_oauth2->login(); - }); + qApp->showGuiMessage(Notification::Event::LoginFailure, { + tr("Gmail: authentication error"), + tr("Click this to login again. Error is: '%1'").arg(error_description), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Login"), + [this]() { + m_oauth2->setAccessToken(QString()); + m_oauth2->setRefreshToken(QString()); + m_oauth2->login(); + } }); } void GmailNetworkFactory::onAuthFailed() { - qApp->showGuiMessage(Notification::Event::LoginFailure, - tr("Gmail: authorization denied"), - tr("Click this to login again."), - QSystemTrayIcon::MessageIcon::Critical, - {}, {}, - tr("Login"), - [this]() { - m_oauth2->login(); - }); + qApp->showGuiMessage(Notification::Event::LoginFailure, { + tr("Gmail: authorization denied"), + tr("Click this to login again."), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Login"), + [this]() { + m_oauth2->login(); + } }); } bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json, const QString& feed_id) { diff --git a/src/librssguard/services/greader/greadernetwork.cpp b/src/librssguard/services/greader/greadernetwork.cpp index 6a8984337..4ee1dab67 100644 --- a/src/librssguard/services/greader/greadernetwork.cpp +++ b/src/librssguard/services/greader/greadernetwork.cpp @@ -1096,29 +1096,29 @@ QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) co void GreaderNetwork::onTokensError(const QString& error, const QString& error_description) { Q_UNUSED(error) - qApp->showGuiMessage(Notification::Event::LoginFailure, - tr("Inoreader: authentication error"), - tr("Click this to login again. Error is: '%1'").arg(error_description), - QSystemTrayIcon::MessageIcon::Critical, - {}, {}, - tr("Login"), - [this]() { - m_oauth->setAccessToken(QString()); - m_oauth->setRefreshToken(QString()); - m_oauth->login(); - }); + qApp->showGuiMessage(Notification::Event::LoginFailure, { + tr("Inoreader: authentication error"), + tr("Click this to login again. Error is: '%1'").arg(error_description), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Login"), + [this]() { + m_oauth->setAccessToken(QString()); + m_oauth->setRefreshToken(QString()); + m_oauth->login(); + } }); } void GreaderNetwork::onAuthFailed() { - qApp->showGuiMessage(Notification::Event::LoginFailure, - tr("Inoreader: authorization denied"), - tr("Click this to login again."), - QSystemTrayIcon::MessageIcon::Critical, - {}, {}, - tr("Login"), - [this]() { - m_oauth->login(); - }); + qApp->showGuiMessage(Notification::Event::LoginFailure, { + tr("Inoreader: authorization denied"), + tr("Click this to login again."), + QSystemTrayIcon::MessageIcon::Critical }, + {}, { + tr("Login"), + [this]() { + m_oauth->login(); + } }); } void GreaderNetwork::initializeOauth() { diff --git a/src/librssguard/services/standard/standardcategory.cpp b/src/librssguard/services/standard/standardcategory.cpp index bbe71de14..e16bcba84 100644 --- a/src/librssguard/services/standard/standardcategory.cpp +++ b/src/librssguard/services/standard/standardcategory.cpp @@ -39,11 +39,10 @@ bool StandardCategory::performDragDropChange(RootItem* target_item) { qCriticalNN << LOGSEC_DB << "Cannot overwrite category:" << QUOTE_W_SPACE_DOT(ex.message()); - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Error"), - tr("Cannot save data for category, detailed information was logged via debug log."), - QSystemTrayIcon::MessageIcon::Critical, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Error"), + tr("Cannot save data for category, detailed information was logged via debug log."), + QSystemTrayIcon::MessageIcon::Critical }); return false; } } diff --git a/src/librssguard/services/standard/standardfeed.cpp b/src/librssguard/services/standard/standardfeed.cpp index f400a7dbc..ec11f39ef 100644 --- a/src/librssguard/services/standard/standardfeed.cpp +++ b/src/librssguard/services/standard/standardfeed.cpp @@ -206,11 +206,10 @@ void StandardFeed::fetchMetadataForItself() { qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message()); - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Error"), - tr("Cannot save data for feed: %1").arg(ex.message()), - QSystemTrayIcon::MessageIcon::Critical, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Error"), + tr("Cannot save data for feed: %1").arg(ex.message()), + QSystemTrayIcon::MessageIcon::Critical }); } } @@ -473,11 +472,11 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) { qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message()); - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Error"), - tr("Cannot move feed, detailed information was logged via debug log."), - QSystemTrayIcon::MessageIcon::Critical, - true); + + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot move feed"), + tr("Cannot move feed, detailed information was logged via debug log."), + QSystemTrayIcon::MessageIcon::Critical }); return false; } } diff --git a/src/librssguard/services/standard/standardserviceroot.cpp b/src/librssguard/services/standard/standardserviceroot.cpp index 7a9eea869..c51c32d75 100644 --- a/src/librssguard/services/standard/standardserviceroot.cpp +++ b/src/librssguard/services/standard/standardserviceroot.cpp @@ -122,11 +122,10 @@ void StandardServiceRoot::addNewFeed(RootItem* selected_item, const QString& url // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot add item"), - tr("Cannot add feed because another critical operation is ongoing."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot add item"), + tr("Cannot add feed because another critical operation is ongoing."), + QSystemTrayIcon::MessageIcon::Warning }); return; } @@ -394,11 +393,10 @@ void StandardServiceRoot::addNewCategory(RootItem* selected_item) { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot add category"), - tr("Cannot add category because another critical operation is ongoing."), - QSystemTrayIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot add category"), + tr("Cannot add category because another critical operation is ongoing."), + QSystemTrayIcon::Warning }); // Thus, cannot delete and quit the method. return; diff --git a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp index 1032429c6..28ec35b13 100644 --- a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp +++ b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp @@ -44,10 +44,10 @@ void FormTtRssFeedDetails::apply() { if (response.code() == STF_INSERTED) { // Feed was added online. - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Feed added"), - tr("Feed was added, obtaining new tree of feeds now."), - QSystemTrayIcon::MessageIcon::Information); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Feed added"), + tr("Feed was added, obtaining new tree of feeds now."), + QSystemTrayIcon::MessageIcon::Information }); QTimer::singleShot(300, root, &TtRssServiceRoot::syncIn); } else { diff --git a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp index e8b2907e2..fd60e63ff 100644 --- a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp +++ b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp @@ -85,11 +85,10 @@ void TtRssServiceRoot::addNewFeed(RootItem* selected_item, const QString& url) { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(Notification::Event::GeneralEvent, - tr("Cannot add item"), - tr("Cannot add feed because another critical operation is ongoing."), - QSystemTrayIcon::MessageIcon::Warning, - true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, { + tr("Cannot add item"), + tr("Cannot add feed because another critical operation is ongoing."), + QSystemTrayIcon::MessageIcon::Warning }); return; }