implement temporary status bar messages

This commit is contained in:
Martin Rotter 2021-11-01 13:59:21 +01:00
parent f6dd3f88e7
commit 00dee012f1
26 changed files with 301 additions and 285 deletions

View File

@ -117,11 +117,10 @@ bool FeedsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int
if (dragged_item_root != target_item_root) { if (dragged_item_root != target_item_root) {
// Transferring of items between different accounts is not possible. // Transferring of items between different accounts is not possible.
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot perform drag & drop operation"), tr("Cannot perform drag & drop operation"),
tr("You can't transfer dragged item into different account, this is not supported."), tr("You can't transfer dragged item into different account, this is not supported."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
qDebugNN << LOGSEC_FEEDMODEL qDebugNN << LOGSEC_FEEDMODEL
<< "Dragged item cannot be dragged into different account. Cancelling drag-drop action."; << "Dragged item cannot be dragged into different account. Cancelling drag-drop action.";
return false; return false;

View File

@ -142,11 +142,10 @@ void MessagesModel::loadMessages(RootItem* item) {
qCriticalNN << LOGSEC_MESSAGEMODEL qCriticalNN << LOGSEC_MESSAGEMODEL
<< "Loading of messages from item '" << "Loading of messages from item '"
<< item->title() << "' failed."; << item->title() << "' failed.";
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Loading of articles from item '%1' failed.").arg(item->title()), tr("Loading of articles from item '%1' failed").arg(item->title()),
tr("Loading of articles failed, maybe messages could not be downloaded."), tr("Loading of articles failed, maybe messages could not be downloaded."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical });
true);
} }
} }

View File

