summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-04-19 16:30:48 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-04-19 16:30:48 +0200
commit380b6fec3b11a562888f335cca2bcb412a120a22 (patch)
treef5ad26a416b9a82270e836be3ee230b51302aa0c
parentFix urlbar string as suggested by Johannes Zellner (diff)
parentSuggestions activation on demand (diff)
downloadrekonq-380b6fec3b11a562888f335cca2bcb412a120a22.tar.xz
Merge branch 'DefaultEngine'
-rw-r--r--src/rekonq.kcfg5
-rw-r--r--src/settings/settings_general.ui105
-rw-r--r--src/settings/settings_tabs.ui138
-rw-r--r--src/urlbar/listitem.cpp45
-rw-r--r--src/urlbar/listitem.h1
-rw-r--r--src/urlbar/urlbar.cpp37
-rw-r--r--src/urlbar/urlbar.h7
7 files changed, 236 insertions, 102 deletions
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index c999d063..860809cd 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -61,7 +61,10 @@
<entry name="kgetList" type="Bool">
<default>false</default>
</entry>
- </group>
+ <entry name="searchEngine" type="Int">
+ <default>0</default>
+ </entry>
+ </group>
<!-- Tabs Settings -->
<group name="Tabs">
diff --git a/src/settings/settings_general.ui b/src/settings/settings_general.ui
index 98a56591..00277133 100644
--- a/src/settings/settings_general.ui
+++ b/src/settings/settings_general.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>751</width>
- <height>523</height>
+ <width>552</width>
+ <height>512</height>
</rect>
</property>
<property name="windowTitle">
@@ -150,11 +150,11 @@
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
- <string>New Tabs Behaviour</string>
+ <string>Search Engine</string>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -169,73 +169,20 @@
</property>
<property name="baseSize">
<size>
- <width>120</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>New tab opens:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="kcfg_newTabsBehaviour">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>New Tab Page</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Blank Page</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="@item:inlistbox">Home Page</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_5">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>120</width>
+ <width>0</width>
<height>0</height>
</size>
</property>
- <property name="baseSize">
- <size>
- <width>120</width>
- <height>0</height>
- </size>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
</property>
<property name="text">
- <string>New tab page starts with:</string>
+ <string>Default search engine:</string>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="KComboBox" name="kcfg_newTabStartPage">
- <property name="enabled">
- <bool>true</bool>
- </property>
+ <item>
+ <widget class="KComboBox" name="kcfg_searchEngine">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -244,27 +191,27 @@
</property>
<item>
<property name="text">
- <string>Favorites</string>
+ <string>google</string>
</property>
</item>
<item>
<property name="text">
- <string>Closed Tabs</string>
+ <string>altavista</string>
</property>
</item>
<item>
<property name="text">
- <string>Bookmarks</string>
+ <string>lycos</string>
</property>
</item>
<item>
<property name="text">
- <string>History</string>
+ <string>wikipedia</string>
</property>
</item>
<item>
<property name="text">
- <string>Downloads</string>
+ <string>wolfram</string>
</property>
</item>
</widget>
@@ -277,14 +224,7 @@
<property name="title">
<string>Download Manager</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QCheckBox" name="kcfg_kgetDownload">
- <property name="text">
- <string>Use KGet for downloading files</string>
- </property>
- </widget>
- </item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="kcfg_kgetList">
<property name="whatsThis">
@@ -295,6 +235,13 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="kcfg_kgetDownload">
+ <property name="text">
+ <string>Use KGet for downloading files</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -306,7 +253,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>40</height>
+ <height>179</height>
</size>
</property>
</spacer>
diff --git a/src/settings/settings_tabs.ui b/src/settings/settings_tabs.ui
index 9104843a..45579e90 100644
--- a/src/settings/settings_tabs.ui
+++ b/src/settings/settings_tabs.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>456</width>
- <height>329</height>
+ <width>483</width>
+ <height>427</height>
</rect>
</property>
<property name="windowTitle">
@@ -15,6 +15,131 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>New Tabs Behaviour</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>New tab opens:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KComboBox" name="kcfg_newTabsBehaviour">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>New Tab Page</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Blank Page</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string comment="@item:inlistbox">Home Page</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>120</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>New tab page starts with:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="KComboBox" name="kcfg_newTabStartPage">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>Favorites</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Closed Tabs</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Bookmarks</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>History</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Downloads</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Tabbed Browsing</string>
@@ -79,13 +204,20 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>142</height>
+ <height>120</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>KComboBox</class>
+ <extends>QComboBox</extends>
+ <header>kcombobox.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index 4b9831b2..d35da547 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -28,6 +28,9 @@
#include "listitem.h"
#include "listitem.moc"
+// Auto Includes
+#include "rekonq.h"
+
// Local Includes
#include "urlresolver.h"
#include "application.h"
@@ -52,6 +55,9 @@
#include <QWebSettings>
#include <QFile>
+// Defines
+#define QL1S(x) QLatin1String(x)
+
ListItem::ListItem(const UrlSearchItem &item, QWidget *parent)
: QWidget(parent)
@@ -260,7 +266,8 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q
: ListItem(item, parent)
, m_text(text)
{
- if (m_currentEngine == "") m_currentEngine = EngineBar::defaultEngine();
+ if (m_currentEngine == "")
+ m_currentEngine = EngineBar::defaultEngine();
m_iconLabel = new ItemIcon("edit-find", this); //TODO: get the default engine icon
m_titleLabel = new ItemText(searchItemTitle(m_currentEngine, text));
@@ -315,10 +322,10 @@ EngineBar::EngineBar(const QString &text, const QString &selectedEngine, QWidget
QStringList favoriteEngines;
favoriteEngines << "wikipedia" << "google"; //defaults
favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines);
- QString defaultEngine = cg.readEntry("DefaultSearchEngine", "google");
- KService::Ptr service;
- service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(defaultEngine));
+ // default engine
+ QString defaultEngine = EngineBar::defaultEngine();
+ KService::Ptr service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(defaultEngine));
m_engineGroup->addAction(newEngineAction(service, selectedEngine));
// set url;
@@ -344,11 +351,31 @@ EngineBar::EngineBar(const QString &text, const QString &selectedEngine, QWidget
QString EngineBar::defaultEngine()
{
- KConfig config("kuriikwsfilterrc"); //Share with konqueror
- KConfigGroup cg = config.group("General");
- QString d = cg.readEntry("DefaultSearchEngine", "google");
- KService::Ptr service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
- return service->name();
+ 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 engine;
}
diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h
index 8a6f520f..a9dc8213 100644
--- a/src/urlbar/listitem.h
+++ b/src/urlbar/listitem.h
@@ -127,6 +127,7 @@ class EngineBar : public KToolBar
public:
EngineBar(const QString &text, const QString &selectedEngine, QWidget *parent = 0);
+
static QString defaultEngine();
void selectNextEngine();
KUrl url() { return m_url; };
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 8c6c0749..6d1b19c9 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -60,7 +60,6 @@
UrlBar::UrlBar(QWidget *parent)
: LineEdit(parent)
- , _box(new CompletionWidget(this))
, _tab(0)
, _privateMode(false)
{
@@ -69,19 +68,18 @@ UrlBar::UrlBar(QWidget *parent)
connect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setQUrl(const QUrl &)));
connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
connect(_tab->view(), SIGNAL(loadStarted()), this, SLOT(clearRightIcons()));
-
- // suggestions
- installEventFilter(_box);
- connect(_box, SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), this, SLOT(activated(const KUrl &, Rekonq::OpenType)));
// load typed urls
connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &)));
+
+ activateSuggestions(true);
}
UrlBar::~UrlBar()
{
- delete _box;
+ activateSuggestions(false);
+ _box.clear();
}
@@ -105,7 +103,7 @@ void UrlBar::setQUrl(const QUrl& url)
void UrlBar::activated(const KUrl& url, Rekonq::OpenType type)
{
- disconnect(this, SIGNAL(textChanged(const QString &)), _box, SLOT(suggestUrls(const QString &)));
+ activateSuggestions(false);
clearFocus();
setUrl(url);
@@ -189,8 +187,7 @@ void UrlBar::keyPressEvent(QKeyEvent *event)
void UrlBar::focusInEvent(QFocusEvent *event)
{
- // activate suggestions on edit text
- connect(this, SIGNAL(textChanged(const QString &)), _box, SLOT(suggestUrls(const QString &)));
+ activateSuggestions(true);
LineEdit::focusInEvent(event);
}
@@ -249,3 +246,25 @@ void UrlBar::loadTyped(const QString &text)
{
activated(KUrl(text));
}
+
+
+void UrlBar::activateSuggestions(bool b)
+{
+ if(b)
+ {
+ if(_box.isNull())
+ {
+ _box = new CompletionWidget(this);
+ installEventFilter(_box.data());
+ connect(_box.data(), SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), this, SLOT(activated(const KUrl &, Rekonq::OpenType)));
+
+ // activate suggestions on edit text
+ connect(this, SIGNAL(textChanged(const QString &)), _box.data(), SLOT(suggestUrls(const QString &)));
+ }
+ }
+ else
+ {
+ removeEventFilter(_box.data());
+ _box.data()->deleteLater();
+ }
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 3ecd914e..9adc35a3 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -38,6 +38,9 @@
// KDE Includes
#include <KUrl>
+// Qt Includes
+#include <QWeakPointer>
+
// Forward Declarations
class QLinearGradient;
class QWidget;
@@ -69,7 +72,9 @@ protected:
virtual void dropEvent(QDropEvent *event);
private:
- CompletionWidget *_box;
+ void activateSuggestions(bool);
+
+ QWeakPointer<CompletionWidget> _box;
WebTab *_tab;
bool _privateMode;
};