Bug 231015 - URL is not shown when new tab opens home page
Summary: URL is not shown when new tab opens home page
Status: RESOLVED FIXED
Alias: None
Product: rekonq
Classification: Applications
Component: general (show other bugs)
Version: 0.4.0
Platform: openSUSE Unspecified
: NOR normal
Target Milestone: ---
Assignee: Andrea Diamantini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-16 20:24 UTC by Silver Salonen
Modified: 2010-04-08 03:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Silver Salonen 2010-03-16 20:24:39 UTC
Version:           0.4.0 (using KDE 4.4.1)
Installed from:    openSUSE RPMs

When new tab is set to open home page, the page is opened, but address-bar is left empty. It should show the home page address instead.
Comment 1 Andrea Diamantini 2010-04-08 03:06:53 UTC
commit 43dc2695d62fd2e4fc01aff608bb2af3e8335040
Author: Andrea Diamantini <adjam7@gmail.com>
Date:   Thu Apr 8 02:53:38 2010 +0200

    This is a really big commit, implementing the new urlbar
    
    - removed previous SSL animation, we have now a nice yellow lock :)
    - faster and cleaner animations
    - reenabled the old stacked widget, to avoid stupid refreshes and fix some regressions
    - implemented some "right icons": KGet, SSL, RSS. For now, just SSL is full featured
    - clean up the box :) Some old & unuseful files removed, some icons added
    - Pano's request: grey text shown everytime in the empty bar
    
    Again and again:
    this is not the first, but the second implementation of the new urlbar UI.
    About me this is clearly better than the first or the previous.
    But it needs love :D
    
    BUG: 230125
    BUG: 231015
    CCBUG: 228040
    BUG: 227272

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 73eda88..102935a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -50,7 +50,6 @@ SET( rekonq_KDEINIT_SRCS
     #----------------------------------------
     urlbar/urlbar.cpp
     urlbar/lineedit.cpp
-    urlbar/iconbutton.cpp
     urlbar/completionwidget.cpp
     urlbar/urlresolver.cpp
     urlbar/listitem.cpp
diff --git a/src/application.cpp b/src/application.cpp
index b8d6f52..3405a1b 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -398,5 +398,5 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job)
 void Application::newWindow()
 {
     loadUrl( KUrl("about:home"), Rekonq::NewWindow );
-    mainWindow()->mainView()->urlBar()->setFocus();
+    mainWindow()->mainView()->urlBarWidget()->setFocus();
 }
diff --git a/src/data/CMakeLists.txt b/src/data/CMakeLists.txt
index 0af92f5..481f8cd 100644
--- a/src/data/CMakeLists.txt
+++ b/src/data/CMakeLists.txt
@@ -1,5 +1,8 @@
 INSTALL( 
-    FILES bg2.png bg.png bot.gif busywidget.gif closed.png loading.mng open.png tile.gif top.png webkit-icon.png category.png button.png
+    FILES 
+    bg2.png bg.png tile.gif category.png button.png
+    busywidget.gif loading.mng  
+    webkit-icon.png rss-icon.png kget-icon.png ssl-icon.png
     DESTINATION ${DATA_INSTALL_DIR}/rekonq/pics
 )
 
diff --git a/src/data/bot.gif b/src/data/bot.gif
deleted file mode 100644
index 2f9abde..0000000
Binary files a/src/data/bot.gif and /dev/null differ
diff --git a/src/data/closed.png b/src/data/closed.png
deleted file mode 100644
index 2b1bf01..0000000
Binary files a/src/data/closed.png and /dev/null differ
diff --git a/src/data/kget-icon.png b/src/data/kget-icon.png
new file mode 100644
index 0000000..367d2bc
Binary files /dev/null and b/src/data/kget-icon.png differ
diff --git a/src/data/open.png b/src/data/open.png
deleted file mode 100644
index fee6f3f..0000000
Binary files a/src/data/open.png and /dev/null differ
diff --git a/src/data/rss-icon.png b/src/data/rss-icon.png
new file mode 100644
index 0000000..46fe641
Binary files /dev/null and b/src/data/rss-icon.png differ
diff --git a/src/data/ssl-icon.png b/src/data/ssl-icon.png
new file mode 100644
index 0000000..2c71397
Binary files /dev/null and b/src/data/ssl-icon.png differ
diff --git a/src/data/top.png b/src/data/top.png
deleted file mode 100644
index 9ebf023..0000000
Binary files a/src/data/top.png and /dev/null differ
diff --git a/src/data/webkit-icon.png b/src/data/webkit-icon.png
index b3ec677..780b0b1 100644
Binary files a/src/data/webkit-icon.png and b/src/data/webkit-icon.png differ
diff --git a/src/mainview.cpp b/src/mainview.cpp
index b582980..d5c552f 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -64,7 +64,7 @@
 
 MainView::MainView(MainWindow *parent)
     : KTabWidget(parent)