@ -119,11 +119,10 @@ void FormMain::showDbCleanupAssistant() {
qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel(); qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel();
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot cleanup database"), tr("Cannot cleanup database"),
tr("Cannot cleanup database, because another critical action is running."), tr("Cannot cleanup database, because another critical action is running."),
QSystemTrayIcon::Warning, QSystemTrayIcon::Warning });
true);
} }
} }
@ -464,10 +463,10 @@ void FormMain::switchVisibility(bool force_hide) {
if (SystemTrayIcon::isSystemTrayDesired() && SystemTrayIcon::isSystemTrayAreaAvailable()) { if (SystemTrayIcon::isSystemTrayDesired() && SystemTrayIcon::isSystemTrayAreaAvailable()) {
if (QApplication::activeModalWidget() != nullptr) { if (QApplication::activeModalWidget() != nullptr) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
QSL(APP_LONG_NAME), tr("Close dialogs"),
tr("Close opened modal dialogs first."), tr("Close opened modal dialogs first."),
QSystemTrayIcon::Warning, true); QSystemTrayIcon::Warning });
} }
else { else {
hide(); hide();

View File

@ -225,12 +225,11 @@ void FormUpdate::startUpdate() {
if (exec_result <= HINSTANCE(32)) { if (exec_result <= HINSTANCE(32)) {
qDebugNN << LOGSEC_GUI << "External updater was not launched due to error."; qDebugNN << LOGSEC_GUI << "External updater was not launched due to error.";
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot update application"), tr("Cannot update application"),
tr("Cannot launch external updater. Update application manually."), tr("Cannot launch external updater. Update application manually."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning },
true, {}, {}, this);
this);
} }
else { else {
qApp->quit(); qApp->quit();

View File

@ -169,11 +169,10 @@ void FeedsView::addFeedIntoSelectedAccount() {
root->addNewFeed(selected, QGuiApplication::clipboard()->text(QClipboard::Mode::Clipboard)); root->addNewFeed(selected, QGuiApplication::clipboard()->text(QClipboard::Mode::Clipboard));
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Not supported"), tr("Not supported by account"),
tr("Selected account does not support adding of new feeds."), tr("Selected account does not support adding of new feeds."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
} }
} }
} }
@ -188,11 +187,10 @@ void FeedsView::addCategoryIntoSelectedAccount() {
root->addNewCategory(selectedItem()); root->addNewCategory(selectedItem());
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Not supported"), tr("Not supported by account"),
tr("Selected account does not support adding of new categories."), tr("Selected account does not support adding of new categories."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
} }
} }
} }
@ -252,11 +250,10 @@ void FeedsView::editSelectedItem() {
// Lock was not obtained because // Lock was not obtained because
// it is used probably by feed updater or application // it is used probably by feed updater or application
// is quitting. // is quitting.
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot edit item"), tr("Cannot edit item"),
tr("Selected item cannot be edited because another critical operation is ongoing."), tr("Selected item cannot be edited because another critical operation is ongoing."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
// Thus, cannot delete and quit the method. // Thus, cannot delete and quit the method.
return; return;
@ -266,11 +263,10 @@ void FeedsView::editSelectedItem() {
selectedItem()->editViaGui(); selectedItem()->editViaGui();
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot edit item"), tr("Cannot edit item"),
tr("Selected item cannot be edited, this is not (yet?) supported."), tr("Selected item cannot be edited, this is not (yet?) supported."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
} }
// Changes are done, unlock the update master lock. // Changes are done, unlock the update master lock.
@ -282,11 +278,10 @@ void FeedsView::deleteSelectedItem() {
// Lock was not obtained because // Lock was not obtained because
// it is used probably by feed updater or application // it is used probably by feed updater or application
// is quitting. // is quitting.
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot delete item"), tr("Cannot delete item"),
tr("Selected item cannot be deleted because another critical operation is ongoing."), tr("Selected item cannot be deleted because another critical operation is ongoing."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
// Thus, cannot delete and quit the method. // Thus, cannot delete and quit the method.
return; return;
@ -317,19 +312,17 @@ void FeedsView::deleteSelectedItem() {
// We have deleteable item selected, remove it via GUI. // We have deleteable item selected, remove it via GUI.
if (!selected_item->deleteViaGui()) { if (!selected_item->deleteViaGui()) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot delete \"%1\"").arg(selected_item->title()), tr("Cannot delete \"%1\"").arg(selected_item->title()),
tr("This item cannot be deleted because something critically failed. Submit bug report."), tr("This item cannot be deleted because something critically failed. Submit bug report."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical });
true);
} }
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot delete \"%1\"").arg(selected_item->title()), 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."), tr("This item cannot be deleted, because it does not support it\nor this functionality is not implemented yet."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical });
true);
} }
} }

View File

@ -723,10 +723,10 @@ void MessagesView::openSelectedMessagesWithExternalTool() {
if (!link.isEmpty()) { if (!link.isEmpty()) {
if (!tool.run(link)) { if (!tool.run(link)) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot run external tool"), tr("Cannot run external tool"),
tr("External tool '%1' could not be started.").arg(tool.executable()), tr("External tool '%1' could not be started.").arg(tool.executable()),
QSystemTrayIcon::MessageIcon::Critical); QSystemTrayIcon::MessageIcon::Critical });
} }
} }
} }

View File

@ -47,10 +47,9 @@ void NewspaperPreviewer::showMoreMessages() {
m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll); m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll);
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot show more articles"), tr("Cannot show more articles"),
tr("Cannot show more articles because parent feed was removed."), tr("Cannot show more articles because parent feed was removed."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
} }
} }

View File

@ -51,11 +51,10 @@ void DiscoverFeedsButton::linkTriggered(QAction* action) {
root->addNewFeed(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->selectedItem(), url); root->addNewFeed(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->selectedItem(), url);
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Not supported"), tr("Not supported by account"),
tr("Given account does not support adding feeds."), tr("Given account does not support adding feeds."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
} }
} }

View File

