From f33a098efb93291a83e155cc1126652804fee3da Mon Sep 17 00:00:00 2001 From: Dimitrios Christidis Date: Tue, 12 Feb 2013 11:56:37 +0200 Subject: Honor configuration for Web Shortcuts. Rekonq will no longer ignore options "Enable Web shortcuts" and "Use preferred shortcuts only". This commit also removes the conditional compilation directives introduced in commit 14e028 as rekonq 2.x now depends on 4.9. BUG: 309470 REVIEW: 108902 Signed-off-by: Andrea Diamantini --- src/searchengine.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/searchengine.cpp b/src/searchengine.cpp index 742e9bc1..19529d30 100644 --- a/src/searchengine.cpp +++ b/src/searchengine.cpp @@ -37,6 +37,8 @@ struct SearchEnginePrivate { SearchEnginePrivate() : isLoaded(false) {} bool isLoaded; + bool isEnabled; + bool usePreferredOnly; QString delimiter; KService::List favorites; KService::Ptr defaultEngine; @@ -51,16 +53,15 @@ void SearchEngine::reload() KConfig config("kuriikwsfilterrc"); //Shared with konqueror KConfigGroup cg = config.group("General"); + d->isEnabled = cg.readEntry("EnableWebShortcuts", true); + d->usePreferredOnly = cg.readEntry("UsePreferredWebShortcutsOnly", false); + //load delimiter d->delimiter = cg.readEntry("KeywordDelimiter", ":"); // load favorite engines QStringList favoriteEngines; -#if KDE_IS_VERSION(4,9,0) favoriteEngines = cg.readEntry("PreferredWebShortcuts", favoriteEngines); -#else - favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines); -#endif KService::List favorites; KService::Ptr service; @@ -76,11 +77,7 @@ void SearchEngine::reload() // load default engine QString dse; -#if KDE_IS_VERSION(4,9,0) dse = cg.readEntry("DefaultWebShortcut"); -#else - dse = cg.readEntry("DefaultSearchEngine"); -#endif d->defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(dse)); @@ -117,10 +114,18 @@ KService::Ptr SearchEngine::defaultEngine() KService::Ptr SearchEngine::fromString(const QString &text) { - KService::List providers = KServiceTypeTrader::self()->query("SearchProvider"); + KService::Ptr service; + + // first, the easy part... + if (!d->isEnabled) + return service; + + KService::List providers = (d->usePreferredOnly) + ? SearchEngine::favorites() + : KServiceTypeTrader::self()->query("SearchProvider"); + int i = 0; bool found = false; - KService::Ptr service; while (!found && i < providers.size()) { QStringList list = providers.at(i)->property("Keys").toStringList(); -- cgit v1.2.1