-    , m_urlBar(new UrlBar(this))
+    , _bars(new QStackedWidget(this))
     , m_addTabButton(0)
     , m_currentTabIndex(0)
     , m_parentWindow(parent)
@@ -92,6 +92,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)) );
     
     // current page index changing
     connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
@@ -119,8 +120,6 @@ void MainView::postLaunch()
 
 void MainView::updateTabButtonPosition()
 {
-    kDebug() << "updating new tab button position..";
-    
     static bool ButtonInCorner = false;
 
     int tabWidgetWidth = frameSize().width();
@@ -151,7 +150,6 @@ void MainView::updateTabButtonPosition()
         // Y position is fixed
         // Here I noticed with some emphiric valutations ( :D )
         // that 2 look better than 0, just that..
-
         m_addTabButton->move(newPosX, 2);
     }
 }
@@ -170,9 +168,15 @@ TabBar *MainView::tabBar() const
 }
 
 
-UrlBar *MainView::urlBar() const 
+UrlBar *MainView::urlBar() const
+{
+    return qobject_cast<UrlBar *>(_bars->widget(m_currentTabIndex));
+}
+
+
+QWidget *MainView::urlBarWidget() const 
 { 
-    return m_urlBar; 
+    return _bars; 
 }
 
 
@@ -238,16 +242,6 @@ void MainView::webStop()
 }
 
 
-void MainView::clear()
-{
-    // FIXME (the programmer, not the code)
-    // What exactly do we need to clear here?
-     m_urlBar->clear();
-
-    m_recentlyClosedTabs.clear();
-}
-
-
 // When index is -1 index chooses the current tab
 void MainView::reloadTab(int index)
 {
@@ -289,7 +283,7 @@ void MainView::currentChanged(int index)
             this, SIGNAL(linkHovered(const QString&)));
 
     emit currentTitle(tab->view()->title());
-    urlBar()->setCurrentTab(tab);
+    _bars->setCurrentIndex(index);
     
     // clean up "status bar"
     emit showStatusBarMessage( QString() );
@@ -326,7 +320,8 @@ WebTab *MainView::webTab(int index) const
 WebTab *MainView::newWebTab(bool focused, bool nearParent)
 {
     WebTab* tab = new WebTab(this);
-
+    UrlBar *bar = new UrlBar(tab);
+    
     // connecting webview with mainview
     connect(tab->view(), SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
     connect(tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
@@ -339,10 +334,15 @@ WebTab *MainView::newWebTab(bool focused, bool nearParent)
     connect(tab->view()->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *)));
     
     if (nearParent)
+    {
         insertTab(currentIndex() + 1, tab, i18n("(Untitled)"));
+        _bars->insertWidget(currentIndex() + 1, bar);
+    }
     else
+    {
         addTab(tab, i18n("(Untitled)"));
-
+        _bars->addWidget(bar);
+    }
     updateTabBar();
     
     if (focused)
@@ -374,7 +374,7 @@ void MainView::newTab()
     default:
         break;
     }
-    urlBar()->setFocus();
+    urlBarWidget()->setFocus();
 }
 
 