@ -17,11 +17,10 @@ TrayIconMenu::TrayIconMenu(const QString& title, QWidget* parent) : QMenu(title,
bool TrayIconMenu::event(QEvent* event) { bool TrayIconMenu::event(QEvent* event) {
if (event->type() == QEvent::Type::Show && Application::activeModalWidget() != nullptr) { if (event->type() == QEvent::Type::Show && Application::activeModalWidget() != nullptr) {
QTimer::singleShot(0, this, &TrayIconMenu::hide); QTimer::singleShot(0, this, &TrayIconMenu::hide);
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
QSL(APP_LONG_NAME), tr("Close dialogs"),
tr("Close opened modal dialogs first."), tr("Close opened modal dialogs first."),
QSystemTrayIcon::Warning, QSystemTrayIcon::Warning });
true);
} }
return QMenu::event(event); return QMenu::event(event);

View File

@ -318,6 +318,10 @@ bool WebViewer::eventFilter(QObject* object, QEvent* event) {
void WebViewer::onLinkHovered(const QString& url) { void WebViewer::onLinkHovered(const QString& url) {
qDebugNN << LOGSEC_GUI << "Hovered link:" << QUOTE_W_SPACE_DOT(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); QToolTip::showText(QCursor::pos(), url, {}, {}, 6000);
} }

View File

@ -199,28 +199,29 @@ void Application::loadDynamicShortcuts() {
void Application::showPolls() const { void Application::showPolls() const {
if(isFirstRunCurrentVersion()) { if(isFirstRunCurrentVersion()) {
qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, {
tr("RSS Guard has Discord server!"), tr("RSS Guard has Discord server!"),
tr("You can visit it now! Click me!"), tr("You can visit it now! Click me!"),
QSystemTrayIcon::MessageIcon::Information, QSystemTrayIcon::MessageIcon::Information },
true, {}, {
{}, tr("Go to Discord!"),
tr("Go to Discord!"), [this]() {
[this]() { web()->openUrlInExternalBrowser(QSL("https://discord.gg/7xbVMPPNqH"));
web()->openUrlInExternalBrowser(QSL("https://discord.gg/7xbVMPPNqH")); } });
});
} }
} }
void Application::offerChanges() const { void Application::offerChanges() const {
if (isFirstRunCurrentVersion()) { if (isFirstRunCurrentVersion()) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
QSL(APP_NAME), tr("Welcome"),
QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n" tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n"
"version by clicking this popup notification.").arg(QSL(APP_LONG_NAME)), "version by clicking this popup notification.").arg(QSL(APP_LONG_NAME)),
QSystemTrayIcon::MessageIcon::NoIcon, {}, {}, tr("Go to changelog"), [] { QSystemTrayIcon::MessageIcon::NoIcon },
FormAbout(qApp->mainForm()).exec(); {},
}); { tr("Go to changelog"), [] {
FormAbout(qApp->mainForm()).exec();
} });
} }
} }
@ -489,11 +490,13 @@ void Application::deleteTrayIcon() {
} }
} }
void Application::showGuiMessage(Notification::Event event, const QString& title, void Application::showGuiMessage(Notification::Event event,
const QString& message, QSystemTrayIcon::MessageIcon message_type, bool show_at_least_msgbox, const GuiMessage& msg,
QWidget* parent, const QString& functor_heading, std::function<void()> functor) { const GuiMessageDestination& dest,
const GuiAction& action,
QWidget* parent) {
if (SystemTrayIcon::areNotificationsEnabled()) { if (SystemTrayIcon::areNotificationsEnabled() && dest.m_tray) {
auto notification = m_notifications->notificationForEvent(event); auto notification = m_notifications->notificationForEvent(event);
notification.playSound(this); notification.playSound(this);
@ -501,19 +504,23 @@ void Application::showGuiMessage(Notification::Event event, const QString& title
if (SystemTrayIcon::isSystemTrayDesired() && if (SystemTrayIcon::isSystemTrayDesired() &&
SystemTrayIcon::isSystemTrayAreaAvailable() && SystemTrayIcon::isSystemTrayAreaAvailable() &&
notification.balloonEnabled()) { 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; return;
} }
} }
if (show_at_least_msgbox) { if (dest.m_messageBox) {
// Tray icon or OSD is not available, display simple text box. // Tray icon or OSD is not available, display simple text box.
MessageBox::show(parent == nullptr ? mainFormWidget() : parent, QMessageBox::Icon(message_type), title, message, MessageBox::show(parent == nullptr ? mainFormWidget() : parent,
{}, {}, QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok, {}, functor_heading, functor); 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 { 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() { void Application::onAdBlockFailure() {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("AdBlock needs to be configured"), tr("AdBlock needs to be configured"),
tr("AdBlock component is not configured properly."), tr("AdBlock component is not configured properly."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
true, {}, {
{}, tr("Configure now"),
tr("Configure now"), [=]() {
[=]() { m_webFactory->adBlock()->showDialog();
m_webFactory->adBlock()->showDialog(); } });
});
qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled, false); qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled, false);
} }
@ -641,10 +647,10 @@ void Application::onAdBlockFailure() {
void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) { void Application::onFeedUpdatesFinished(const FeedDownloadResults& results) {
if (!results.updatedFeeds().isEmpty()) { if (!results.updatedFeeds().isEmpty()) {
// Now, inform about results via GUI message/notification. // Now, inform about results via GUI message/notification.
qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched, qApp->showGuiMessage(Notification::Event::NewUnreadArticlesFetched, {
tr("Unread articles fetched"), tr("Unread articles fetched"),
results.overview(10), results.overview(10),
QSystemTrayIcon::MessageIcon::NoIcon); QSystemTrayIcon::MessageIcon::NoIcon });
} }
} }
@ -711,10 +717,10 @@ void Application::parseCmdArgumentsFromOtherInstance(const QString& message) {
return; return;
} }
else if (cmd_parser.isSet(QSL(CLI_IS_RUNNING))) { else if (cmd_parser.isSet(QSL(CLI_IS_RUNNING))) {
showGuiMessage(Notification::Event::GeneralEvent, showGuiMessage(Notification::Event::GeneralEvent, {
QSL(APP_NAME), tr("Already running"),
tr("Application is already running."), tr("Application is already running."),
QSystemTrayIcon::MessageIcon::Information); QSystemTrayIcon::MessageIcon::Information });
mainForm()->display(); mainForm()->display();
} }
@ -730,11 +736,10 @@ void Application::parseCmdArgumentsFromOtherInstance(const QString& message) {
rt->addNewFeed(nullptr, msg); rt->addNewFeed(nullptr, msg);
} }
else { else {
showGuiMessage(Notification::Event::GeneralEvent, showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot add feed"), tr("Cannot add feed"),
tr("Feed cannot be added because there is no active account which can add feeds."), tr("Feed cannot be added because there is no active account which can add feeds."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
} }
} }
} }

