diff options
| author | Andrea Diamantini <adjam7@gmail.com> | 2008-12-12 11:33:42 +0100 | 
|---|---|---|
| committer | Andrea Diamantini <adjam7@gmail.com> | 2008-12-12 11:33:42 +0100 | 
| commit | c69985e1cd542a73051c84457e61986a15b7b586 (patch) | |
| tree | 63a3e22062eb0a5b8430a131cd8a3575b640dabc /src | |
| parent | ( SHIFT + ) CTRL + TAB switching. Finally!! (diff) | |
| download | rekonq-c69985e1cd542a73051c84457e61986a15b7b586.tar.xz | |
1st implementation of colored progress loading urlbar
Diffstat (limited to 'src')
| -rw-r--r-- | src/urlbar.cpp | 43 | ||||
| -rw-r--r-- | src/urlbar.h | 3 | 
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; | 
