From 749138e7c41b41f7b33564baae2e7b54c96e5424 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 25 Sep 2023 13:38:14 +0200 Subject: [PATCH] better logic when handling text for google search --- .../notifications/articlelistnotification.cpp | 4 ++++ .../notifications/toastnotificationsmanager.cpp | 16 ++++++++++++++-- .../notifications/toastnotificationsmanager.h | 2 ++ src/librssguard/network-web/googlesuggest.cpp | 7 ++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/librssguard/gui/notifications/articlelistnotification.cpp b/src/librssguard/gui/notifications/articlelistnotification.cpp index cb899de4f..eee373bb7 100644 --- a/src/librssguard/gui/notifications/articlelistnotification.cpp +++ b/src/librssguard/gui/notifications/articlelistnotification.cpp @@ -32,6 +32,10 @@ ArticleListNotification::ArticleListNotification(QWidget* parent) &PlainToolButton::setEnabled); connect(m_ui.m_btnNextPage, &PlainToolButton::clicked, m_model, &ArticleListNotificationModel::nextPage); connect(m_ui.m_btnPreviousPage, &PlainToolButton::clicked, m_model, &ArticleListNotificationModel::previousPage); + connect(m_ui.m_treeArticles, + &QAbstractItemView::doubleClicked, + this, + &ArticleListNotification::openArticleInWebBrowser); connect(m_ui.m_btnOpenWebBrowser, &PlainToolButton::clicked, this, &ArticleListNotification::openArticleInWebBrowser); connect(m_ui.m_btnOpenArticleList, &PlainToolButton::clicked, diff --git a/src/librssguard/gui/notifications/toastnotificationsmanager.cpp b/src/librssguard/gui/notifications/toastnotificationsmanager.cpp index d783c40ef..9edf8aa2f 100644 --- a/src/librssguard/gui/notifications/toastnotificationsmanager.cpp +++ b/src/librssguard/gui/notifications/toastnotificationsmanager.cpp @@ -71,8 +71,7 @@ void ToastNotificationsManager::showNotification(Notification::Event event, if (!msg.m_feedFetchResults.updatedFeeds().isEmpty()) { if (m_articleListNotification == nullptr) { - m_articleListNotification = new ArticleListNotification(); - hookNotification(m_articleListNotification); + initializeArticleListNotification(); } else if (m_activeNotifications.contains(m_articleListNotification)) { // Article notification is somewhere in list, clear first to move it to first positon. @@ -110,6 +109,8 @@ void ToastNotificationsManager::showNotification(Notification::Event event, m_activeNotifications.prepend(notif); } +void ToastNotificationsManager::openArticleInArticleList(Feed* feed, const Message& msg) {} + void ToastNotificationsManager::closeNotification(BaseToastNotification* notif, bool delete_from_memory) { auto notif_idx = m_activeNotifications.indexOf(notif); @@ -159,6 +160,17 @@ QPoint ToastNotificationsManager::cornerForNewNotification(QRect screen_rect) { } } +void ToastNotificationsManager::initializeArticleListNotification() { + m_articleListNotification = new ArticleListNotification(); + hookNotification(m_articleListNotification); + + /* + connect(m_articleListNotification, + &ArticleListNotification::openingArticleInArticleListRequested, + this, + &ArticleListNotification::)*/ +} + void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) { connect(notif, &BaseToastNotification::closeRequested, this, [this](BaseToastNotification* notif) { closeNotification(notif, notif != m_articleListNotification); diff --git a/src/librssguard/gui/notifications/toastnotificationsmanager.h b/src/librssguard/gui/notifications/toastnotificationsmanager.h index 10f2b54ed..d7d6962bf 100644 --- a/src/librssguard/gui/notifications/toastnotificationsmanager.h +++ b/src/librssguard/gui/notifications/toastnotificationsmanager.h @@ -47,6 +47,7 @@ class ToastNotificationsManager : public QObject { void showNotification(Notification::Event event, const GuiMessage& msg, const GuiAction& action); private slots: + void openArticleInArticleList(Feed* feed, const Message& msg); void closeNotification(BaseToastNotification* notif, bool delete_from_memory); private: @@ -54,6 +55,7 @@ class ToastNotificationsManager : public QObject { QScreen* moveToProperScreen(BaseToastNotification* notif); QPoint cornerForNewNotification(QRect screen_rect); + void initializeArticleListNotification(); void hookNotification(BaseToastNotification* notif); void moveNotificationToCorner(BaseToastNotification* notif, QPoint corner); void makeSpaceForNotification(int height_to_make_space, bool reverse = false, int stard_idx = 0); diff --git a/src/librssguard/network-web/googlesuggest.cpp b/src/librssguard/network-web/googlesuggest.cpp index d10777400..bca64ba24 100644 --- a/src/librssguard/network-web/googlesuggest.cpp +++ b/src/librssguard/network-web/googlesuggest.cpp @@ -150,7 +150,12 @@ void GoogleSuggest::preventSuggest() { } void GoogleSuggest::autoSuggest() { - QUrl entered_url = QUrl::fromUserInput(m_editor->text()); + QUrl entered_url = QUrl(m_editor->text()); + + // auto a = entered_url.isValid(); + // auto b = entered_url.isLocalFile(); + // auto c = entered_url.scheme(); + // auto d = entered_url.host(); if (m_editor->text().size() < 3 || m_editor->text().startsWith(QSL("http")) || m_editor->text().startsWith(QSL("www")) ||