View File

@ -43,6 +43,35 @@ class QWebEngineDownloadItem;
class WebFactory; class WebFactory;
class NotificationFactory; 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<void()>& action = nullptr)
: m_title(std::move(title)), m_action(action) {}
QString m_title;
std::function<void()> m_action;
};
class RSSGUARD_DLLSPEC Application : public SingleApplication { class RSSGUARD_DLLSPEC Application : public SingleApplication {
Q_OBJECT Q_OBJECT
@ -119,10 +148,11 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
// Displays given simple message in tray icon bubble or OSD // Displays given simple message in tray icon bubble or OSD
// or in message box if tray icon is disabled. // or in message box if tray icon is disabled.
void showGuiMessage(Notification::Event event, const QString& title, const QString& message, void showGuiMessage(Notification::Event event,
QSystemTrayIcon::MessageIcon message_type, bool show_at_least_msgbox = false, const GuiMessage& msg,
QWidget* parent = nullptr, const QString& functor_heading = {}, const GuiMessageDestination& dest = {},
std::function<void()> functor = nullptr); const GuiAction& action = {},
QWidget* parent = nullptr);
// Returns pointer to "GOD" application singleton. // Returns pointer to "GOD" application singleton.
static Application* instance(); static Application* instance();

View File

@ -69,11 +69,10 @@ QList<ServiceEntryPoint*> FeedReader::feedServices() {
void FeedReader::updateFeeds(const QList<Feed*>& feeds) { void FeedReader::updateFeeds(const QList<Feed*>& feeds) {
if (!qApp->feedUpdateLock()->tryLock()) { if (!qApp->feedUpdateLock()->tryLock()) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot fetch articles at this point"), tr("Cannot fetch articles at this point"),
tr("You cannot fetch new articles now because another critical operation is ongoing."), tr("You cannot fetch new articles now because another critical operation is ongoing."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
return; return;
} }
@ -315,10 +314,10 @@ void FeedReader::executeNextAutoUpdate() {
updateFeeds(feeds_for_update); updateFeeds(feeds_for_update);
// NOTE: OSD/bubble informing about performing of scheduled update can be shown now. // NOTE: OSD/bubble informing about performing of scheduled update can be shown now.
qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted, qApp->showGuiMessage(Notification::Event::ArticlesFetchingStarted, {
tr("Starting auto-download of some feeds' articles"), tr("Starting auto-download of some feeds' articles"),
tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()), tr("I will auto-download new articles for %n feed(s).", nullptr, feeds_for_update.size()),
QSystemTrayIcon::MessageIcon::Information); QSystemTrayIcon::MessageIcon::Information });
} }
} }

