summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-04-08 02:53:38 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-04-08 02:53:38 +0200
commit43dc2695d62fd2e4fc01aff608bb2af3e8335040 (patch)
treee854bca16452965d5e4d38bc1d36459bf723355f /src/urlbar
parentrekonq 0.4.59 (diff)
downloadrekonq-43dc2695d62fd2e4fc01aff608bb2af3e8335040.tar.xz
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
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/iconbutton.cpp76
-rw-r--r--src/urlbar/iconbutton.h51
-rw-r--r--src/urlbar/lineedit.cpp97
-rw-r--r--src/urlbar/lineedit.h36
-rw-r--r--src/urlbar/urlbar.cpp104
-rw-r--r--src/urlbar/urlbar.h2
6 files changed, 157 insertions, 209 deletions
diff --git a/src/urlbar/iconbutton.cpp b/src/urlbar/iconbutton.cpp
deleted file mode 100644
index 60008993..00000000
--- 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 b66e212b..00000000
--- 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 f7af1f61..8e689a46 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 96f25918..5b8ff2a3 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 35934bf4..c5201a1c 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 3b28fb3a..2536c27b 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);