From 50e1d79c42ffc282d0273b47e252f3f736ccf040 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 18 Jun 2021 13:42:31 +0200 Subject: [PATCH] work on notifications --- .../desktop/com.github.rssguard.appdata.xml | 2 +- src/librssguard/core/feedsmodel.cpp | 4 +- src/librssguard/core/messagesmodel.cpp | 4 +- src/librssguard/gui/dialogs/formmain.cpp | 11 +++-- src/librssguard/gui/dialogs/formupdate.cpp | 7 ++- src/librssguard/gui/feedsview.cpp | 34 +++++++------ src/librssguard/gui/messagesview.cpp | 3 +- src/librssguard/gui/newspaperpreviewer.cpp | 4 +- .../gui/reusable/discoverfeedsbutton.cpp | 5 +- .../gui/settings/settingsnotifications.ui | 2 +- src/librssguard/gui/systemtrayicon.cpp | 6 ++- src/librssguard/miscellaneous/application.cpp | 49 +++++++++++++------ src/librssguard/miscellaneous/application.h | 7 +-- src/librssguard/miscellaneous/feedreader.cpp | 11 +++-- .../miscellaneous/notification.cpp | 4 +- src/librssguard/miscellaneous/notification.h | 7 ++- .../miscellaneous/systemfactory.cpp | 5 +- .../network-web/adblock/adblockmanager.cpp | 5 +- .../network-web/downloadmanager.cpp | 14 ++++-- src/librssguard/network-web/oauth2service.cpp | 8 +-- .../services/abstract/gui/formfeeddetails.cpp | 7 +-- .../services/abstract/labelsnode.cpp | 4 +- .../services/gmail/gmailnetworkfactory.cpp | 10 ++-- .../inoreader/inoreadernetworkfactory.cpp | 10 ++-- .../services/standard/standardcategory.cpp | 4 +- .../services/standard/standardfeed.cpp | 8 +-- .../services/standard/standardserviceroot.cpp | 12 +++-- .../tt-rss/gui/formttrssfeeddetails.cpp | 3 +- .../services/tt-rss/ttrssserviceroot.cpp | 4 +- 29 files changed, 157 insertions(+), 97 deletions(-) diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml index 5c511a7be..6afb82793 100644 --- a/resources/desktop/com.github.rssguard.appdata.xml +++ b/resources/desktop/com.github.rssguard.appdata.xml @@ -30,7 +30,7 @@ https://martinrotter.github.io/donate/ - + none diff --git a/src/librssguard/core/feedsmodel.cpp b/src/librssguard/core/feedsmodel.cpp index 874eb493a..243296c9a 100644 --- a/src/librssguard/core/feedsmodel.cpp +++ b/src/librssguard/core/feedsmodel.cpp @@ -117,10 +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(tr("Cannot perform drag & drop operation"), + 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, - qApp->mainFormWidget(), true); qDebugNN << LOGSEC_FEEDMODEL << "Dragged item cannot be dragged into different account. Cancelling drag-drop action."; diff --git a/src/librssguard/core/messagesmodel.cpp b/src/librssguard/core/messagesmodel.cpp index 78bbfe58b..e246b3ee0 100644 --- a/src/librssguard/core/messagesmodel.cpp +++ b/src/librssguard/core/messagesmodel.cpp @@ -137,10 +137,10 @@ void MessagesModel::loadMessages(RootItem* item) { qCriticalNN << LOGSEC_MESSAGEMODEL << "Loading of messages from item '" << item->title() << "' failed."; - qApp->showGuiMessage(tr("Loading of messages from item '%1' failed.").arg(item->title()), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Loading of messages from item '%1' failed.").arg(item->title()), tr("Loading of messages failed, maybe messages could not be downloaded."), QSystemTrayIcon::MessageIcon::Critical, - qApp->mainFormWidget(), true); } } diff --git a/src/librssguard/gui/dialogs/formmain.cpp b/src/librssguard/gui/dialogs/formmain.cpp index aba121722..d681097e6 100755 --- a/src/librssguard/gui/dialogs/formmain.cpp +++ b/src/librssguard/gui/dialogs/formmain.cpp @@ -119,9 +119,11 @@ void FormMain::showDbCleanupAssistant() { qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel(); } else { - qApp->showGuiMessage(tr("Cannot cleanup database"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot cleanup database"), tr("Cannot cleanup database, because another critical action is running."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::Warning, + true); } } @@ -465,9 +467,10 @@ void FormMain::switchVisibility(bool force_hide) { if (SystemTrayIcon::isSystemTrayDesired() && SystemTrayIcon::isSystemTrayAreaAvailable()) { if (QApplication::activeModalWidget() != nullptr) { - qApp->showGuiMessage(QSL(APP_LONG_NAME), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + QSL(APP_LONG_NAME), tr("Close opened modal dialogs first."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::Warning, true); } else { hide(); diff --git a/src/librssguard/gui/dialogs/formupdate.cpp b/src/librssguard/gui/dialogs/formupdate.cpp index 5fb91a345..9e1a8787e 100644 --- a/src/librssguard/gui/dialogs/formupdate.cpp +++ b/src/librssguard/gui/dialogs/formupdate.cpp @@ -220,9 +220,12 @@ void FormUpdate::startUpdate() { if (exec_result <= HINSTANCE(32)) { qDebugNN << LOGSEC_GUI << "External updater was not launched due to error."; - qApp->showGuiMessage(tr("Cannot update application"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot update application"), tr("Cannot launch external updater. Update application manually."), - QSystemTrayIcon::MessageIcon::Warning, this); + QSystemTrayIcon::MessageIcon::Warning, + true, + this); } else { qApp->quit(); diff --git a/src/librssguard/gui/feedsview.cpp b/src/librssguard/gui/feedsview.cpp index 3a76164d1..b77a049c6 100755 --- a/src/librssguard/gui/feedsview.cpp +++ b/src/librssguard/gui/feedsview.cpp @@ -165,10 +165,11 @@ void FeedsView::addFeedIntoSelectedAccount() { root->addNewFeed(selected, QGuiApplication::clipboard()->text(QClipboard::Mode::Clipboard)); } else { - qApp->showGuiMessage(tr("Not supported"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Not supported"), tr("Selected account does not support adding of new feeds."), QSystemTrayIcon::MessageIcon::Warning, - qApp->mainFormWidget(), true); + true); } } } @@ -183,10 +184,11 @@ void FeedsView::addCategoryIntoSelectedAccount() { root->addNewCategory(selectedItem()); } else { - qApp->showGuiMessage(tr("Not supported"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Not supported"), tr("Selected account does not support adding of new categories."), QSystemTrayIcon::MessageIcon::Warning, - qApp->mainFormWidget(), true); + true); } } } @@ -246,9 +248,11 @@ void FeedsView::editSelectedItem() { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(tr("Cannot edit item"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot edit item"), tr("Selected item cannot be edited because another critical operation is ongoing."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::MessageIcon::Warning, + true); // Thus, cannot delete and quit the method. return; @@ -258,10 +262,10 @@ void FeedsView::editSelectedItem() { selectedItem()->editViaGui(); } else { - qApp->showGuiMessage(tr("Cannot edit item"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot edit item"), tr("Selected item cannot be edited, this is not (yet?) supported."), QSystemTrayIcon::MessageIcon::Warning, - qApp->mainFormWidget(), true); } @@ -274,9 +278,11 @@ void FeedsView::deleteSelectedItem() { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(tr("Cannot delete item"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot delete item"), tr("Selected item cannot be deleted because another critical operation is ongoing."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::MessageIcon::Warning, + true); // Thus, cannot delete and quit the method. return; @@ -307,18 +313,18 @@ void FeedsView::deleteSelectedItem() { // We have deleteable item selected, remove it via GUI. if (!selected_item->deleteViaGui()) { - qApp->showGuiMessage(tr("Cannot delete \"%1\"").arg(selected_item->title()), + 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, - qApp->mainFormWidget(), true); } } else { - qApp->showGuiMessage(tr("Cannot delete \"%1\"").arg(selected_item->title()), + 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, - qApp->mainFormWidget(), true); } } diff --git a/src/librssguard/gui/messagesview.cpp b/src/librssguard/gui/messagesview.cpp index 4d79a7bf9..939be4427 100644 --- a/src/librssguard/gui/messagesview.cpp +++ b/src/librssguard/gui/messagesview.cpp @@ -617,7 +617,8 @@ void MessagesView::openSelectedMessagesWithExternalTool() { if (!link.isEmpty()) { if (!tool.run(link)) { - qApp->showGuiMessage(tr("Cannot run external tool"), + 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 b20490d1c..c02b2d450 100644 --- a/src/librssguard/gui/newspaperpreviewer.cpp +++ b/src/librssguard/gui/newspaperpreviewer.cpp @@ -47,10 +47,10 @@ void NewspaperPreviewer::showMoreMessages() { m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll); } else { - qApp->showGuiMessage(tr("Cannot show more articles"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot show more articles"), tr("Cannot show more articles because parent feed was removed."), QSystemTrayIcon::MessageIcon::Warning, - qApp->mainForm(), true); } } diff --git a/src/librssguard/gui/reusable/discoverfeedsbutton.cpp b/src/librssguard/gui/reusable/discoverfeedsbutton.cpp index 3ec1a0e91..677555fb2 100755 --- a/src/librssguard/gui/reusable/discoverfeedsbutton.cpp +++ b/src/librssguard/gui/reusable/discoverfeedsbutton.cpp @@ -51,10 +51,11 @@ void DiscoverFeedsButton::linkTriggered(QAction* action) { root->addNewFeed(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->selectedItem(), url); } else { - qApp->showGuiMessage(tr("Not supported"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Not supported"), tr("Given account does not support adding feeds."), QSystemTrayIcon::MessageIcon::Warning, - qApp->mainFormWidget(), true); + true); } } diff --git a/src/librssguard/gui/settings/settingsnotifications.ui b/src/librssguard/gui/settings/settingsnotifications.ui index a8894275e..554bdf1b3 100755 --- a/src/librssguard/gui/settings/settingsnotifications.ui +++ b/src/librssguard/gui/settings/settingsnotifications.ui @@ -52,7 +52,7 @@ - You must have "tray icon" activated to have notifications working. + You must have "tray icon" activated to have balloon notifications working. diff --git a/src/librssguard/gui/systemtrayicon.cpp b/src/librssguard/gui/systemtrayicon.cpp index 038f09a79..f321ae0ea 100644 --- a/src/librssguard/gui/systemtrayicon.cpp +++ b/src/librssguard/gui/systemtrayicon.cpp @@ -17,9 +17,11 @@ 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(QSL(APP_LONG_NAME), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + QSL(APP_LONG_NAME), tr("Close opened modal dialogs first."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::Warning, + true); } return QMenu::event(event); diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index e93e956ed..32f10f4ae 100755 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -172,9 +172,11 @@ void Application::showPolls() const { void Application::offerChanges() const { if (isFirstRunCurrentVersion()) { - qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n" - "version by clicking this popup notification.").arg(APP_LONG_NAME), - QSystemTrayIcon::MessageIcon::NoIcon, nullptr, false, [] { + 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(APP_LONG_NAME), + QSystemTrayIcon::MessageIcon::NoIcon, {}, {}, [] { FormAbout(qApp->mainForm()).exec(); }); } @@ -432,15 +434,25 @@ void Application::deleteTrayIcon() { } } -void Application::showGuiMessage(const QString& title, const QString& message, - QSystemTrayIcon::MessageIcon message_type, QWidget* parent, - bool show_at_least_msgbox, std::function functor) { - if (SystemTrayIcon::areNotificationsEnabled() && - SystemTrayIcon::isSystemTrayDesired() && - SystemTrayIcon::isSystemTrayAreaAvailable()) { - trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, std::move(functor)); +void Application::showGuiMessage(Notification::Event event, const QString& title, + const QString& message, QSystemTrayIcon::MessageIcon message_type, bool show_at_least_msgbox, + QWidget* parent, std::function functor) { + + if (SystemTrayIcon::areNotificationsEnabled()) { + auto notification = m_notifications->notificationForEvent(event); + + notification.playSound(this); + + if (SystemTrayIcon::isSystemTrayDesired() && + SystemTrayIcon::isSystemTrayAreaAvailable() && + notification.balloonEnabled()) { + trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, std::move(functor)); + + return; + } } - else if (show_at_least_msgbox) { + + if (show_at_least_msgbox) { // Tray icon or OSD is not available, display simple text box. MessageBox::show(parent == nullptr ? mainFormWidget() : parent, QMessageBox::Icon(message_type), title, message); } @@ -534,8 +546,10 @@ void Application::downloadRequested(QWebEngineDownloadItem* download_item) { void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) { if (!results.updatedFeeds().isEmpty()) { // Now, inform about results via GUI message/notification. - qApp->showGuiMessage(tr("New messages downloaded"), results.overview(10), QSystemTrayIcon::MessageIcon::NoIcon, - nullptr, false); + qApp->showGuiMessage(Notification::Event::NewArticlesFetched, + tr("New articles fetched"), + results.overview(10), + QSystemTrayIcon::MessageIcon::NoIcon); } } @@ -602,7 +616,10 @@ void Application::parseCmdArgumentsFromOtherInstance(const QString& message) { return; } else if (cmd_parser.isSet(CLI_IS_RUNNING)) { - showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::MessageIcon::Information); + showGuiMessage(Notification::Event::GeneralEvent, + APP_NAME, + tr("Application is already running."), + QSystemTrayIcon::MessageIcon::Information); mainForm()->display(); } @@ -618,10 +635,10 @@ void Application::parseCmdArgumentsFromOtherInstance(const QString& message) { rt->addNewFeed(nullptr, msg); } else { - showGuiMessage(tr("Cannot add feed"), + 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, - qApp->mainForm(), true); } } diff --git a/src/librssguard/miscellaneous/application.h b/src/librssguard/miscellaneous/application.h index 4832d78f8..67af83abe 100755 --- a/src/librssguard/miscellaneous/application.h +++ b/src/librssguard/miscellaneous/application.h @@ -10,6 +10,7 @@ #include "miscellaneous/feedreader.h" #include "miscellaneous/iofactory.h" #include "miscellaneous/localization.h" +#include "miscellaneous/notification.h" #include "miscellaneous/settings.h" #include "miscellaneous/singleapplication.h" #include "miscellaneous/skinfactory.h" @@ -110,9 +111,9 @@ 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(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon message_type, - QWidget* parent = nullptr, bool show_at_least_msgbox = false, - std::function functor = nullptr); + void showGuiMessage(Notification::Event event, const QString& title, const QString& message, + QSystemTrayIcon::MessageIcon message_type, bool show_at_least_msgbox = false, + QWidget* parent = nullptr, std::function functor = 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 afd5d61d7..f64b1a849 100644 --- a/src/librssguard/miscellaneous/feedreader.cpp +++ b/src/librssguard/miscellaneous/feedreader.cpp @@ -70,10 +70,12 @@ QList FeedReader::feedServices() { void FeedReader::updateFeeds(const QList& feeds) { if (!qApp->feedUpdateLock()->tryLock()) { - qApp->showGuiMessage(tr("Cannot update all items"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot update all items"), tr("You cannot download new messages for your items " "because another critical operation is ongoing."), - QSystemTrayIcon::MessageIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::MessageIcon::Warning, + true); return; } @@ -315,8 +317,9 @@ void FeedReader::executeNextAutoUpdate() { // NOTE: OSD/bubble informing about performing of scheduled update can be shown now. if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::EnableAutoUpdateNotification)).toBool()) { - qApp->showGuiMessage(tr("Starting auto-download of some feeds' messages"), - tr("I will auto-download new messages for %n feed(s).", nullptr, feeds_for_update.size()), + 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/notification.cpp b/src/librssguard/miscellaneous/notification.cpp index 37d1a1d59..17477b011 100755 --- a/src/librssguard/miscellaneous/notification.cpp +++ b/src/librssguard/miscellaneous/notification.cpp @@ -27,7 +27,9 @@ void Notification::setSoundPath(const QString& sound_path) { } void Notification::playSound(Application* app) const { - QSound::play(QDir::toNativeSeparators(app->replaceDataUserDataFolderPlaceholder(m_soundPath))); + if (!m_soundPath.isEmpty()) { + QSound::play(QDir::toNativeSeparators(app->replaceDataUserDataFolderPlaceholder(m_soundPath))); + } } QList Notification::allEvents() { diff --git a/src/librssguard/miscellaneous/notification.h b/src/librssguard/miscellaneous/notification.h index 6a5c73b34..6e06ced11 100755 --- a/src/librssguard/miscellaneous/notification.h +++ b/src/librssguard/miscellaneous/notification.h @@ -14,11 +14,14 @@ class Notification { // not trigger any notifications. NoEvent = 0, + // Used for many events which happen throught application lifecycle. + GeneralEvent = 1, + // New (unread) messages were downloaded for some feed. - NewArticlesFetched = 1, + NewArticlesFetched = 2, // RSS Guard started downloading messages for some feed. - ArticlesFetchingStarted = 2, + ArticlesFetchingStarted = 3, // Login tokens were successfuly refreshed. // NOTE: This is primarily used in accounts which use diff --git a/src/librssguard/miscellaneous/systemfactory.cpp b/src/librssguard/miscellaneous/systemfactory.cpp index f6d6cb61a..844024f0f 100644 --- a/src/librssguard/miscellaneous/systemfactory.cpp +++ b/src/librssguard/miscellaneous/systemfactory.cpp @@ -226,9 +226,10 @@ void SystemFactory::checkForUpdatesOnStartup() { if (!updates.first.isEmpty() && updates.second == QNetworkReply::NetworkError::NoError && SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) { - qApp->showGuiMessage(QObject::tr("New version available"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + QObject::tr("New version available"), QObject::tr("Click the bubble for more information."), - QSystemTrayIcon::Information, qApp->mainForm(), false, + QSystemTrayIcon::Information, {}, {}, [] { FormUpdate(qApp->mainForm()).exec(); }); diff --git a/src/librssguard/network-web/adblock/adblockmanager.cpp b/src/librssguard/network-web/adblock/adblockmanager.cpp index e6d6fc8d6..d785646d0 100644 --- a/src/librssguard/network-web/adblock/adblockmanager.cpp +++ b/src/librssguard/network-web/adblock/adblockmanager.cpp @@ -118,11 +118,12 @@ void AdBlockManager::load(bool initial_load) { << "Failed to write unified filters to file or re-start server, error:" << QUOTE_W_SPACE_DOT(ex.message()); - qApp->showGuiMessage(tr("AdBlock needs to be configured"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("AdBlock needs to be configured"), tr("AdBlock component is not configured properly."), QSystemTrayIcon::MessageIcon::Warning, - nullptr, true, + {}, [=]() { showDialog(); }); diff --git a/src/librssguard/network-web/downloadmanager.cpp b/src/librssguard/network-web/downloadmanager.cpp index f90adf352..b079db197 100644 --- a/src/librssguard/network-web/downloadmanager.cpp +++ b/src/librssguard/network-web/downloadmanager.cpp @@ -194,8 +194,11 @@ void DownloadItem::stop() { void DownloadItem::openFile() { if (!QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()))) { - qApp->showGuiMessage(tr("Cannot open file"), tr("Cannot open output file. Open it manually."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot open file"), + tr("Cannot open output file. Open it manually."), + QSystemTrayIcon::MessageIcon::Warning, + true); } } @@ -410,12 +413,13 @@ void DownloadItem::finished() { emit downloadFinished(); if (downloadedSuccessfully()) { - qApp->showGuiMessage(tr("Download finished"), + 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, - nullptr, - false, + {}, + {}, [this] { openFolder(); }); diff --git a/src/librssguard/network-web/oauth2service.cpp b/src/librssguard/network-web/oauth2service.cpp index 7cb0d4335..26243e831 100644 --- a/src/librssguard/network-web/oauth2service.cpp +++ b/src/librssguard/network-web/oauth2service.cpp @@ -81,10 +81,11 @@ OAuth2Service::~OAuth2Service() { QString OAuth2Service::bearer() { if (!isFullyLoggedIn()) { - qApp->showGuiMessage(tr("You have to login first"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("You have to login first"), tr("Click here to login."), QSystemTrayIcon::MessageIcon::Critical, - nullptr, false, + {}, {}, [this]() { login(); }); @@ -188,7 +189,8 @@ void OAuth2Service::refreshAccessToken(const QString& refresh_token) { real_refresh_token, QSL("refresh_token")); - qApp->showGuiMessage(tr("Logging in via OAuth 2.0..."), + 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); diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.cpp b/src/librssguard/services/abstract/gui/formfeeddetails.cpp index 75d2aafc0..7bdc8d21f 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.cpp +++ b/src/librssguard/services/abstract/gui/formfeeddetails.cpp @@ -94,11 +94,12 @@ void FormFeedDetails::acceptIfPossible() { accept(); } catch (const ApplicationException& ex) { - qApp->showGuiMessage(tr("Error"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Error"), tr("Cannot save changes: %1").arg(ex.message()), QSystemTrayIcon::MessageIcon::Critical, - this, - true); + true, + this); } } diff --git a/src/librssguard/services/abstract/labelsnode.cpp b/src/librssguard/services/abstract/labelsnode.cpp index 0828fc8be..30d52c508 100755 --- a/src/librssguard/services/abstract/labelsnode.cpp +++ b/src/librssguard/services/abstract/labelsnode.cpp @@ -67,10 +67,10 @@ void LabelsNode::createLabel() { } } else { - qApp->showGuiMessage(tr("This account does not allow you to create labels."), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("This account does not allow you to create labels."), tr("Not allowed"), QSystemTrayIcon::MessageIcon::Critical, - qApp->mainFormWidget(), true); } } diff --git a/src/librssguard/services/gmail/gmailnetworkfactory.cpp b/src/librssguard/services/gmail/gmailnetworkfactory.cpp index bf22723b0..d9faf9835 100755 --- a/src/librssguard/services/gmail/gmailnetworkfactory.cpp +++ b/src/librssguard/services/gmail/gmailnetworkfactory.cpp @@ -419,10 +419,11 @@ QVariantHash GmailNetworkFactory::getProfile(const QNetworkProxy& custom_proxy) void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) { Q_UNUSED(error) - qApp->showGuiMessage(tr("Gmail: authentication error"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Gmail: authentication error"), tr("Click this to login again. Error is: '%1'").arg(error_description), QSystemTrayIcon::MessageIcon::Critical, - nullptr, false, + {}, {}, [this]() { m_oauth2->setAccessToken(QString()); m_oauth2->setRefreshToken(QString()); @@ -431,10 +432,11 @@ void GmailNetworkFactory::onTokensError(const QString& error, const QString& err } void GmailNetworkFactory::onAuthFailed() { - qApp->showGuiMessage(tr("Gmail: authorization denied"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Gmail: authorization denied"), tr("Click this to login again."), QSystemTrayIcon::MessageIcon::Critical, - nullptr, false, + {}, {}, [this]() { m_oauth2->login(); }); diff --git a/src/librssguard/services/inoreader/inoreadernetworkfactory.cpp b/src/librssguard/services/inoreader/inoreadernetworkfactory.cpp index 1418ad6c8..94d942b23 100755 --- a/src/librssguard/services/inoreader/inoreadernetworkfactory.cpp +++ b/src/librssguard/services/inoreader/inoreadernetworkfactory.cpp @@ -324,10 +324,11 @@ QNetworkReply::NetworkError InoreaderNetworkFactory::markMessagesStarred(RootIte void InoreaderNetworkFactory::onTokensError(const QString& error, const QString& error_description) { Q_UNUSED(error) - qApp->showGuiMessage(tr("Inoreader: authentication error"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Inoreader: authentication error"), tr("Click this to login again. Error is: '%1'").arg(error_description), QSystemTrayIcon::MessageIcon::Critical, - nullptr, false, + {}, {}, [this]() { m_oauth2->setAccessToken(QString()); m_oauth2->setRefreshToken(QString()); @@ -336,10 +337,11 @@ void InoreaderNetworkFactory::onTokensError(const QString& error, const QString& } void InoreaderNetworkFactory::onAuthFailed() { - qApp->showGuiMessage(tr("Inoreader: authorization denied"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Inoreader: authorization denied"), tr("Click this to login again."), QSystemTrayIcon::MessageIcon::Critical, - nullptr, false, + {}, {}, [this]() { m_oauth2->login(); }); diff --git a/src/librssguard/services/standard/standardcategory.cpp b/src/librssguard/services/standard/standardcategory.cpp index bb60c1ede..8b0f55501 100644 --- a/src/librssguard/services/standard/standardcategory.cpp +++ b/src/librssguard/services/standard/standardcategory.cpp @@ -39,10 +39,10 @@ bool StandardCategory::performDragDropChange(RootItem* target_item) { qCriticalNN << LOGSEC_DB << "Cannot overwrite category:" << QUOTE_W_SPACE_DOT(ex.message()); - qApp->showGuiMessage(tr("Error"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Error"), tr("Cannot save data for category, detailed information was logged via debug log."), QSystemTrayIcon::MessageIcon::Critical, - nullptr, true); return false; } diff --git a/src/librssguard/services/standard/standardfeed.cpp b/src/librssguard/services/standard/standardfeed.cpp index 7f89b8337..70f5f1b30 100644 --- a/src/librssguard/services/standard/standardfeed.cpp +++ b/src/librssguard/services/standard/standardfeed.cpp @@ -211,10 +211,10 @@ void StandardFeed::fetchMetadataForItself() { qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message()); - qApp->showGuiMessage(tr("Error"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Error"), tr("Cannot save data for feed: %1").arg(ex.message()), QSystemTrayIcon::MessageIcon::Critical, - nullptr, true); } } @@ -476,10 +476,10 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) { qCriticalNN << LOGSEC_DB << "Cannot overwrite feed:" << QUOTE_W_SPACE_DOT(ex.message()); - qApp->showGuiMessage(tr("Error"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Error"), tr("Cannot move feed, detailed information was logged via debug log."), QSystemTrayIcon::MessageIcon::Critical, - nullptr, true); return false; } diff --git a/src/librssguard/services/standard/standardserviceroot.cpp b/src/librssguard/services/standard/standardserviceroot.cpp index 887f64fad..7b4c60cf3 100644 --- a/src/librssguard/services/standard/standardserviceroot.cpp +++ b/src/librssguard/services/standard/standardserviceroot.cpp @@ -121,9 +121,11 @@ 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(tr("Cannot add item"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot add item"), tr("Cannot add feed because another critical operation is ongoing."), - QSystemTrayIcon::MessageIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::MessageIcon::Warning, + true); return; } @@ -396,9 +398,11 @@ void StandardServiceRoot::addNewCategory(RootItem* selected_item) { // Lock was not obtained because // it is used probably by feed updater or application // is quitting. - qApp->showGuiMessage(tr("Cannot add category"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot add category"), tr("Cannot add category because another critical operation is ongoing."), - QSystemTrayIcon::Warning, qApp->mainFormWidget(), true); + QSystemTrayIcon::Warning, + true); // 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 d636d0dd5..1032429c6 100755 --- a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp +++ b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp @@ -44,7 +44,8 @@ void FormTtRssFeedDetails::apply() { if (response.code() == STF_INSERTED) { // Feed was added online. - qApp->showGuiMessage(tr("Feed added"), + 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); diff --git a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp index a4bf238c3..97b826217 100644 --- a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp +++ b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp @@ -84,10 +84,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(tr("Cannot add item"), + qApp->showGuiMessage(Notification::Event::GeneralEvent, + tr("Cannot add item"), tr("Cannot add feed because another critical operation is ongoing."), QSystemTrayIcon::MessageIcon::Warning, - qApp->mainFormWidget(), true); return;