View File

@ -211,14 +211,14 @@ void SystemFactory::checkForUpdatesOnStartup() {
if (!updates.first.isEmpty() && if (!updates.first.isEmpty() &&
updates.second == QNetworkReply::NetworkError::NoError && updates.second == QNetworkReply::NetworkError::NoError &&
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, QSL(APP_VERSION))) { SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, QSL(APP_VERSION))) {
qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable, {
QObject::tr("New version available"), QObject::tr("New version available"),
QObject::tr("Click the bubble for more information."), QObject::tr("Click the bubble for more information."),
QSystemTrayIcon::Information, {}, {}, QSystemTrayIcon::Information }, {}, {
tr("See new version info"), tr("See new version info"),
[] { [] {
FormUpdate(qApp->mainForm()).exec(); FormUpdate(qApp->mainForm()).exec();
}); } });
} }
}); });
qApp->system()->checkForUpdates(); qApp->system()->checkForUpdates();

View File

@ -194,11 +194,10 @@ void DownloadItem::stop() {
void DownloadItem::openFile() { void DownloadItem::openFile() {
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()))) { if (!QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()))) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot open file"), tr("Cannot open file"),
tr("Cannot open output file. Open it manually."), tr("Cannot open output file. Open it manually."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
} }
} }
@ -415,17 +414,16 @@ void DownloadItem::finished() {
emit downloadFinished(); emit downloadFinished();
if (downloadedSuccessfully()) { if (downloadedSuccessfully()) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Download finished"), tr("Download finished"),
tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators( tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators(
m_output.fileName())), m_output.fileName())),
QSystemTrayIcon::MessageIcon::Information, QSystemTrayIcon::MessageIcon::Information },
{}, {}, {
{}, tr("Open folder"),
tr("Open folder"), [this] {
[this] { openFolder();
openFolder(); } });
});
} }
} }

View File

