summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/application.cpp4
-rw-r--r--src/opensearch/opensearchmanager.cpp1
-rw-r--r--src/opensearch/opensearchmanager.h1
-rw-r--r--src/opensearch/searchengine.cpp3
-rw-r--r--src/opensearch/searchengine.h23
-rw-r--r--src/rekonq.kcfg3
-rw-r--r--src/searchenginebar.cpp93
-rw-r--r--src/searchenginebar.h55
-rw-r--r--src/webtab.cpp14
-rw-r--r--src/webtab.h2
11 files changed, 190 insertions, 10 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 10b57b1c..518ce571 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,6 +24,7 @@ SET( rekonq_KDEINIT_SRCS
previewselectorbar.cpp
protocolhandler.cpp
rekonqmenu.cpp
+ searchenginebar.cpp
sessionmanager.cpp
sslinfodialog.cpp
tabpreviewpopup.cpp
diff --git a/src/application.cpp b/src/application.cpp
index 0eb08cee..40197d78 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -46,6 +46,7 @@
#include "mainview.h"
#include "mainwindow.h"
#include "opensearchmanager.h"
+#include "searchengine.h"
#include "sessionmanager.h"
#include "syncmanager.h"
#include "stackedurlbar.h"
@@ -318,6 +319,9 @@ int Application::newInstance()
if (isFirstLoad)
{
+ if (ReKonfig::checkDefaultSearchEngine() && !isRekonqCrashed && SearchEngine::defaultEngine().isNull())
+ QTimer::singleShot(2000, mainWindow()->currentTab(), SLOT(showSearchEngineBar()));
+
// updating rekonq configuration
updateConfiguration();
diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp
index 12b93ec2..ad2f7092 100644
--- a/src/opensearch/opensearchmanager.cpp
+++ b/src/opensearch/opensearchmanager.cpp
@@ -131,6 +131,7 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl
connect(m_currentJob, SIGNAL(result(KJob*)), this, SLOT(jobFinished(KJob*)));
}
+
void OpenSearchManager::requestSuggestion(const QString &searchText)
{
if (!m_activeEngine)
diff --git a/src/opensearch/opensearchmanager.h b/src/opensearch/opensearchmanager.h
index 84272f26..b2f772fb 100644
--- a/src/opensearch/opensearchmanager.h
+++ b/src/opensearch/opensearchmanager.h
@@ -46,6 +46,7 @@
// Forward Declarations
class OpenSearchEngine;
+
/**
* This class acts as a proxy between the SearchBar plugin
* and the individual suggestion engine.
diff --git a/src/opensearch/searchengine.cpp b/src/opensearch/searchengine.cpp
index b54d9434..aef06a7b 100644
--- a/src/opensearch/searchengine.cpp
+++ b/src/opensearch/searchengine.cpp
@@ -37,6 +37,7 @@
#include <KConfigGroup>
#include <KServiceTypeTrader>
+
struct SearchEnginePrivate
{
SearchEnginePrivate() : isLoaded(false) {}
@@ -46,8 +47,10 @@ struct SearchEnginePrivate
KService::Ptr defaultEngine;
};
+
K_GLOBAL_STATIC(SearchEnginePrivate, d)
+
void SearchEngine::reload()
{
KConfig config("kuriikwsfilterrc"); //Shared with konqueror
diff --git a/src/opensearch/searchengine.h b/src/opensearch/searchengine.h
index 7825d661..7cd37a67 100644
--- a/src/opensearch/searchengine.h
+++ b/src/opensearch/searchengine.h
@@ -2,7 +2,7 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2008-2011 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2009-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
*
*
@@ -24,6 +24,7 @@
*
* ============================================================ */
+
#ifndef SEARCHENGINE_H
#define SEARCHENGINE_H
@@ -40,13 +41,19 @@
namespace SearchEngine
{
-void reload();
-QString delimiter();
-KService::Ptr defaultEngine();
-KService::List favorites();
-KService::Ptr fromString(const QString &text);
-QString buildQuery(KService::Ptr engine, const QString &text);
-QString extractQuery(const QString &text);
+ void reload();
+
+ QString delimiter();
+
+ KService::Ptr defaultEngine();
+
+ KService::List favorites();
+
+ KService::Ptr fromString(const QString &text);
+
+ QString buildQuery(KService::Ptr engine, const QString &text);
+
+ QString extractQuery(const QString &text);
}
#endif
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index bdcbcb60..1675c558 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -36,6 +36,9 @@
<entry name="createMenuAppShortcut" type="Bool">
<default>false</default>
</entry>
+ <entry name="checkDefaultSearchEngine" type="Bool">
+ <default>true</default>
+ </entry>
</group>
diff --git a/src/searchenginebar.cpp b/src/searchenginebar.cpp
new file mode 100644
index 00000000..f8e137ec
--- /dev/null
+++ b/src/searchenginebar.cpp
@@ -0,0 +1,93 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2012 by Andrea Diamantini <adjam7 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 "searchenginebar.h"
+#include "searchenginebar.moc"
+
+// Auto Includes
+#include "rekonq.h"
+
+// KDE Includes
+#include <KIcon>
+#include <KIconLoader>
+#include <KAction>
+#include <KLocalizedString>
+
+// Qt Includes
+#include <QProcess>
+
+
+SearchEngineBar::SearchEngineBar(QWidget *parent)
+ : KMessageWidget(parent)
+{
+ connect(this, SIGNAL(accepted()), this, SLOT(hideAndDelete()));
+ connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
+
+ connect(this, SIGNAL(rejected()), this, SLOT(hideAndDelete()));
+ connect(this, SIGNAL(rejected()), this, SLOT(slotRejected()));
+
+ setMessageType(KMessageWidget::Information);
+
+ QSize sz = size();
+ sz.setWidth(qobject_cast<QWidget *>(parent)->size().width());
+ resize(sz);
+
+ setCloseButtonVisible(false);
+
+ setText(i18n("You don't have a default search engine set. Without it, rekonq will no show proper urlbar suggestions."));
+
+ KAction *acceptAction = new KAction(i18n("Set it"), this);
+ connect(acceptAction, SIGNAL(triggered(bool)), this, SIGNAL(accepted()));
+ addAction(acceptAction);
+
+ KAction *rejectAction = new KAction(i18n("Ignore"), this);
+ connect(rejectAction, SIGNAL(triggered(bool)), this, SIGNAL(rejected()));
+ addAction(rejectAction);
+}
+
+
+void SearchEngineBar::hideAndDelete()
+{
+ animatedHide();
+ deleteLater();
+}
+
+
+void SearchEngineBar::slotAccepted()
+{
+ QProcess *proc = new QProcess(parent());
+ QStringList args;
+ args << QL1S("ebrowsing");
+ proc->start(QL1S("kcmshell4"), args);
+}
+
+
+void SearchEngineBar::slotRejected()
+{
+ // Remember users choice
+ ReKonfig::setCheckDefaultSearchEngine(false);
+}
diff --git a/src/searchenginebar.h b/src/searchenginebar.h
new file mode 100644
index 00000000..9e5b8efc
--- /dev/null
+++ b/src/searchenginebar.h
@@ -0,0 +1,55 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2012 by Andrea Diamantini <adjam7 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 SEARCH_ENGINE_BAR_H
+#define SEARCH_ENGINE_BAR_H
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// KDE Includes
+#include <KMessageWidget>
+
+
+class REKONQ_TESTS_EXPORT SearchEngineBar : public KMessageWidget
+{
+ Q_OBJECT
+
+public:
+ explicit SearchEngineBar(QWidget *parent);
+
+private Q_SLOTS:
+ void hideAndDelete();
+ void slotAccepted();
+ void slotRejected();
+
+Q_SIGNALS:
+ void accepted();
+ void rejected();
+};
+
+
+#endif // SEARCH_ENGINE_BAR_H
diff --git a/src/webtab.cpp b/src/webtab.cpp
index cbb38a5e..718d8b98 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -39,6 +39,7 @@
#include "opensearchmanager.h"
#include "previewselectorbar.h"
#include "rsswidget.h"
+#include "searchenginebar.h"
#include "sessionmanager.h"
#include "syncmanager.h"
#include "urlbar.h"
@@ -253,6 +254,7 @@ void WebTab::showRSSInfo(const QPoint &pos)
widget->showAt(pos);
}
+
void WebTab::hideSelectorBar()
{
m_previewSelectorBar.data()->animatedHide();
@@ -341,8 +343,7 @@ void WebTab::openSearchEngineAdded()
void WebTab::showMessageBar()
{
MessageBar *msgBar = new MessageBar(i18n("It seems rekonq was not closed properly. Do you want "
- "to restore the last saved session?")
- , this);
+ "to restore the last saved session?"), this);
qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, msgBar);
msgBar->animatedShow();
@@ -363,3 +364,12 @@ void WebTab::loadFinished()
QString pageTitle = (page() && page()->isOnRekonqPage()) ? url().url() : m_webView->title();
rApp->historyManager()->addHistoryEntry(url(), pageTitle);
}
+
+
+void WebTab::showSearchEngineBar()
+{
+ SearchEngineBar *seBar = new SearchEngineBar(this);
+
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, seBar);
+ seBar->animatedShow();
+}
diff --git a/src/webtab.h b/src/webtab.h
index 257f7380..92ae2eb5 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -104,6 +104,8 @@ private Q_SLOTS:
void showMessageBar();
void loadFinished();
+
+ void showSearchEngineBar();
private:
KUrl extractOpensearchUrl(QWebElement e);