From: Nate Graham Date: Fri, 18 Apr 2025 19:13:02 +0000 (-0600) Subject: [PATCH] Respect systemwide default search engine X-Git-Tag: archive/raspbian/6.3.6-1+rpi1^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=35cb1bc67bc032cbe73b608b684aa0ef87c5681a;p=plasma-discover.git [PATCH] Respect systemwide default search engine Right now we hardcode DuckDuckGo, which ignores the user's preference and doesn't work in Indonesia, where it's currently blocked. Instead, get the actual configured default search engine, which the user can change if desired or needed. BUG: 502908 FIXED-IN: 6.4.0 Gbp-Pq: Name upstream_1e71f6c7_Respect-systemwide-default-search-engine.patch --- diff --git a/discover/CMakeLists.txt b/discover/CMakeLists.txt index 9c195fc..8fda662 100644 --- a/discover/CMakeLists.txt +++ b/discover/CMakeLists.txt @@ -45,6 +45,7 @@ target_link_libraries(plasma-discover PUBLIC KF6::I18n KF6::ConfigGui KF6::KIOCore + KF6::KIOGui KF6::WindowSystem KF6::Notifications KF6::JobWidgets diff --git a/discover/DiscoverObject.cpp b/discover/DiscoverObject.cpp index 4ca4b5f..43a563a 100644 --- a/discover/DiscoverObject.cpp +++ b/discover/DiscoverObject.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include // #include @@ -631,6 +632,15 @@ void DiscoverObject::copyTextToClipboard(const QString text) clipboard->setText(text); } +QUrl DiscoverObject::searchUrl(const QString searchText) +{ + KUriFilterData filterData(searchText); + if (KUriFilter::self()->filterSearchUri(filterData, KUriFilter::NormalTextFilter)) { + return filterData.uri(); + } + return {}; +} + void DiscoverObject::setAboutToPowerOff() { for (auto backend : ResourcesModel::global()->backends()) { diff --git a/discover/DiscoverObject.h b/discover/DiscoverObject.h index 2d9d1cf..3b61151 100644 --- a/discover/DiscoverObject.h +++ b/discover/DiscoverObject.h @@ -44,6 +44,7 @@ public: QQuickWindow *mainWindow() const; void showError(const QString &msg); Q_INVOKABLE void copyTextToClipboard(const QString text); + Q_INVOKABLE QUrl searchUrl(const QString searchText); QString describeSources() const; Q_SCRIPTABLE void restore(); diff --git a/discover/qml/ApplicationsListPage.qml b/discover/qml/ApplicationsListPage.qml index d497c5f..f3ffeed 100644 --- a/discover/qml/ApplicationsListPage.qml +++ b/discover/qml/ApplicationsListPage.qml @@ -229,7 +229,7 @@ DiscoverPage { icon.name: "internet-web-browser" onTriggered: { const searchTerm = encodeURIComponent("Linux " + appsModel.search); - Qt.openUrlExternally(i18nc("If appropriate, localize this URL to be something more relevant to the language. %1 is the text that will be searched for.", "https://duckduckgo.com/?q=%1", searchTerm)); + Qt.openUrlExternally(app.searchUrl(searchTerm)); } }