@ -80,15 +80,15 @@ OAuth2Service::~OAuth2Service() {
QString OAuth2Service::bearer() { QString OAuth2Service::bearer() {
if (!isFullyLoggedIn()) { if (!isFullyLoggedIn()) {
qApp->showGuiMessage(Notification::Event::LoginFailure, qApp->showGuiMessage(Notification::Event::LoginFailure, {
tr("You have to login first"), tr("You have to login first"),
tr("Click here to login."), tr("Click here to login."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
{}, {}, {}, {
tr("Login"), tr("Login"),
[this]() { [this]() {
login(); login();
}); } });
return {}; return {};
} }
else { else {
@ -189,10 +189,10 @@ void OAuth2Service::refreshAccessToken(const QString& refresh_token) {
real_refresh_token, real_refresh_token,
QSL("refresh_token")); QSL("refresh_token"));
qApp->showGuiMessage(Notification::Event::LoginDataRefreshed, qApp->showGuiMessage(Notification::Event::LoginDataRefreshed, {
tr("Logging in via OAuth 2.0..."), tr("Logging in via OAuth 2.0..."),
tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()), tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()),
QSystemTrayIcon::MessageIcon::Information); QSystemTrayIcon::MessageIcon::Information });
qDebugNN << LOGSEC_OAUTH << "Posting data for access token refreshing:" << QUOTE_W_SPACE_DOT(content); qDebugNN << LOGSEC_OAUTH << "Posting data for access token refreshing:" << QUOTE_W_SPACE_DOT(content);
m_networkManager.post(networkRequest, content.toUtf8()); m_networkManager.post(networkRequest, content.toUtf8());

View File

@ -98,11 +98,11 @@ void FormFeedDetails::acceptIfPossible() {
accept(); accept();
} }
catch (const ApplicationException& ex) { catch (const ApplicationException& ex) {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Error"), tr("Cannot save feed properties"),
tr("Cannot save changes: %1").arg(ex.message()), tr("Cannot save changes: %1").arg(ex.message()),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
true, {}, {},
this); this);
} }
} }

View File

@ -67,10 +67,9 @@ void LabelsNode::createLabel() {
} }
} }
else { else {
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("This account does not allow you to create labels."), tr("This account does not allow you to create labels."),
tr("Not allowed"), tr("Not allowed"),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical });
true);
} }
} }

View File

