From 80c7e876028deefd944c5e5a9b783b68a02f9e90 Mon Sep 17 00:00:00 2001 From: Thijs Heus Date: Mon, 7 Jun 2010 14:27:56 +0200 Subject: Link webshortcuts default engine into urlbar default engine - without crashing with SE=None --- src/searchengine.cpp | 70 ++++++++++++++++------------------------ src/settings/settings_general.ui | 69 --------------------------------------- 2 files changed, 28 insertions(+), 111 deletions(-) (limited to 'src') diff --git a/src/searchengine.cpp b/src/searchengine.cpp index 0d2c6aea..0a66bb64 100644 --- a/src/searchengine.cpp +++ b/src/searchengine.cpp @@ -115,53 +115,39 @@ KService::List SearchEngine::favorites() return m_favorites; } - void SearchEngine::loadFavorites() { - KConfig config("kuriikwsfilterrc"); //Share with konqueror - KConfigGroup cg = config.group("General"); - QStringList favoriteEngines; - favoriteEngines << "wikipedia" << "google"; //defaults - favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines); - - KService::List favorites; - KService::Ptr service; - foreach(const QString &engine, favoriteEngines) - { - service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine)); - if (service) - favorites << service; - } - - m_favorites = favorites; + KConfig config("kuriikwsfilterrc"); //Share with konqueror + KConfigGroup cg = config.group("General"); + QStringList favoriteEngines; + favoriteEngines << "google"; //defaults + favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines); + + KService::List favorites; + KService::Ptr service; + foreach(const QString &engine, favoriteEngines) + { + service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine)); + if (service) + favorites << service; + } + + m_favorites = favorites; } KService::Ptr SearchEngine::defaultEngine() { - int n = ReKonfig::searchEngine(); - QString engine; - switch (n) - { - case 0: - engine = QL1S("google"); - break; - case 1: - engine = QL1S("altavista"); - break; - case 2: - engine = QL1S("lycos"); - break; - case 3: - engine = QL1S("wikipedia"); - break; - case 4: - engine = QL1S("wolfram"); - break; - default: - engine = QL1S("google"); - break; - } - - return KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine)); + KConfig config("kuriikwsfilterrc"); //Share with konqueror + KConfigGroup cg = config.group("General"); + QString d = cg.readEntry("DefaultSearchEngine"); + KService::Ptr service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d)); + if (!service) + { + d = QL1S("google"); + service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d)); + } + + return service; + } diff --git a/src/settings/settings_general.ui b/src/settings/settings_general.ui index 92e409a2..dccf479a 100644 --- a/src/settings/settings_general.ui +++ b/src/settings/settings_general.ui @@ -148,75 +148,6 @@ - - - - Search Engine - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - Qt::LeftToRight - - - Default search engine: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - google - - - - - altavista - - - - - lycos - - - - - wikipedia - - - - - wolfram - - - - - - - -- cgit v1.2.1