@@ -452,8 +452,6 @@ void MainView::cloneTab(int index)
 // When index is -1 index chooses the current tab
 void MainView::closeTab(int index)
 {
-    urlBar()->clear();
-    
     // open default homePage if just one tab is opened
     if (count() == 1)
     {
@@ -463,7 +461,7 @@ void MainView::closeTab(int index)
         case 0: // new tab page
         case 1: // blank page
             w->load( KUrl("about:home") );
-            urlBar()->setFocus();
+            urlBarWidget()->setFocus();
             break;
         case 2: // homepage
             w->load( KUrl(ReKonfig::homePage()) );
@@ -507,6 +505,10 @@ void MainView::closeTab(int index)
     removeTab(index);
     updateTabBar();        // UI operation: do it ASAP!!
     tab->deleteLater();    // tab is scheduled for deletion.
+
+    QWidget *urlbar = _bars->widget(index);
+    _bars->removeWidget(urlbar);
+    urlbar->deleteLater();
     
     emit tabsChanged();
 }
@@ -679,3 +681,11 @@ void MainView::detachTab(int index)
     
     Application::instance()->loadUrl(url, Rekonq::NewWindow);
 }
+
+
+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 fc10c2d..272cf82 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -44,6 +44,7 @@
 
 // Qt Includes
 #include <QtGui/QToolButton>
+#include <QStackedWidget>
 
 // Forward Declarations
 class QUrl;
@@ -69,6 +70,7 @@ public:
     MainView(MainWindow *parent);
     ~MainView();
 
+    QWidget *urlBarWidget() const;
     UrlBar *urlBar() const;
     WebTab *webTab(int index) const;
 
@@ -85,7 +87,6 @@ public:
     void setTabBarHidden(bool hide);
     
     QToolButton *addTabButton() const;