@ -508,32 +508,32 @@ void FeedlyNetwork::setBatchSize(int batch_size) {
void FeedlyNetwork::onTokensError(const QString& error, const QString& error_description) { void FeedlyNetwork::onTokensError(const QString& error, const QString& error_description) {
Q_UNUSED(error) Q_UNUSED(error)
qApp->showGuiMessage(Notification::Event::LoginFailure, qApp->showGuiMessage(Notification::Event::LoginFailure, {
tr("Feedly: authentication error"), tr("Feedly: authentication error"),
tr("Click this to login again. Error is: '%1'").arg(error_description), tr("Click this to login again. Error is: '%1'").arg(error_description),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
{}, {}, {}, {
tr("Login"), tr("Login"),
[this]() { [this]() {
m_oauth->setAccessToken(QString()); m_oauth->setAccessToken(QString());
m_oauth->setRefreshToken(QString()); m_oauth->setRefreshToken(QString());
//m_oauth->logout(false); //m_oauth->logout(false);
m_oauth->login(); m_oauth->login();
}); } });
} }
void FeedlyNetwork::onAuthFailed() { void FeedlyNetwork::onAuthFailed() {
qApp->showGuiMessage(Notification::Event::LoginFailure, qApp->showGuiMessage(Notification::Event::LoginFailure, {
tr("Feedly: authorization denied"), tr("Feedly: authorization denied"),
tr("Click this to login again."), tr("Click this to login again."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
{}, {}, {}, {
tr("Login"), tr("Login"),
[this]() { [this]() {
//m_oauth->logout(false); //m_oauth->logout(false);
m_oauth->login(); m_oauth->login();
}); } });
} }
void FeedlyNetwork::onTokensRetrieved(const QString& access_token, const QString& refresh_token, int expires_in) { void FeedlyNetwork::onTokensRetrieved(const QString& access_token, const QString& refresh_token, int expires_in) {

View File

@ -420,29 +420,29 @@ QVariantHash GmailNetworkFactory::getProfile(const QNetworkProxy& custom_proxy)
void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) { void GmailNetworkFactory::onTokensError(const QString& error, const QString& error_description) {
Q_UNUSED(error) Q_UNUSED(error)
qApp->showGuiMessage(Notification::Event::LoginFailure, qApp->showGuiMessage(Notification::Event::LoginFailure, {
tr("Gmail: authentication error"), tr("Gmail: authentication error"),
tr("Click this to login again. Error is: '%1'").arg(error_description), tr("Click this to login again. Error is: '%1'").arg(error_description),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
{}, {}, {}, {
tr("Login"), tr("Login"),
[this]() { [this]() {
m_oauth2->setAccessToken(QString()); m_oauth2->setAccessToken(QString());
m_oauth2->setRefreshToken(QString()); m_oauth2->setRefreshToken(QString());
m_oauth2->login(); m_oauth2->login();
}); } });
} }
void GmailNetworkFactory::onAuthFailed() { void GmailNetworkFactory::onAuthFailed() {
qApp->showGuiMessage(Notification::Event::LoginFailure, qApp->showGuiMessage(Notification::Event::LoginFailure, {
tr("Gmail: authorization denied"), tr("Gmail: authorization denied"),
tr("Click this to login again."), tr("Click this to login again."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
{}, {}, {}, {
tr("Login"), tr("Login"),
[this]() { [this]() {
m_oauth2->login(); m_oauth2->login();
}); } });
} }
bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json, const QString& feed_id) { bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json, const QString& feed_id) {

View File

@ -1096,29 +1096,29 @@ QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) co
void GreaderNetwork::onTokensError(const QString& error, const QString& error_description) { void GreaderNetwork::onTokensError(const QString& error, const QString& error_description) {
Q_UNUSED(error) Q_UNUSED(error)
qApp->showGuiMessage(Notification::Event::LoginFailure, qApp->showGuiMessage(Notification::Event::LoginFailure, {
tr("Inoreader: authentication error"), tr("Inoreader: authentication error"),
tr("Click this to login again. Error is: '%1'").arg(error_description), tr("Click this to login again. Error is: '%1'").arg(error_description),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
{}, {}, {}, {
tr("Login"), tr("Login"),
[this]() { [this]() {
m_oauth->setAccessToken(QString()); m_oauth->setAccessToken(QString());
m_oauth->setRefreshToken(QString()); m_oauth->setRefreshToken(QString());
m_oauth->login(); m_oauth->login();
}); } });
} }
void GreaderNetwork::onAuthFailed() { void GreaderNetwork::onAuthFailed() {
qApp->showGuiMessage(Notification::Event::LoginFailure, qApp->showGuiMessage(Notification::Event::LoginFailure, {
tr("Inoreader: authorization denied"), tr("Inoreader: authorization denied"),
tr("Click this to login again."), tr("Click this to login again."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical },
{}, {}, {}, {
tr("Login"), tr("Login"),
[this]() { [this]() {
m_oauth->login(); m_oauth->login();
}); } });
} }
void GreaderNetwork::initializeOauth() { void GreaderNetwork::initializeOauth() {

View File

@ -39,11 +39,10 @@ bool StandardCategory::performDragDropChange(RootItem* target_item) {
qCriticalNN << LOGSEC_DB qCriticalNN << LOGSEC_DB
<< "Cannot overwrite category:" << "Cannot overwrite category:"
<< QUOTE_W_SPACE_DOT(ex.message()); << QUOTE_W_SPACE_DOT(ex.message());
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Error"), tr("Error"),
tr("Cannot save data for category, detailed information was logged via debug log."), tr("Cannot save data for category, detailed information was logged via debug log."),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical });
true);
return false; return false;
} }
} }

View File

@ -206,11 +206,10 @@ void StandardFeed::fetchMetadataForItself() {
qCriticalNN << LOGSEC_DB qCriticalNN << LOGSEC_DB
<< "Cannot overwrite feed:" << "Cannot overwrite feed:"
<< QUOTE_W_SPACE_DOT(ex.message()); << QUOTE_W_SPACE_DOT(ex.message());
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Error"), tr("Error"),
tr("Cannot save data for feed: %1").arg(ex.message()), tr("Cannot save data for feed: %1").arg(ex.message()),
QSystemTrayIcon::MessageIcon::Critical, QSystemTrayIcon::MessageIcon::Critical });
true);
} }
} }
@ -473,11 +472,11 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) {
qCriticalNN << LOGSEC_DB qCriticalNN << LOGSEC_DB
<< "Cannot overwrite feed:" << "Cannot overwrite feed:"
<< QUOTE_W_SPACE_DOT(ex.message()); << QUOTE_W_SPACE_DOT(ex.message());
qApp->showGuiMessage(Notification::Event::GeneralEvent,
tr("Error"), qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot move feed, detailed information was logged via debug log."), tr("Cannot move feed"),
QSystemTrayIcon::MessageIcon::Critical, tr("Cannot move feed, detailed information was logged via debug log."),
true); QSystemTrayIcon::MessageIcon::Critical });
return false; return false;
} }
} }

