[PATCH] Respect systemwide default search engine
authorNate Graham <nate@kde.org>
Fri, 18 Apr 2025 19:13:02 +0000 (13:13 -0600)
committerAurélien COUDERC <coucouf@debian.org>
Mon, 14 Jul 2025 21:44:48 +0000 (23:44 +0200)
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

discover/CMakeLists.txt
discover/DiscoverObject.cpp
discover/DiscoverObject.h
discover/qml/ApplicationsListPage.qml

index 9c195fca4e7eb788c8f2e30a93da540364c1a8f0..8fda6621ae74d640b4eff4a05767e0fcf7e49af0 100644 (file)
@@ -45,6 +45,7 @@ target_link_libraries(plasma-discover PUBLIC
                                      KF6::I18n
                                      KF6::ConfigGui
                                      KF6::KIOCore
+                                     KF6::KIOGui
                                      KF6::WindowSystem
                                      KF6::Notifications
                                      KF6::JobWidgets
index 4ca4b5f8fc6aa40244ce1406e9255a4e5024ceb5..43a563a4a4904c203306cb7a565aa5b1b0fdd63d 100644 (file)
@@ -45,6 +45,7 @@
 #include <KSharedConfig>
 #include <KStatusNotifierItem>
 #include <KUiServerV2JobTracker>
+#include <KUriFilter>
 #include <kcoreaddons_version.h>
 // #include <KSwitchLanguageDialog>
 
@@ -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()) {
index 2d9d1cf047be558123a239f1174769b4b012a015..3b611518b90deebcec209e09a398a7bf24f7d823 100644 (file)
@@ -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();
index d497c5f75c27920504a3fa4043ca75edc01dbd90..f3ffeeda90464537afbf0443769104c33eccd5fd 100644 (file)
@@ -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));
                     }
                 }