-    void clear();
 
     /**
      * This function creates a new empty tab
@@ -146,7 +147,7 @@ private slots:
     void windowCloseRequested();
 
     void postLaunch();
-
+    void movedTab(int,int);
 
 protected:
     virtual void resizeEvent(QResizeEvent *event);
@@ -169,7 +170,7 @@ private:
 
 // --------------------------------------------------------------------------
 
-    UrlBar *m_urlBar;
+    QStackedWidget *_bars;
 
     QString m_loadingGitPath;
 
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 13adab3..c49f8e7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -177,7 +177,7 @@ void MainWindow::setupToolbars()
 
     // location bar
     KAction *urlBarAction = new KAction(this);
-    urlBarAction->setDefaultWidget(m_view->urlBar());
+    urlBarAction->setDefaultWidget(m_view->urlBarWidget());
     m_mainBar->addAction( urlBarAction );
 
     m_mainBar->addAction( actionByName("bookmarksActionMenu") );
@@ -760,7 +760,6 @@ void MainWindow::privateBrowsing(bool enable)
         m_view->urlBar()->setPrivateMode(false);
         
         m_lastSearch.clear();
-        m_view->clear();
         m_view->reloadAllTabs();
     }
 }
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index f6867e8..1458bdf 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -85,16 +85,14 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra
     _url = request.url();
     _frame = frame;
     
-    kDebug() << "URL PROTOCOL: " << _url;
-    
-    // relative urls
-    if(_url.isRelative())
-        return false;
-    
     // "http(s)" (fast) handling
     if( _url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") )
         return false;
-    
+
+    // relative urls
+    if(_url.isRelative())
+        return false;
+        
     // javascript handling
     if( _url.protocol() == QL1S("javascript") )
     {
@@ -148,7 +146,9 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra
                 break;
             }
         }
-        
+    
+        Application::instance()->mainWindow()->mainView()->urlBar()->clearRightIcons();
+
         NewTabPage p(frame);
         p.generate(_url);
         return true;
diff --git a/src/urlbar/iconbutton.cpp b/src/urlbar/iconbutton.cpp
deleted file mode 100644
index 6000899..0000000
--- a/src/urlbar/iconbutton.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ============================================================
-*
-* 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 "iconbutton.h"
-#include "iconbutton.moc"
-
-// Local Includes
-#include "application.h"
-
-// KDE Includes
-#include <KDebug>
-
-
-IconButton::IconButton(QWidget *parent)
-    : QToolButton(parent)
-{
-    QPalette p = palette();
-    p.setColor( QPalette::Button, Qt::transparent );
-    setPalette(p);
-
-    setCursor(Qt::ArrowCursor);
-    setStyleSheet("IconButton { border: none; padding: 0px}");
-}
-
-
-void IconButton::setIconUrl(const KUrl &url, bool trusted)
-{
-    setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
-    setIcon( Application::icon(url) );
-    setText( url.host() );
-    
-    if(trusted)
-    {
-        setStyleSheet("IconButton { background-color:#0F0; padding: 2px }");
-    }
-    else
-    {
-        setStyleSheet("IconButton { background-color:#F00; padding: 2px}");
-    }
-    
-    adjustSize();
-}
-
-
-void IconButton::updateIcon(KIcon icon)
-{
-    setToolButtonStyle(Qt::ToolButtonIconOnly);
-    setIcon( icon );
-
-    setStyleSheet("IconButton { background-color:transparent; border: none; padding: 0px}");
-    adjustSize();
-}
diff --git a/src/urlbar/iconbutton.h b/src/urlbar/iconbutton.h
deleted file mode 100644
index b66e212..0000000
--- a/src/urlbar/iconbutton.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ============================================================
-*
-* 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 ICON_BUTTON_H
-#define ICON_BUTTON_H
-
-
-// KDE Includes
-#include <KUrl>
-#include <KIcon>
-
-// Qt Includes
-#include <QToolButton>
-
-
-class IconButton : public QToolButton
-{
-    Q_OBJECT
-
-public:
-    IconButton(QWidget *parent = 0);
-
-    void setIconUrl(const KUrl &url, bool trusted);
-    void updateIcon(KIcon icon);
-};
-
-#endif // ICON_BUTTON_H
diff --git a/src/urlbar/lineedit.cpp b/src/urlbar/lineedit.cpp
index f7af1f6..8e689a4 100644
--- a/src/urlbar/lineedit.cpp
+++ b/src/urlbar/lineedit.cpp
@@ -33,6 +33,8 @@
 // KDE Includes
 #include <klocalizedstring.h>
 #include <KDebug>
+#include <KStandardDirs>
+#include <KIconLoader>
 
 // Qt Includes
 #include <QtGui/QContextMenuEvent>
@@ -42,6 +44,18 @@
 #include <QPainter>
 
 
+IconButton::IconButton(QWidget *parent)
+    : QToolButton(parent)
+{
+    setToolButtonStyle(Qt::ToolButtonIconOnly);
+    setStyleSheet("IconButton { background-color:transparent; border: none; padding: 0px}");
+    setCursor(Qt::ArrowCursor);
+}
+
+
+// -----------------------------------------------------------------------------------------------------------
+
+
 LineEdit::LineEdit(QWidget* parent)
     : KLineEdit(parent)
     , _icon( new IconButton(this) )
@@ -49,8 +63,11 @@ LineEdit::LineEdit(QWidget* parent)
     // cosmetic
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     setMinimumWidth(200);
-    setMinimumHeight(26);
-    updateStyles();
+    setMinimumHeight(20);
+
+    // initial style
+    _icon->move(4,6);
+    setStyleSheet( QString("LineEdit { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width()) );
     
     // doesn't show the clear button
     setClearButtonShown(false);
@@ -75,22 +92,6 @@ LineEdit::~LineEdit()
 }
 
 
-void LineEdit::updateStyles()
-{
-    adjustSize();
-    _icon->adjustSize();
-    if(_icon->toolButtonStyle() == Qt::ToolButtonIconOnly)
-        _icon->move( 4, 3);
-    else
-        _icon->move( 2, 1);
-    
-    int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
-    setStyleSheet(QString("LineEdit { padding-left: %1px; } ").arg(_icon->sizeHint().width() + frameWidth + 1));
-
-    update();
-}
-
-
 void LineEdit::keyPressEvent(QKeyEvent *event)
 {
     if (event->key() == Qt::Key_Escape)
@@ -117,18 +118,70 @@ IconButton *LineEdit::iconButton() const
 
 void LineEdit::paintEvent(QPaintEvent *event)
 {
+    // you need this before our code to draw inside the line edit..
     KLineEdit::paintEvent(event);
     
-    if (text().isEmpty() && !hasFocus()) 
-    {
+    if (text().isEmpty()) 
+    {       
         QStyleOptionFrame option;
         initStyleOption(&option);
         QRect textRect = style()->subElementRect(QStyle::SE_LineEditContents, &option, this);
         QPainter painter(this);
         painter.setPen(Qt::gray);
         painter.drawText( textRect, 
-                          Qt::AlignLeft | Qt::AlignVCenter, 
-                          i18n("Search Bookmarks, History, Google.. and the Kitchen Sink!")
+                          Qt::AlignCenter, 
+                          i18n("Search Bookmarks, History, Google.. just start typing here!")
                         );
     }
 }
+
+
+IconButton *LineEdit::addRightIcon(LineEdit::icon ic)
+{
+    IconButton *rightIcon = new IconButton(this);
+    
+    switch(ic)
+    {
+    case LineEdit::KGet:
+        rightIcon->setIcon( QIcon(KStandardDirs::locate("data", "rekonq/pics/kget-icon.png")) );
+        break;
+    case LineEdit::RSS:
+        rightIcon->setIcon( QIcon(KStandardDirs::locate("data", "rekonq/pics/rss-icon.png")) );
+        break;
+    case LineEdit::SSL:
+        rightIcon->setIcon( QIcon(KStandardDirs::locate("data", "rekonq/pics/ssl-icon.png")) );
+        break;
+    default:
+        kDebug() << "ERROR.. default non extant case!!";
+        break;
+    }
+    
+    _rightIconsList << rightIcon;
+    int iconsCount = _rightIconsList.count();
+    rightIcon->move( width() - 23*iconsCount, 6);
+    rightIcon->show();
+    
+    return rightIcon;
+}
+
+
+void LineEdit::clearRightIcons()
+{
+    qDeleteAll(_rightIconsList);
+    _rightIconsList.clear();
+}
+
+
+void LineEdit::resizeEvent(QResizeEvent *event)
+{
+    KLineEdit::resizeEvent(event);
+    
+    int iconsCount = _rightIconsList.count();
+    int w = width();
+    
+    for(int i = 0; i < iconsCount; ++i)
+    {
+        IconButton *bt = _rightIconsList.at(i);
+        bt->move( w - 23*(i+1), 6);
+    }
+}
diff --git a/src/urlbar/lineedit.h b/src/urlbar/lineedit.h
index 96f2591..5b8ff2a 100644
--- a/src/urlbar/lineedit.h
+++ b/src/urlbar/lineedit.h
@@ -30,13 +30,11 @@
 #define LINEEDIT_H
 
 
-// Local Includes
-#include "iconbutton.h"
-
 // KDE Includes
 #include <KLineEdit>
 #include <KIcon>
 
+// Qt Includes
 #include <QToolButton>
 
 // Forward Declarations
@@ -46,25 +44,53 @@ class QKeyEvent;
 class QStyleOptionFrameV2;
 
 
+class IconButton : public QToolButton
+{
+    Q_OBJECT
+
+public:
+    IconButton(QWidget *parent = 0);
+};
+
+
+// ------------------------------------------------------------------------------------
+
+
+// Definitions
+typedef QList<IconButton *> IconButtonPointerList;
+
+
 class LineEdit : public KLineEdit
 {
     Q_OBJECT
 
 public:
+    
+    enum icon
+    { 
+        KGet    = 0x00000001,
+        RSS     = 0x00000010,
+        SSL     = 0x00000100,
+    };   
+
     explicit LineEdit(QWidget *parent = 0);
     virtual ~LineEdit();
     
     IconButton *iconButton() const;
     
-    void updateStyles();
+    void clearRightIcons();
     
 protected:
     virtual void keyPressEvent(QKeyEvent *);
     virtual void mouseDoubleClickEvent(QMouseEvent *);
     virtual void paintEvent(QPaintEvent *);
+    virtual void resizeEvent(QResizeEvent *);
     
+    IconButton *addRightIcon(LineEdit::icon );
+
 private:    
-    IconButton *_icon;    
+    IconButton *_icon;
+    IconButtonPointerList _rightIconsList;
 };
 
 #endif // LINEEDIT_H
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 35934bf..c5201a1 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -31,6 +31,9 @@
 #include "urlbar.h"
 #include "urlbar.moc"
 
+// Auto Includes
+#include "rekonq.h"
+
 // Local Includes
 #include "application.h"
 #include "lineedit.h"
@@ -60,6 +63,11 @@ UrlBar::UrlBar(QWidget *parent)
     , _tab(0)
     , _privateMode(false)
 {
+    _tab = qobject_cast<WebTab *>(parent);
+    
+    connect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setQUrl(const QUrl &)));
+    connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
+    
     // load urls on activated urlbar signal
     connect(this, SIGNAL(returnPressed(const QString&)), this, SLOT(activated(const QString&)));
 
@@ -77,19 +85,21 @@ UrlBar::~UrlBar()
 
 void UrlBar::setQUrl(const QUrl& url)
 {
+    // find a better place? Ideally a loadStarted connected slot..
+    clearRightIcons();
+    
     if(url.scheme() == QL1S("about") )
     {
-        iconButton()->updateIcon( KIcon("arrow-right") );
+        iconButton()->setIcon( KIcon("arrow-right") );
+        clear();
         setFocus();
     }
     else
     {
         LineEdit::setUrl(url);
         setCursorPosition(0);
-        iconButton()->updateIcon( Application::icon(url) );
+        iconButton()->setIcon( Application::icon(url) );
     }
-
-    updateStyles();
 }
 
 
@@ -111,7 +121,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
     QColor backgroundColor;
     if( _privateMode )
     {
-        backgroundColor = QColor(192, 192, 192);  // gray
+        backgroundColor = QColor(220, 220, 220);  // light gray
     }
     else
     {
@@ -124,21 +134,16 @@ void UrlBar::paintEvent(QPaintEvent *event)
     int progr = _tab->progress();
     if (progr == 0) 
     {
+        if( _tab->url().scheme() == QL1S("https") )
+        {
+            backgroundColor = QColor(255, 255, 171);  // light yellow
+        }
         p.setBrush(QPalette::Base, backgroundColor);
     } 
     else 
     {
-        QColor loadingColor;
-        if ( _tab->url().scheme() == QLatin1String("https"))
-        {
-            loadingColor = QColor(248, 248, 100);
-        }
-        else
-        {
-            loadingColor = QColor(116, 192, 250);
-        }
-    
-    
+        QColor loadingColor = QColor(116, 192, 250);
+        
         QLinearGradient gradient(0, 0, width(), 0);
         gradient.setColorAt(0, loadingColor);
         gradient.setColorAt(((double)progr)/100, backgroundColor);
@@ -225,54 +230,47 @@ void UrlBar::focusInEvent(QFocusEvent *event)
 }
 
 
-void UrlBar::setCurrentTab(WebTab *tab)
+void UrlBar::setPrivateMode(bool on)
 {
-    if(_tab)
-    {
-        disconnect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setQUrl(const QUrl &)));
-        disconnect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
-        disconnect(_tab->page(), SIGNAL(validSSLInfo(bool)), this, SLOT(setTrustedHost(bool)));
-        disconnect(iconButton(), SIGNAL(clicked()), _tab->page(), SLOT(showSSLInfo()));
-    }
-    _tab = tab;
-    connect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setQUrl(const QUrl &)));
-    connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
-    connect(_tab->page(), SIGNAL(validSSLInfo(bool)), this, SLOT(setTrustedHost(bool)));
-    connect(iconButton(), SIGNAL(clicked()), _tab->page(), SLOT(showSSLInfo()));
-            
-    // update it now (the first time)
-    updateStyles();
-    _tab->view()->setFocus();
-    setQUrl( _tab->url() );
+    _privateMode = on;
 }
 
 
-void UrlBar::setPrivateMode(bool on)
+void UrlBar::dropEvent(QDropEvent *event)
 {
-    _privateMode = on;
+    LineEdit::dropEvent(event);
+    activated(text());
 }
 
 
 void UrlBar::loadFinished()
 {
-    // show RSS
+    if(_tab->progress() != 0)
+        return;
+    
+    if(_tab->url().scheme() == QL1S("about") )
+        return;
     
     // show KGet downloads??
+    if(ReKonfig::kgetList())
+    {
+        IconButton *bt = addRightIcon(LineEdit::KGet);
+        connect(bt, SIGNAL(clicked()), _tab->page(), SLOT(downloadAllContentsWithKGet()));
+    }
     
-    // last, but not least
-    updateStyles();
-}
-
-
-void UrlBar::setTrustedHost(bool on)
-{
-    kDebug() << "SET TRUSTED HOST..";
-    iconButton()->setIconUrl( _tab->url() , on );
-}
-
-
-void UrlBar::dropEvent(QDropEvent *event)
-{
-    LineEdit::dropEvent(event);
-    activated(text());
+    // show RSS
+    if(_tab->hasRSSInfo())
+    {
+        IconButton *bt = addRightIcon(LineEdit::RSS);
+        connect(bt, SIGNAL(clicked()), _tab, SLOT(showRSSInfo()));
+    }
+    
+    // show SSL
+    if(_tab->url().scheme() == QL1S("https") )
+    {
+        IconButton *bt = addRightIcon(LineEdit::SSL);
+        connect(bt, SIGNAL(clicked()), _tab->page(), SLOT(showSSLInfo()));
+    }
+    
+    update();
 }
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 3b28fb3..2536c27 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -57,7 +57,6 @@ public:
     UrlBar(QWidget *parent = 0);
     ~UrlBar();
 
-    void setCurrentTab(WebTab *);
     void setPrivateMode(bool on);
 
 private slots:
@@ -66,7 +65,6 @@ private slots:
     void setQUrl(const QUrl &url);
 
     void loadFinished();
-    void setTrustedHost(bool on);
     
 protected:
     virtual void paintEvent(QPaintEvent *event);
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 8dc0ef9..628b013 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -304,9 +304,6 @@ void WebPage::loadFinished(bool)
     {
         wallet()->fillFormData(mainFrame());
     }
-
-    if( mainFrame()->url().scheme() == QL1S("https") )
-        emit validSSLInfo( _sslInfo.isValid() );
 }
 
 
diff --git a/src/webpage.h b/src/webpage.h
index 479d0cd..9583cc2 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -76,9 +76,6 @@ private slots:
     void manageNetworkErrors(QNetworkReply *reply);
     void loadFinished(bool);
     void showSSLInfo();
-
-signals:
-    void validSSLInfo(bool);
     
 private:
     QString errorPage(QNetworkReply *);
diff --git a/src/webtab.cpp b/src/webtab.cpp
index b4e59d8..fd44cc1 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -49,6 +49,7 @@
 #include <KActionMenu>
 #include <KWebView>
 #include <kwebwallet.h>
+#include <KDE/KMessageBox>
 
 // Qt Includes
 #include <QContextMenuEvent>
@@ -59,6 +60,9 @@
 #include <QAction>
 #include <QVBoxLayout>
 
+// Defines
+#define QL1S(x)  QLatin1String(x)
+
 
 WebTab::WebTab(QWidget *parent)
     : QWidget(parent)
@@ -171,3 +175,33 @@ void WebTab::createPreviewSelectorBar(int index)
     connect(page(), SIGNAL(loadFinished(bool)), bar, SLOT(loadFinished()));
     connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), bar, SLOT(verifyUrl()));
 }
+
+
+bool WebTab::hasRSSInfo()
+{
+    _rssList.clear();
+    QWebElementCollection col = page()->mainFrame()->findAllElements("link");
+    foreach(QWebElement el, col)
+    {
+        if( el.attribute("type") == QL1S("application/rss+xml") || el.attribute("type") == QL1S("application/rss+xml") )
+            _rssList << KUrl( el.attribute("href") );
+    }
+    
+    return !_rssList.isEmpty();
+}
+
+
+void WebTab::showRSSInfo()
+{
+    QString urlList = QString("Here are the rss link found: <br /><br />");
+    foreach(const KUrl &url, _rssList)
+    {
+        urlList += QString("<a href=\"") + url.url() + QString("\">") + url.url() + QString("</a><br />");
+    }
+    urlList += QString("<br />Enough for now.. waiting for some cool akonadi based feeds management :)");
+    
+    KMessageBox::information( view(), 
+                              urlList,
+                              "RSS Management"
+                            );
+}
diff --git a/src/webtab.h b/src/webtab.h
index 9837cd6..9054a7c 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -57,15 +57,20 @@ public:
 
     int progress();
     void createPreviewSelectorBar(int index);
+
+    bool hasRSSInfo();
     
 private slots:
     void updateProgress(int progress);
     void loadFinished(bool);
 
     void createWalletBar(const QString &, const QUrl &);
-
+    void showRSSInfo();
+    
 private:
     int m_progress;
+    
+    KUrl::List _rssList;
 };
 
 #endif