View File

@ -122,11 +122,10 @@ void StandardServiceRoot::addNewFeed(RootItem* selected_item, const QString& url
// Lock was not obtained because // Lock was not obtained because
// it is used probably by feed updater or application // it is used probably by feed updater or application
// is quitting. // is quitting.
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot add item"), tr("Cannot add item"),
tr("Cannot add feed because another critical operation is ongoing."), tr("Cannot add feed because another critical operation is ongoing."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
return; return;
} }
@ -394,11 +393,10 @@ void StandardServiceRoot::addNewCategory(RootItem* selected_item) {
// Lock was not obtained because // Lock was not obtained because
// it is used probably by feed updater or application // it is used probably by feed updater or application
// is quitting. // is quitting.
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot add category"), tr("Cannot add category"),
tr("Cannot add category because another critical operation is ongoing."), tr("Cannot add category because another critical operation is ongoing."),
QSystemTrayIcon::Warning, QSystemTrayIcon::Warning });
true);
// Thus, cannot delete and quit the method. // Thus, cannot delete and quit the method.
return; return;

View File

@ -44,10 +44,10 @@ void FormTtRssFeedDetails::apply() {
if (response.code() == STF_INSERTED) { if (response.code() == STF_INSERTED) {
// Feed was added online. // Feed was added online.
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Feed added"), tr("Feed added"),
tr("Feed was added, obtaining new tree of feeds now."), tr("Feed was added, obtaining new tree of feeds now."),
QSystemTrayIcon::MessageIcon::Information); QSystemTrayIcon::MessageIcon::Information });
QTimer::singleShot(300, root, &TtRssServiceRoot::syncIn); QTimer::singleShot(300, root, &TtRssServiceRoot::syncIn);
} }
else { else {

View File

@ -85,11 +85,10 @@ void TtRssServiceRoot::addNewFeed(RootItem* selected_item, const QString& url) {
// Lock was not obtained because // Lock was not obtained because
// it is used probably by feed updater or application // it is used probably by feed updater or application
// is quitting. // is quitting.
qApp->showGuiMessage(Notification::Event::GeneralEvent, qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot add item"), tr("Cannot add item"),
tr("Cannot add feed because another critical operation is ongoing."), tr("Cannot add feed because another critical operation is ongoing."),
QSystemTrayIcon::MessageIcon::Warning, QSystemTrayIcon::MessageIcon::Warning });
true);
return; return;
} }