summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/adblock/adblockmanager.cpp2
-rw-r--r--src/adblock/adblockrule.cpp93
-rw-r--r--src/adblock/adblockrule.h20
-rw-r--r--src/adblock/adblockrulefallbackimpl.cpp105
-rw-r--r--src/adblock/adblockrulefallbackimpl.h47
-rw-r--r--src/adblock/adblockruleimpl.h39
-rw-r--r--src/adblock/adblockruletextmatchimpl.cpp68
-rw-r--r--src/adblock/adblockruletextmatchimpl.h47
-rw-r--r--src/mainwindow.cpp39
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/searchengine.cpp110
-rw-r--r--src/searchengine.h10
-rw-r--r--src/settings/generalwidget.cpp22
-rw-r--r--src/settings/generalwidget.h1
-rw-r--r--src/settings/settingsdialog.cpp4
-rw-r--r--src/urlbar/bookmarkwidget.cpp17
-rw-r--r--src/urlbar/urlbar.cpp2
-rw-r--r--src/webview.cpp12
19 files changed, 437 insertions, 207 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8c78c5a3..f7d94777 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -54,6 +54,8 @@ SET( rekonq_KDEINIT_SRCS
adblock/adblockmanager.cpp
adblock/adblocknetworkreply.cpp
adblock/adblockrule.cpp
+ adblock/adblockrulefallbackimpl.cpp
+ adblock/adblockruletextmatchimpl.cpp
#----------------------------------------
urlbar/stackedurlbar.cpp
urlbar/urlbar.cpp
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index 39432f88..644ecff5 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -168,7 +168,6 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
if (filter.match(urlString))
{
kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched: ***********";
- kDebug() << "Filter exp: " << filter.pattern();
kDebug() << "UrlString: " << urlString;
return 0;
}
@@ -180,7 +179,6 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa
if (filter.match(urlString))
{
kDebug() << "****ADBLOCK: BLACK RULE Matched: ***********";
- kDebug() << "Filter exp: " << filter.pattern();
kDebug() << "UrlString: " << urlString;
QWebElement document = page->mainFrame()->documentElement();
diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp
index 6ff98f03..1cb6773a 100644
--- a/src/adblock/adblockrule.cpp
+++ b/src/adblock/adblockrule.cpp
@@ -55,94 +55,13 @@
// Self Includes
#include "adblockrule.h"
-// Qt Includes
-#include <QStringList>
-#include <QUrl>
-
+#include "adblockrulefallbackimpl.h"
+#include "adblockruletextmatchimpl.h"
AdBlockRule::AdBlockRule(const QString &filter)
{
- bool isRegExpRule = false;
-
- QString parsedLine = filter;
-
- if (parsedLine.startsWith(QL1C('/')) && parsedLine.endsWith(QL1C('/')))
- {
- parsedLine = parsedLine.mid(1);
- parsedLine = parsedLine.left(parsedLine.size() - 1);
- isRegExpRule = true;
- }
-
- int optionsNumber = parsedLine.indexOf(QL1C('$'), 0);
- QStringList options;
-
- if (optionsNumber >= 0)
- {
- options = parsedLine.mid(optionsNumber + 1).split(QL1C(','));
- parsedLine = parsedLine.left(optionsNumber);
- }
-
- if (!isRegExpRule)
- parsedLine = convertPatternToRegExp(parsedLine);
-
- m_regExp = QRegExp(parsedLine, Qt::CaseInsensitive, QRegExp::RegExp2);
-
- if (options.contains(QL1S("match-case")))
- {
- m_regExp.setCaseSensitivity(Qt::CaseSensitive);
- }
-}
-
-
-// here return false means that rule doesn't match,
-// so that url is allowed
-// return true means "matched rule", so stop url!
-bool AdBlockRule::match(const QString &encodedUrl) const
-{
- return m_regExp.indexIn(encodedUrl) != -1;
-}
-
-
-QString AdBlockRule::convertPatternToRegExp(const QString &wildcardPattern)
-{
- QString pattern = wildcardPattern;
-
- // remove multiple wildcards
- pattern.replace(QRegExp(QL1S("\\*+")), QL1S("*"));
-
- // remove anchors following separator placeholder
- pattern.replace(QRegExp(QL1S("\\^\\|$")), QL1S("^"));
-
- // remove leading wildcards
- pattern.replace(QRegExp(QL1S("^(\\*)")), QL1S(""));
-
- // remove trailing wildcards
- pattern.replace(QRegExp(QL1S("(\\*)$")), QL1S(""));
-
- // escape special symbols
- pattern.replace(QRegExp(QL1S("(\\W)")), QL1S("\\\\1"));
-
- // process extended anchor at expression start
- pattern.replace(QRegExp(QL1S("^\\\\\\|\\\\\\|")), QL1S("^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?"));
-
- // process separator placeholders
- pattern.replace(QRegExp(QL1S("\\\\\\^")), QL1S("(?:[^\\w\\d\\-.%]|$)"));
-
- // process anchor at expression start
- pattern.replace(QRegExp(QL1S("^\\\\\\|")), QL1S("^"));
-
- // process anchor at expression end
- pattern.replace(QRegExp(QL1S("\\\\\\|$")), QL1S("$"));
-
- // replace wildcards by .*
- pattern.replace(QRegExp(QL1S("\\\\\\*")), QL1S(".*"));
-
- // Finally, return...
- return pattern;
-}
-
-
-QString AdBlockRule::pattern() const
-{
- return m_regExp.pattern();
+ if (AdBlockRuleTextMatchImpl::isTextMatchFilter(filter))
+ m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleTextMatchImpl(filter));
+ else
+ m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleFallbackImpl(filter));
}
diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h
index 28084004..04409688 100644
--- a/src/adblock/adblockrule.h
+++ b/src/adblock/adblockrule.h
@@ -58,27 +58,25 @@
// Rekonq Includes
#include "rekonq_defines.h"
-// Qt Includes
-#include <QtCore/QRegExp>
-#include <QtCore/QString>
+#include "adblockruleimpl.h"
-// Forward Includes
-class QUrl;
+#include <QSharedPointer>
+// Forward Includes
+class QString;
class AdBlockRule
{
public:
AdBlockRule(const QString &filter);
- bool match(const QString &encodedUrl) const;
-
- QString pattern() const;
+ bool match(const QString &encodedUrl) const
+ {
+ return m_implementation->match(encodedUrl);
+ }
private:
- QString convertPatternToRegExp(const QString &wildcardPattern);
-
- QRegExp m_regExp;
+ QSharedPointer<AdBlockRuleImpl> m_implementation;
};
diff --git a/src/adblock/adblockrulefallbackimpl.cpp b/src/adblock/adblockrulefallbackimpl.cpp
new file mode 100644
index 00000000..decb895d
--- /dev/null
+++ b/src/adblock/adblockrulefallbackimpl.cpp
@@ -0,0 +1,105 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Benjamin Poulain <ikipou at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+// Self Includes
+#include "adblockrulefallbackimpl.h"
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// Qt Includes
+#include <QStringList>
+
+static inline bool isRegExpFilter(const QString &filter)
+{
+ return filter.startsWith(QL1C('/')) && filter.endsWith(QL1C('/'));
+}
+
+AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter)
+ : AdBlockRuleImpl(filter)
+{
+ m_regExp.setCaseSensitivity(Qt::CaseInsensitive);
+ m_regExp.setPatternSyntax(QRegExp::RegExp2);
+
+ QString parsedLine = filter;
+
+ const int optionsNumber = parsedLine.lastIndexOf(QL1C('$'));
+ if (optionsNumber >= 0 && !isRegExpFilter(parsedLine)) {
+ const QStringList options(parsedLine.mid(optionsNumber + 1).split(QL1C(',')));
+ if (options.contains(QL1S("match-case")))
+ m_regExp.setCaseSensitivity(Qt::CaseSensitive);
+ parsedLine = parsedLine.left(optionsNumber);
+ }
+
+ if (isRegExpFilter(parsedLine))
+ parsedLine = parsedLine.mid(1, parsedLine.length() - 2);
+ else
+ parsedLine = convertPatternToRegExp(parsedLine);
+
+ m_regExp.setPattern(parsedLine);
+}
+
+bool AdBlockRuleFallbackImpl::match(const QString &encodedUrl) const
+{
+ return m_regExp.indexIn(encodedUrl) != -1;
+}
+
+QString AdBlockRuleFallbackImpl::convertPatternToRegExp(const QString &wildcardPattern)
+{
+ QString pattern = wildcardPattern;
+
+ // remove multiple wildcards
+ pattern.replace(QRegExp(QL1S("\\*+")), QL1S("*"));
+
+ // remove anchors following separator placeholder
+ pattern.replace(QRegExp(QL1S("\\^\\|$")), QL1S("^"));
+
+ // remove leading wildcards
+ pattern.replace(QRegExp(QL1S("^(\\*)")), QL1S(""));
+
+ // remove trailing wildcards
+ pattern.replace(QRegExp(QL1S("(\\*)$")), QL1S(""));
+
+ // escape special symbols
+ pattern.replace(QRegExp(QL1S("(\\W)")), QL1S("\\\\1"));
+
+ // process extended anchor at expression start
+ pattern.replace(QRegExp(QL1S("^\\\\\\|\\\\\\|")), QL1S("^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?"));
+
+ // process separator placeholders
+ pattern.replace(QRegExp(QL1S("\\\\\\^")), QL1S("(?:[^\\w\\d\\-.%]|$)"));
+
+ // process anchor at expression start
+ pattern.replace(QRegExp(QL1S("^\\\\\\|")), QL1S("^"));
+
+ // process anchor at expression end
+ pattern.replace(QRegExp(QL1S("\\\\\\|$")), QL1S("$"));
+
+ // replace wildcards by .*
+ pattern.replace(QRegExp(QL1S("\\\\\\*")), QL1S(".*"));
+
+ // Finally, return...
+ return pattern;
+}
diff --git a/src/adblock/adblockrulefallbackimpl.h b/src/adblock/adblockrulefallbackimpl.h
new file mode 100644
index 00000000..4e7ca555
--- /dev/null
+++ b/src/adblock/adblockrulefallbackimpl.h
@@ -0,0 +1,47 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Benjamin Poulain <ikipou at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+#ifndef ADBLOCKRULEFALLBACKIMPL_H
+#define ADBLOCKRULEFALLBACKIMPL_H
+
+#include "adblockruleimpl.h"
+
+// Qt Includes
+#include <QRegExp>
+#include <QString>
+
+class AdBlockRuleFallbackImpl : public AdBlockRuleImpl
+{
+public:
+ AdBlockRuleFallbackImpl(const QString &filter);
+ bool match(const QString &encodedUrl) const;
+
+private:
+ QString convertPatternToRegExp(const QString &wildcardPattern);
+
+ QRegExp m_regExp;
+};
+
+#endif // ADBLOCKRULEFALLBACKIMPL_H
diff --git a/src/adblock/adblockruleimpl.h b/src/adblock/adblockruleimpl.h
new file mode 100644
index 00000000..da367aeb
--- /dev/null
+++ b/src/adblock/adblockruleimpl.h
@@ -0,0 +1,39 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Benjamin Poulain <ikipou at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+#ifndef ADBLOCKRULEIMPL_H
+#define ADBLOCKRULEIMPL_H
+
+class QString;
+
+class AdBlockRuleImpl
+{
+public:
+ AdBlockRuleImpl(const QString &) {}
+ virtual ~AdBlockRuleImpl() {}
+ virtual bool match(const QString &encodedUrl) const = 0;
+};
+
+#endif // ADBLOCKRULEIMPL_H
diff --git a/src/adblock/adblockruletextmatchimpl.cpp b/src/adblock/adblockruletextmatchimpl.cpp
new file mode 100644
index 00000000..7c02ea37
--- /dev/null
+++ b/src/adblock/adblockruletextmatchimpl.cpp
@@ -0,0 +1,68 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Benjamin Poulain <ikipou at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+// Self Includes
+#include "adblockruletextmatchimpl.h"
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+AdBlockRuleTextMatchImpl::AdBlockRuleTextMatchImpl(const QString &filter)
+ : AdBlockRuleImpl(filter)
+{
+ Q_ASSERT(AdBlockRuleTextMatchImpl::isTextMatchFilter(filter));
+
+ m_textToMatch = filter;
+ m_textToMatch.remove(QL1C('*'));
+}
+
+bool AdBlockRuleTextMatchImpl::match(const QString &encodedUrl) const
+{
+ return encodedUrl.contains(m_textToMatch, Qt::CaseInsensitive);
+}
+
+bool AdBlockRuleTextMatchImpl::isTextMatchFilter(const QString &filter)
+{
+ // We don't deal with options just yet
+ if (filter.contains(QL1C('$')))
+ return false;
+
+ // We don't deal with element matching
+ if (filter.contains(QL1S("##")))
+ return false;
+
+ // We don't deal with the begin-end matching
+ if (filter.startsWith(QL1C('|')) || filter.endsWith(QL1C('|')))
+ return false;
+
+ // We only handle * at the beginning or the end
+ int starPosition = filter.indexOf(QL1C('*'));
+ while (starPosition >= 0) {
+ if (starPosition != 0 && starPosition != (filter.length() - 1))
+ return false;
+ starPosition = filter.indexOf(QL1C('*'), starPosition + 1);
+ }
+ return true;
+}
diff --git a/src/adblock/adblockruletextmatchimpl.h b/src/adblock/adblockruletextmatchimpl.h
new file mode 100644
index 00000000..f0e78be0
--- /dev/null
+++ b/src/adblock/adblockruletextmatchimpl.h
@@ -0,0 +1,47 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Benjamin Poulain <ikipou at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+#ifndef ADBLOCKRULETEXTMATCHIMPL_H
+#define ADBLOCKRULETEXTMATCHIMPL_H
+
+#include "adblockruleimpl.h"
+
+// Qt Includes
+#include <QString>
+
+// Simple rule to find a string in the URL
+class AdBlockRuleTextMatchImpl : public AdBlockRuleImpl
+{
+public:
+ AdBlockRuleTextMatchImpl(const QString &filter);
+ bool match(const QString &encodedUrl) const;
+
+ static bool isTextMatchFilter(const QString &filter);
+
+private:
+ QString m_textToMatch;
+};
+
+#endif // ADBLOCKRULETEXTMATCHIMPL_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index cbef274a..73779627 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -211,19 +211,7 @@ void MainWindow::setupToolbars()
void MainWindow::postLaunch()
{
- KToolBar *mainBar = toolBar("mainToolBar");
-
- QToolButton *bookmarksButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName( QL1S("bookmarksActionMenu") )));
- if(bookmarksButton)
- {
- connect(actionByName(QL1S("bookmarksActionMenu")), SIGNAL(triggered()), bookmarksButton, SLOT(showMenu()));
- }
-
- QToolButton *toolsButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName( QL1S("rekonq_tools") )));
- if(toolsButton)
- {
- connect(actionByName(QL1S("rekonq_tools")), SIGNAL(triggered()), toolsButton, SLOT(showMenu()));
- }
+ setupBookmarksAndToolsShortcuts();
// setting popup notification
m_popup->setAutoDelete(false);
@@ -1343,3 +1331,28 @@ bool MainWindow::queryClose()
}
return true;
}
+
+
+void MainWindow::saveNewToolbarConfig()
+{
+ KXmlGuiWindow::saveNewToolbarConfig();
+ setupBookmarksAndToolsShortcuts();
+}
+
+
+void MainWindow::setupBookmarksAndToolsShortcuts()
+{
+ KToolBar *mainBar = toolBar("mainToolBar");
+
+ QToolButton *bookmarksButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName( QL1S("bookmarksActionMenu") )));
+ if(bookmarksButton)
+ {
+ connect(actionByName(QL1S("bookmarksActionMenu")), SIGNAL(triggered()), bookmarksButton, SLOT(showMenu()));
+ }
+
+ QToolButton *toolsButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName( QL1S("rekonq_tools") )));
+ if(toolsButton)
+ {
+ connect(actionByName(QL1S("rekonq_tools")), SIGNAL(triggered()), toolsButton, SLOT(showMenu()));
+ }
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index e5a43649..50c73b4b 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -81,6 +81,7 @@ public:
void setWidgetsVisible(bool makeFullScreen);
private:
+ void setupBookmarksAndToolsShortcuts();
void setupActions();
void setupTools();
void setupToolbars();
@@ -108,6 +109,9 @@ signals:
void ctrlTabPressed();
void shiftCtrlTabPressed();
+protected slots:
+ void saveNewToolbarConfig();
+
protected:
/**
* Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed()
diff --git a/src/searchengine.cpp b/src/searchengine.cpp
index 0a66bb64..7065d55f 100644
--- a/src/searchengine.cpp
+++ b/src/searchengine.cpp
@@ -36,40 +36,70 @@
#include <KServiceTypeTrader>
+bool SearchEngine::m_loaded = false;
QString SearchEngine::m_delimiter = "";
+KService::List SearchEngine::m_favorites;
+KService::Ptr SearchEngine::m_defaultEngine;
-QString SearchEngine::delimiter()
-{
- if (m_delimiter == "") loadDelimiter();
- return m_delimiter;
-}
-
-
-void SearchEngine::loadDelimiter()
+void SearchEngine::reload()
{
- KConfig config("kuriikwsfilterrc"); //Share with konqueror
+ KConfig config("kuriikwsfilterrc"); //Shared with konqueror
KConfigGroup cg = config.group("General");
+
+ //load delimiter
m_delimiter = cg.readEntry("KeywordDelimiter", ":");
+
+ //load favorite engines
+ QStringList favoriteEngines;
+ 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;
+
+ //load default engine
+ QString d = cg.readEntry("DefaultSearchEngine");
+ m_defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
+ if (!m_defaultEngine)
+ {
+ d = QL1S("google");
+ m_defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
+ }
+
+ m_loaded = true;
}
-KService::Ptr SearchEngine::m_defaultWS;
+QString SearchEngine::delimiter()
+{
+ if (!m_loaded)
+ reload();
+
+ return m_delimiter;
+}
-KService::Ptr SearchEngine::defaultWS()
+KService::List SearchEngine::favorites()
{
- if (!m_defaultWS) loadDefaultWS();
- return m_defaultWS;
+ if (!m_loaded)
+ reload();
+
+ return m_favorites;
}
-void SearchEngine::loadDefaultWS()
+KService::Ptr SearchEngine::defaultEngine()
{
- KConfig config("kuriikwsfilterrc"); //Share with konqueror
- KConfigGroup cg = config.group("General");
- QString d = cg.readEntry("DefaultSearchEngine", "google");
- m_defaultWS = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
+ if (!m_loaded)
+ reload();
+
+ return m_defaultEngine;
}
@@ -106,48 +136,4 @@ QString SearchEngine::buildQuery(KService::Ptr engine, QString text)
}
-KService::List SearchEngine::m_favorites;
-
-
-KService::List SearchEngine::favorites()
-{
- if (m_favorites.isEmpty()) loadFavorites();
- return m_favorites;
-}
-
-void SearchEngine::loadFavorites()
-{
- 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()
-{
- 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/searchengine.h b/src/searchengine.h
index 2e30e056..e57b1a5c 100644
--- a/src/searchengine.h
+++ b/src/searchengine.h
@@ -41,22 +41,18 @@
class SearchEngine
{
public:
-
+ static void reload();
static QString delimiter();
static KService::Ptr defaultEngine();
static KService::List favorites();
static KService::Ptr fromString(QString text);
static QString buildQuery(KService::Ptr engine, QString text);
- static KService::Ptr defaultWS();
-
- static void loadDelimiter();
- static void loadFavorites();
- static void loadDefaultWS();
private:
+ static bool m_loaded;
static QString m_delimiter;
static KService::List m_favorites;
- static KService::Ptr m_defaultWS;
+ static KService::Ptr m_defaultEngine;
};
#endif
diff --git a/src/settings/generalwidget.cpp b/src/settings/generalwidget.cpp
index 09c9e5c7..94f8b9c6 100644
--- a/src/settings/generalwidget.cpp
+++ b/src/settings/generalwidget.cpp
@@ -36,6 +36,8 @@
#include "mainwindow.h"
#include "webtab.h"
+//KDE Includes
+#include <kstandarddirs.h>
GeneralWidget::GeneralWidget(QWidget *parent)
: QWidget(parent)
@@ -48,6 +50,8 @@ GeneralWidget::GeneralWidget(QWidget *parent)
disableHomeSettings(ReKonfig::useNewTabPage());
connect(kcfg_useNewTabPage, SIGNAL(toggled(bool)), this, SLOT(disableHomeSettings(bool)));
+
+ checkKGetPresence();
}
@@ -83,3 +87,21 @@ void GeneralWidget::disableHomeSettings(bool b)
kcfg_homePage->setEnabled(!b);
setHomeToCurrentPageButton->setEnabled(!b);
}
+
+void GeneralWidget::checkKGetPresence()
+{
+ if (KStandardDirs::findExe("kget").isNull())
+ {
+ ReKonfig::setKgetDownload(false);
+ ReKonfig::setKgetList(false);
+ kcfg_kgetDownload->setDisabled(true);
+ kcfg_kgetList->setDisabled(true);
+ kcfg_kgetDownload->setToolTip(i18n("Install KGet to enable rekonq to use KGet as download manager"));
+
+ }
+ else
+ {
+ kcfg_kgetDownload->setDisabled(false);
+ kcfg_kgetList->setDisabled(false);
+ }
+}
diff --git a/src/settings/generalwidget.h b/src/settings/generalwidget.h
index d669fd04..b2cefcfa 100644
--- a/src/settings/generalwidget.h
+++ b/src/settings/generalwidget.h
@@ -44,6 +44,7 @@ public:
void save();
bool changed();
+ void checkKGetPresence();
signals:
void changed(bool);
diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp
index cd64f434..eee2a4e1 100644
--- a/src/settings/settingsdialog.cpp
+++ b/src/settings/settingsdialog.cpp
@@ -197,9 +197,7 @@ void SettingsDialog::saveSettings()
d->shortcutsEditor->save();
d->ebrowsingModule->save();
- SearchEngine::loadDefaultWS();
- SearchEngine::loadDelimiter();
- SearchEngine::loadFavorites();
+ SearchEngine::reload();
updateButtons();
emit settingsChanged("ReKonfig");
diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp
index 3380ec57..ccfe4914 100644
--- a/src/urlbar/bookmarkwidget.cpp
+++ b/src/urlbar/bookmarkwidget.cpp
@@ -152,21 +152,6 @@ void BookmarkWidget::showAt(const QPoint &pos)
void BookmarkWidget::removeBookmark()
{
- bool folder = m_bookmark.isGroup();
-
- if (KMessageBox::warningContinueCancel(
- QApplication::activeWindow(),
- folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", m_bookmark.text())
- : i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", m_bookmark.text()),
- folder ? i18n("Bookmark Folder Deletion")
- : i18n("Bookmark Deletion"),
- KStandardGuiItem::del())
- == KMessageBox::Continue
- )
- {
- m_bookmark.parentGroup().deleteBookmark(m_bookmark);
- Application::bookmarkProvider()->bookmarkManager()->emitChanged();
- }
-
+ Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(m_bookmark);
reject();
}
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index e2033120..0d130b94 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -312,10 +312,12 @@ void UrlBar::loadFinished()
if (Application::bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull())
{
_icon->setIcon(KIcon("bookmarks").pixmap(32,32, QIcon::Disabled));
+ _icon->setToolTip(i18n("Bookmark this page"));
}
else
{
_icon->setIcon(KIcon("bookmarks"));
+ _icon->setToolTip(i18n("Edit this bookmark"));
}
// show KGet downloads??
diff --git a/src/webview.cpp b/src/webview.cpp
index 441225af..b710719f 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -536,13 +536,11 @@ void WebView::keyPressEvent(QKeyEvent *event)
}
-
-
-
void WebView::wheelEvent(QWheelEvent *event)
{
- if (!ReKonfig::smoothScrolling() || page()->currentFrame()->hitTestContent(event->pos()).isContentEditable())
- KWebView::wheelEvent(event);
+ // To let some websites (eg: google maps) to handle wheel events
+ int ypos = page()->currentFrame()->scrollPosition().y();
+ KWebView::wheelEvent(event);
// Sync with the zoom slider
if (event->modifiers() == Qt::ControlModifier)
@@ -560,8 +558,10 @@ void WebView::wheelEvent(QWheelEvent *event)
emit zoomChanged(newFactor);
}
- else if ( ReKonfig::smoothScrolling() && !page()->currentFrame()->hitTestContent(event->pos()).isContentEditable())
+ else if (ReKonfig::smoothScrolling() && ypos != page()->currentFrame()->scrollPosition().y())
{
+ page()->currentFrame()->setScrollPosition(QPoint(page()->currentFrame()->scrollPosition().x(), ypos));
+
int numDegrees = event->delta() / 8;
int numSteps = numDegrees / 15;