diff --git a/src/librssguard/gui/feedmessageviewer.cpp b/src/librssguard/gui/feedmessageviewer.cpp index 8e18b8903..f8b812633 100644 --- a/src/librssguard/gui/feedmessageviewer.cpp +++ b/src/librssguard/gui/feedmessageviewer.cpp @@ -236,11 +236,7 @@ void FeedMessageViewer::loadMessageToFeedAndArticleList(Feed* feed, const Messag // TODO: expand properly m_feedsView->setExpanded(idx_map, true); - - m_feedsView->selectionModel()->select(idx_map, - QItemSelectionModel::SelectionFlag::ClearAndSelect | - QItemSelectionModel::SelectionFlag::Rows); - + m_feedsView->setCurrentIndex(idx_map); qApp->processEvents(); auto idx_map_msg = m_messagesView->model()->indexFromMessage(message); @@ -255,7 +251,6 @@ void FeedMessageViewer::loadMessageToFeedAndArticleList(Feed* feed, const Messag return; } - // m_messagesView->selectionModel()->select(idx_map_msg, QItemSelectionModel::SelectionFlag::Clear); m_messagesView->setCurrentIndex(idx_map_msg); } diff --git a/src/librssguard/gui/notifications/articlelistnotification.cpp b/src/librssguard/gui/notifications/articlelistnotification.cpp index d8035abdc..1183bb0ba 100644 --- a/src/librssguard/gui/notifications/articlelistnotification.cpp +++ b/src/librssguard/gui/notifications/articlelistnotification.cpp @@ -7,6 +7,7 @@ #include "miscellaneous/iconfactory.h" #include "network-web/webfactory.h" +#include #include ArticleListNotification::ArticleListNotification(QWidget* parent) @@ -16,6 +17,8 @@ ArticleListNotification::ArticleListNotification(QWidget* parent) setupHeading(m_ui.m_lblTitle); setupCloseButton(m_ui.m_btnClose); + m_ui.m_treeArticles->viewport()->installEventFilter(this); + m_ui.m_btnNextPage->setIcon(qApp->icons()->fromTheme(QSL("arrow-right"), QSL("stock_right"))); m_ui.m_btnPreviousPage->setIcon(qApp->icons()->fromTheme(QSL("arrow-left"), QSL("stock_left"))); m_ui.m_btnOpenArticleList->setIcon(qApp->icons()->fromTheme(QSL("view-list-details"))); @@ -112,6 +115,8 @@ void ArticleListNotification::openArticleInWebBrowser() { Message msg = selectedMessage(); markAsRead(fd, {msg}); + emit reloadMessageListRequested(false); + qApp->web()->openUrlInExternalBrowser(msg.m_url); } @@ -119,6 +124,8 @@ void ArticleListNotification::markAllRead() { for (Feed* fd : m_newMessages.keys()) { markAsRead(fd, m_newMessages.value(fd)); } + + emit reloadMessageListRequested(false); } void ArticleListNotification::markAsRead(Feed* feed, const QList& articles) { @@ -157,3 +164,13 @@ Message ArticleListNotification::selectedMessage() const { throw ApplicationException(QSL("message cannot be loaded, wrong index")); } } + +bool ArticleListNotification::eventFilter(QObject* watched, QEvent* event) { + if (event->type() == QEvent::Type::MouseButtonRelease) { + if (dynamic_cast(event)->button() == Qt::MouseButton::MiddleButton) { + openArticleInArticleList(); + } + } + + return BaseToastNotification::eventFilter(watched, event); +} diff --git a/src/librssguard/gui/notifications/articlelistnotification.h b/src/librssguard/gui/notifications/articlelistnotification.h index 171002bd7..c37fe8c29 100644 --- a/src/librssguard/gui/notifications/articlelistnotification.h +++ b/src/librssguard/gui/notifications/articlelistnotification.h @@ -22,6 +22,10 @@ class ArticleListNotification : public BaseToastNotification { signals: void openingArticleInArticleListRequested(Feed* feed, const Message& msg); + void reloadMessageListRequested(bool mark_selected_messages_read); + + public: + virtual bool eventFilter(QObject* watched, QEvent* event); private slots: void openArticleInArticleList(); diff --git a/src/librssguard/gui/notifications/toastnotificationsmanager.cpp b/src/librssguard/gui/notifications/toastnotificationsmanager.cpp index adbf0a072..8cc6cff15 100644 --- a/src/librssguard/gui/notifications/toastnotificationsmanager.cpp +++ b/src/librssguard/gui/notifications/toastnotificationsmanager.cpp @@ -166,6 +166,11 @@ void ToastNotificationsManager::initializeArticleListNotification() { &ArticleListNotification::openingArticleInArticleListRequested, this, &ToastNotificationsManager::openingArticleInArticleListRequested); + + connect(m_articleListNotification, + &ArticleListNotification::reloadMessageListRequested, + this, + &ToastNotificationsManager::reloadMessageListRequested); } void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) { diff --git a/src/librssguard/gui/notifications/toastnotificationsmanager.h b/src/librssguard/gui/notifications/toastnotificationsmanager.h index 4f233c83a..6617fad00 100644 --- a/src/librssguard/gui/notifications/toastnotificationsmanager.h +++ b/src/librssguard/gui/notifications/toastnotificationsmanager.h @@ -51,6 +51,7 @@ class ToastNotificationsManager : public QObject { signals: void openingArticleInArticleListRequested(Feed* feed, const Message& msg); + void reloadMessageListRequested(bool mark_selected_messages_read); private: QScreen* activeScreen() const; diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index b13da5cd9..a81eab364 100644 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -18,6 +18,7 @@ #include "gui/dialogs/formmain.h" #include "gui/feedmessageviewer.h" #include "gui/messagebox.h" +#include "gui/messagesview.h" #include "gui/notifications/toastnotificationsmanager.h" #include "gui/toolbars/statusbar.h" #include "gui/webviewers/qtextbrowser/textbrowserviewer.h" @@ -157,6 +158,13 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin m_icons->loadCurrentIconTheme(); m_skins->loadCurrentSkin(); + if (m_toastNotifications != nullptr) { + connect(m_toastNotifications, + &ToastNotificationsManager::openingArticleInArticleListRequested, + this, + &Application::loadMessageToFeedAndArticleList); + } + connect(this, &Application::aboutToQuit, this, &Application::onAboutToQuit); connect(this, &Application::commitDataRequest, this, &Application::onCommitData); connect(this, &Application::saveStateRequest, this, &Application::onSaveState); @@ -499,9 +507,9 @@ void Application::setMainForm(FormMain* main_form) { if (m_toastNotifications != nullptr) { connect(m_toastNotifications, - &ToastNotificationsManager::openingArticleInArticleListRequested, - m_mainForm->tabWidget()->feedMessageViewer(), - &FeedMessageViewer::loadMessageToFeedAndArticleList); + &ToastNotificationsManager::reloadMessageListRequested, + m_mainForm->tabWidget()->feedMessageViewer()->messagesView(), + &MessagesView::reloadSelections); } } @@ -751,6 +759,11 @@ void Application::showGuiMessageCore(Notification::Event event, } } +void Application::loadMessageToFeedAndArticleList(Feed* feed, const Message& message) { + m_mainForm->display(); + m_mainForm->tabWidget()->feedMessageViewer()->loadMessageToFeedAndArticleList(feed, message); +} + void Application::showGuiMessage(Notification::Event event, const GuiMessage& msg, GuiMessageDestination dest, diff --git a/src/librssguard/miscellaneous/application.h b/src/librssguard/miscellaneous/application.h index c1a6e92be..a32ba146e 100644 --- a/src/librssguard/miscellaneous/application.h +++ b/src/librssguard/miscellaneous/application.h @@ -211,6 +211,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication { QWidget* parent = nullptr); private slots: + void loadMessageToFeedAndArticleList(Feed* feed, const Message& message); void fillCmdArgumentsParser(QCommandLineParser& parser); void onNodeJsPackageUpdateError(const QList& pkgs, const QString& error);