summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/application.cpp6
-rw-r--r--src/bookmarks/bookmarksmanager.cpp6
-rw-r--r--src/data/rekonq.desktop2
-rw-r--r--src/mainview.cpp43
-rw-r--r--src/mainview.h7
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/urlbar/completionwidget.cpp21
-rw-r--r--src/urlbar/completionwidget.h2
-rw-r--r--src/urlbar/listitem.cpp1
-rw-r--r--src/urlbar/stackedurlbar.cpp74
-rw-r--r--src/urlbar/stackedurlbar.h56
-rw-r--r--src/urlbar/urlbar.cpp26
-rw-r--r--src/urlbar/urlbar.h4
-rw-r--r--src/urlbar/urlresolver.cpp64
15 files changed, 232 insertions, 83 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6926630e..b79e64fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -49,6 +49,7 @@ SET( rekonq_KDEINIT_SRCS
adblock/adblocknetworkreply.cpp
adblock/adblockrule.cpp
#----------------------------------------
+ urlbar/stackedurlbar.cpp
urlbar/urlbar.cpp
urlbar/completionwidget.cpp
urlbar/urlresolver.cpp
diff --git a/src/application.cpp b/src/application.cpp
index b1419d00..bfa9c03f 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -319,6 +319,10 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
break;
};
+
+ // rapidly show first loading url..
+ w->mainView()->urlBar()->setQUrl(url);
+
WebView *view = tab->view();
if (view)
@@ -390,7 +394,7 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job)
void Application::newWindow()
{
loadUrl(KUrl("about:home"), Rekonq::NewWindow);
- mainWindow()->mainView()->urlBarWidget()->setFocus();
+ mainWindow()->mainView()->urlBar()->setFocus();
}
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index bfa8d238..9fe3d689 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -99,7 +99,11 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark)
if (urlList.length() > 8)
{
- if (!(KMessageBox::warningContinueCancel(Application::instance()->mainWindow(), i18n("You are about to open %1 tabs.\nAre you sure ?", QString::number(urlList.length()))) == KMessageBox::Continue))
+ if ( !(KMessageBox::warningContinueCancel( Application::instance()->mainWindow(),
+ i18n("You are about to open %1 tabs.\nAre you sure ?",
+ QString::number( urlList.length() ))
+ ) == KMessageBox::Continue)
+ )
return;
}
diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop
index 109b5505..19ea9dd2 100644
--- a/src/data/rekonq.desktop
+++ b/src/data/rekonq.desktop
@@ -2,6 +2,7 @@
Name=rekonq
Name[cs]=rekonq
Name[da]=rekonq
+Name[it]=rekonq
Name[nds]=Rekonq
Name[pt]=rekonq
Name[pt_BR]=rekonq
@@ -11,6 +12,7 @@ Name[x-test]=xxrekonqxx
GenericName=Webkit KDE Browser
GenericName[cs]=Prohlížeč pro KDE založený na Webkitu
GenericName[da]=KDE-browser baseret på Webkit
+GenericName[it]=Browser per KDE basato su Webkit
GenericName[nds]=Webkit-KDE-Kieker
GenericName[pt]=Navegador do KDE usando o WebKit
GenericName[pt_BR]=Navegador Webkit do KDE
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 84b87956..4fbd5959 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -63,7 +63,7 @@
MainView::MainView(MainWindow *parent)
: KTabWidget(parent)
- , _bars(new QStackedWidget(this))
+ , _widgetBar(new StackedUrlBar(this))
, m_addTabButton(0)
, m_currentTabIndex(0)
, m_parentWindow(parent)
@@ -91,7 +91,7 @@ MainView::MainView(MainWindow *parent)
connect(tabBar, SIGNAL(detachTab(int)), this, SLOT(detachTab(int)));
connect(tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
- connect(tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(movedTab(int, int)));
+ connect(tabBar, SIGNAL(tabMoved(int, int)), _widgetBar, SLOT(moveBar(int, int)));
// current page index changing
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
@@ -102,7 +102,7 @@ MainView::MainView(MainWindow *parent)
MainView::~MainView()
{
- delete _bars;
+ delete _widgetBar;
delete m_addTabButton;
}
@@ -180,13 +180,13 @@ TabBar *MainView::tabBar() const
UrlBar *MainView::urlBar() const
{
- return qobject_cast<UrlBar *>(_bars->widget(m_currentTabIndex));
+ return _widgetBar->urlBar(m_currentTabIndex);
}
-QWidget *MainView::urlBarWidget() const
+StackedUrlBar *MainView::widgetBar() const
{
- return _bars;
+ return _widgetBar;
}
@@ -293,7 +293,7 @@ void MainView::currentChanged(int index)
this, SIGNAL(linkHovered(const QString&)));
emit currentTitle(tab->view()->title());
- _bars->setCurrentIndex(index);
+ _widgetBar->setCurrentIndex(index);
// clean up "status bar"
emit showStatusBarMessage(QString());
@@ -311,7 +311,7 @@ void MainView::currentChanged(int index)
// set focus to the current webview
if (tab->url().scheme() == QL1S("about"))
- _bars->currentWidget()->setFocus();
+ _widgetBar->currentWidget()->setFocus();
else
tab->view()->setFocus();
}
@@ -349,12 +349,12 @@ WebTab *MainView::newWebTab(bool focused, bool nearParent)
if (nearParent)
{
insertTab(currentIndex() + 1, tab, i18n("(Untitled)"));
- _bars->insertWidget(currentIndex() + 1, bar);
+ _widgetBar->insertWidget(currentIndex() + 1, bar);
}
else
{
addTab(tab, i18n("(Untitled)"));
- _bars->addWidget(bar);
+ _widgetBar->addWidget(bar);
}
updateTabBar();
@@ -387,7 +387,7 @@ void MainView::newTab()
default:
break;
}
- _bars->currentWidget()->setFocus();
+ urlBar()->setFocus();
}
@@ -469,6 +469,10 @@ void MainView::closeTab(int index, bool del)
if (count() == 1)
{
WebView *w = currentWebTab()->view();
+
+ if( currentWebTab()->url().protocol() == QL1S("about") )
+ return;
+
switch (ReKonfig::newTabsBehaviour())
{
case 0: // new tab page
@@ -517,8 +521,8 @@ void MainView::closeTab(int index, bool del)
removeTab(index);
updateTabBar(); // UI operation: do it ASAP!!
- QWidget *urlbar = _bars->widget(index);
- _bars->removeWidget(urlbar);
+ UrlBar *urlbar = _widgetBar->urlBar(index);
+ _widgetBar->removeWidget(urlbar);
if (del)
{
@@ -719,21 +723,12 @@ void MainView::detachTab(int index)
else
{
QString label = tab->view()->title();
- QWidget *bar = _bars->widget(index);
+ UrlBar *bar = _widgetBar->urlBar(index);
closeTab(index, false);
MainWindow *w = Application::instance()->newMainWindow(false);
w->mainView()->addTab(tab, Application::icon(u), label);
- QStackedWidget *stack = qobject_cast<QStackedWidget *>(w->mainView()->urlBarWidget());
- stack->insertWidget(0, bar);
+ _widgetBar->insertWidget(0, bar);
w->mainView()->updateTabBar();
}
}
-
-
-void MainView::movedTab(int from, int to)
-{
- QWidget *bar = _bars->widget(from);
- _bars->removeWidget(bar);
- _bars->insertWidget(to, bar);
-}
diff --git a/src/mainview.h b/src/mainview.h
index 6edccc15..6eacc104 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -40,13 +40,13 @@
#include "application.h"
#include "historymanager.h"
#include "mainwindow.h"
+#include "stackedurlbar.h"
// KDE Includes
#include <KTabWidget>
// Qt Includes
#include <QtGui/QToolButton>
-#include <QStackedWidget>
// Forward Declarations
class QUrl;
@@ -72,7 +72,7 @@ public:
MainView(MainWindow *parent);
~MainView();
- QWidget *urlBarWidget() const;
+ StackedUrlBar *widgetBar() const;
UrlBar *urlBar() const;
WebTab *webTab(int index) const;
@@ -151,7 +151,6 @@ private slots:
void windowCloseRequested();
void postLaunch();
- void movedTab(int, int);
protected:
virtual void resizeEvent(QResizeEvent *event);
@@ -174,7 +173,7 @@ private:
// --------------------------------------------------------------------------
- QStackedWidget *_bars;
+ StackedUrlBar *_widgetBar;
QString m_loadingGitPath;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 128648bf..083bb810 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -194,7 +194,7 @@ void MainWindow::setupToolbars()
// location bar
KAction *urlBarAction = new KAction(this);
- urlBarAction->setDefaultWidget(m_view->urlBarWidget());
+ urlBarAction->setDefaultWidget(m_view->widgetBar());
m_mainBar->addAction(urlBarAction);
m_mainBar->addAction(actionByName( QL1S("bookmarksActionMenu") ));
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 1bb01785..b19b163e 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -35,6 +35,7 @@
#include "application.h"
#include "urlresolver.h"
#include "searchengine.h"
+#include "urlbar.h"
// KDE Includes
#include <KGlobalSettings>
@@ -180,7 +181,8 @@ bool CompletionWidget::eventFilter(QObject *o, QEvent *e)
if (wid && wid->isAncestorOf(_parent) && isVisible())
{
ListItem *child;
-
+ UrlBar *w;
+
if (type == QEvent::KeyPress)
{
QKeyEvent *ev = static_cast<QKeyEvent *>(e);
@@ -214,12 +216,21 @@ bool CompletionWidget::eventFilter(QObject *o, QEvent *e)
case Qt::Key_Enter:
case Qt::Key_Return:
- child = findChild<ListItem *>(QString::number(_currentIndex));
- emit chosenUrl(child->url(), Rekonq::CurrentTab);
+ w = qobject_cast<UrlBar *>(parent());
+ if(w->text() == _typedString)
+ {
+ child = findChild<ListItem *>(QString::number(_currentIndex));
+ emit chosenUrl(child->url(), Rekonq::CurrentTab);
+ }
+ else
+ {
+ // this will be used just on fast typing..
+ emit chosenUrl(KUrl(w->text()), Rekonq::CurrentTab);
+ }
ev->accept();
hide();
return true;
-
+
case Qt::Key_Escape:
hide();
return true;
@@ -259,6 +270,8 @@ void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button)
void CompletionWidget::suggestUrls(const QString &text)
{
+ _typedString = text;
+
QWidget *w = qobject_cast<QWidget *>(parent());
if (!w->hasFocus())
return;
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
index 4ce8248d..2d33b59f 100644
--- a/src/urlbar/completionwidget.h
+++ b/src/urlbar/completionwidget.h
@@ -85,6 +85,8 @@ private:
int _currentIndex;
KService::Ptr _searchEngine;
+
+ QString _typedString;
};
#endif // COMPLETION_WIDGET_H
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index c6f75348..f91840d2 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -296,6 +296,7 @@ QString SearchListItem::searchItemTitle(QString engine, QString text)
return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, text));
}
+
void SearchListItem::changeSearchEngine(KService::Ptr engine)
{
m_titleLabel->setText(searchItemTitle(engine->name(), m_text));
diff --git a/src/urlbar/stackedurlbar.cpp b/src/urlbar/stackedurlbar.cpp
new file mode 100644
index 00000000..1882d98c
--- /dev/null
+++ b/src/urlbar/stackedurlbar.cpp
@@ -0,0 +1,74 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 "stackedurlbar.h"
+#include "stackedurlbar.moc"
+
+// Local Includes
+#include "application.h"
+#include "urlbar.h"
+
+
+StackedUrlBar::StackedUrlBar(QWidget *parent)
+ : QStackedWidget(parent)
+{
+ // cosmetic
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ setMinimumWidth(200);
+ setMinimumHeight(26); // FIXME in Qt 4.7 we can probably move using MinimumWidth 20
+}
+
+
+StackedUrlBar::~StackedUrlBar()
+{
+}
+
+
+UrlBar *StackedUrlBar::currentUrlBar()
+{
+ return urlBar(currentIndex());
+}
+
+
+UrlBar *StackedUrlBar::urlBar(int index)
+{
+ UrlBar *urlBar = qobject_cast<UrlBar*>(QStackedWidget::widget(index));
+ if (!urlBar)
+ {
+ kWarning() << "URL bar with index" << index << "not found. Returning NULL. line:" << __LINE__;
+ }
+
+ return urlBar;
+}
+
+
+void StackedUrlBar::moveBar(int from, int to)
+{
+ QWidget *fromBar = widget(from);
+ removeWidget(fromBar);
+ insertWidget(to, fromBar);
+}
diff --git a/src/urlbar/stackedurlbar.h b/src/urlbar/stackedurlbar.h
new file mode 100644
index 00000000..d2c76c8a
--- /dev/null
+++ b/src/urlbar/stackedurlbar.h
@@ -0,0 +1,56 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 STACKED_URLBAR_H
+#define STACKED_URLBAR_H
+
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// Qt Includes
+#include <QStackedWidget>
+
+// Forward Declarations
+class UrlBar;
+
+
+class REKONQ_TESTS_EXPORT StackedUrlBar : public QStackedWidget
+{
+ Q_OBJECT
+
+public:
+ StackedUrlBar(QWidget *parent = 0);
+ ~StackedUrlBar();
+
+ UrlBar *currentUrlBar();
+ UrlBar *urlBar(int index);
+
+private slots:
+ void moveBar(int, int);
+};
+
+#endif // STACKED_URLBAR_H
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index e1e542b7..d2992c4d 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -61,6 +61,7 @@ IconButton::IconButton(QWidget *parent)
setCursor(Qt::ArrowCursor);
}
+
void IconButton::mouseReleaseEvent(QMouseEvent* event)
{
emit clicked(event->globalPos());
@@ -80,11 +81,6 @@ UrlBar::UrlBar(QWidget *parent)
// initial style
setStyleSheet(QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width()));
- // cosmetic
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- setMinimumWidth(200);
- setMinimumHeight(26);
-
// doesn't show the clear button
setClearButtonShown(false);
@@ -190,7 +186,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
// you need this before our code to draw inside the line edit..
KLineEdit::paintEvent(event);
- if (text().isEmpty())
+ if( text().isEmpty() && progr == 0 )
{
QStyleOptionFrame option;
initStyleOption(&option);
@@ -305,7 +301,7 @@ void UrlBar::loadFinished()
void UrlBar::loadTyped(const QString &text)
{
- activated(KUrl(text));
+ activated( KUrl(text) );
}
@@ -363,7 +359,8 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
_rightIconsList << rightIcon;
int iconsCount = _rightIconsList.count();
- rightIcon->move(width() - 23*iconsCount, 6);
+ int iconHeight = (height() - 18) / 2;
+ rightIcon->move(width() - 23*iconsCount, iconHeight);
rightIcon->show();
return rightIcon;
@@ -379,7 +376,7 @@ void UrlBar::clearRightIcons()
void UrlBar::resizeEvent(QResizeEvent *event)
{
- int newHeight = (height() - 19) / 2;
+ int newHeight = (height() - 18) / 2;
_icon->move(4, newHeight);
int iconsCount = _rightIconsList.count();
@@ -392,17 +389,20 @@ void UrlBar::resizeEvent(QResizeEvent *event)
}
KLineEdit::resizeEvent(event);
-
}
void UrlBar::detectTypedString(const QString &typed)
{
- Q_UNUSED(typed);
+ if(typed.count() == 1)
+ {
+ QTimer::singleShot(0, this, SLOT(suggest()));
+ return;
+ }
if(_suggestionTimer->isActive())
_suggestionTimer->stop();
- _suggestionTimer->start(200);
+ _suggestionTimer->start(150);
}
@@ -410,4 +410,4 @@ void UrlBar::suggest()
{
if(!_box.isNull())
_box.data()->suggestUrls( text() );
-} \ No newline at end of file
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index cda8a2e1..7fbe8bb4 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -90,9 +90,11 @@ public:
void setPrivateMode(bool on);
+public slots:
+ void setQUrl(const QUrl &url);
+
private slots:
void activated(const KUrl& url, Rekonq::OpenType = Rekonq::CurrentTab);
- void setQUrl(const QUrl &url);
void loadFinished();
void loadTyped(const QString &);
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index e86adc62..840fd78f 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -88,50 +88,47 @@ UrlSearchList UrlResolver::orderedSearchItems()
}
- if (_typedString.length() >= 2)
- {
- int firstResults = list.count();
- int checkPoint = 9 - firstResults;
+ int firstResults = list.count();
+ int checkPoint = 9 - firstResults;
- UrlSearchList historyList = historyResolution();
- int historyResults = historyList.count();
+ UrlSearchList historyList = historyResolution();
+ int historyResults = historyList.count();
- UrlSearchList bookmarksList = bookmarksResolution();
- int bookmarkResults = bookmarksList.count();
+ UrlSearchList bookmarksList = bookmarksResolution();
+ int bookmarkResults = bookmarksList.count();
- if (historyResults + bookmarkResults > checkPoint)
- {
- historyList = historyList.mid(0, 3);
- bookmarksList = bookmarksList.mid(0, 3);
- }
+ if (historyResults + bookmarkResults > checkPoint)
+ {
+ historyList = historyList.mid(0, 3);
+ bookmarksList = bookmarksList.mid(0, 3);
+ }
- QList<UrlSearchItem> common;
+ QList<UrlSearchItem> common;
- foreach(UrlSearchItem i, historyList)
- {
- if (!bookmarksList.contains(i))
- {
- list << i;
- }
- else
- {
- i.type |= UrlSearchItem::Bookmark;
- common << i;
- }
- }
-
- foreach(const UrlSearchItem &i, common)
+ foreach(UrlSearchItem i, historyList)
+ {
+ if (!bookmarksList.contains(i))
{
list << i;
}
-
- foreach(const UrlSearchItem &i, bookmarksList)
+ else
{
- if (!common.contains(i))
- list << i;
+ i.type |= UrlSearchItem::Bookmark;
+ common << i;
}
}
+ foreach(const UrlSearchItem &i, common)
+ {
+ list << i;
+ }
+
+ foreach(const UrlSearchItem &i, bookmarksList)
+ {
+ if (!common.contains(i))
+ list << i;
+ }
+
list = placeTypedDomaineNameOnTop(list);
return list;
@@ -225,7 +222,7 @@ UrlSearchList UrlResolver::bookmarksResolution()
UrlSearchList UrlResolver::placeTypedDomaineNameOnTop(UrlSearchList list)
{
- int i=0;
+ int i = 0;
bool found = false;
while(i<list.count() && !found)
@@ -242,4 +239,3 @@ UrlSearchList UrlResolver::placeTypedDomaineNameOnTop(UrlSearchList list)
return list;
}
-