implement temporary status bar messages
This commit is contained in:
parent
f6dd3f88e7
commit
00dee012f1
@ -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;
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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<void()> 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<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 {
|
||||
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<void()> 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();
|
||||
|
@ -69,11 +69,10 @@ QList<ServiceEntryPoint*> FeedReader::feedServices() {
|
||||
|
||||
void FeedReader::updateFeeds(const QList<Feed*>& 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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
} });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user