summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/urlbar.cpp43
-rw-r--r--src/urlbar.h3
2 files changed, 44 insertions, 2 deletions
diff --git a/src/urlbar.cpp b/src/urlbar.cpp
index 4a599463..894c702f 100644
--- a/src/urlbar.cpp
+++ b/src/urlbar.cpp
@@ -22,6 +22,7 @@
#include "urlbar.moc"
#include "browserapplication.h"
+#include "browsermainwindow.h"
UrlBar::UrlBar(KHistoryComboBox *parent)
@@ -31,25 +32,30 @@ UrlBar::UrlBar(KHistoryComboBox *parent)
{
m_lineEdit = new QLineEdit;
setLineEdit( m_lineEdit );
-
+
+ m_defaultBaseColor = palette().color( QPalette::Base );
+
// add every item to history
- connect( this, SIGNAL( activated( const QString& )), this, SLOT( addToHistory( const QString& )));
+ connect( this, SIGNAL( activated( const QString& ) ), this, SLOT( addToHistory( const QString& ) ) );
webViewIconChanged();
}
+
UrlBar::~UrlBar()
{
}
+
QLineEdit *UrlBar::lineEdit()
{
return m_lineEdit;
}
+
void UrlBar::setWebView(WebView *webView)
{
Q_ASSERT(!m_webView);
@@ -61,6 +67,7 @@ void UrlBar::setWebView(WebView *webView)
}
+
void UrlBar::webViewUrlChanged(const QUrl &url)
{
m_lineEdit->setText(url.toString());
@@ -68,6 +75,7 @@ void UrlBar::webViewUrlChanged(const QUrl &url)
}
+
void UrlBar::webViewIconChanged()
{
KUrl url = (m_webView) ? m_webView->url() : KUrl();
@@ -91,3 +99,34 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const
gradient.setColorAt(1, m_defaultBaseColor);
return gradient;
}
+
+
+void UrlBar::paintEvent( QPaintEvent *event )
+{
+ QPalette p = palette();
+ if (m_webView && m_webView->url().scheme() == QLatin1String("https"))
+ {
+ QColor lightYellow(248, 248, 210);
+ p.setBrush(QPalette::Base, generateGradient(lightYellow));
+ }
+ else
+ {
+ p.setBrush(QPalette::Base, m_defaultBaseColor);
+ }
+ setPalette(p);
+ KHistoryComboBox::paintEvent(event);
+
+ QPainter painter( this );
+ QRect backgroundRect = m_lineEdit->frameGeometry(); // contentsRect();
+ if ( m_webView && !hasFocus() )
+ {
+ int progress = m_webView->progress();
+ QColor loadingColor = QColor(116, 192, 250);
+ painter.setBrush( generateGradient(loadingColor) );
+ painter.setPen(Qt::transparent);
+ int mid = backgroundRect.width() / 100 * progress;
+ QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
+ painter.drawRect(progressRect);
+ }
+}
+
diff --git a/src/urlbar.h b/src/urlbar.h
index fcebc6f9..a670fca6 100644
--- a/src/urlbar.h
+++ b/src/urlbar.h
@@ -45,6 +45,9 @@ private slots:
void webViewUrlChanged(const QUrl &url);
void webViewIconChanged();
+protected:
+ void paintEvent( QPaintEvent * );
+
private:
QLinearGradient generateGradient(const QColor &color) const;