From fcd11edde50d65f272cfc1ebf211697d778af77e Mon Sep 17 00:00:00 2001 From: aqua Date: Tue, 23 Aug 2022 10:28:54 +0300 Subject: Add RekonqView_fake class --- src/urlbar/urlbar.cpp | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) (limited to 'src/urlbar/urlbar.cpp') diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 67d77aa4..d9059833 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -47,10 +47,8 @@ QString guessUrlWithCustomFirstLevel(const QString &str1, const QString &str2) // ----------------------------------------------------------------------------------------------------------- UrlBar::UrlBar(QWidget *parent) - : QLineEdit(parent) - //, _box(new CompletionWidget(this)) - , - _icon(new IconButton(this)) + : QLineEdit(parent), _icon(new IconButton(this)), backgroundColor{qApp->palette().color(QPalette::Base)}, + highlightColor{qApp->palette().color(QPalette::Highlight)} { // set initial icon @@ -134,7 +132,8 @@ void UrlBar::loadRequestedUrl(const QUrl &url, rekonq::OpenType type) void UrlBar::loadStarted() { if (sender() != m_currentView) return; - //_icon->setIcon(QIcon("text-html")); + m_currentView_progress = 1; + _icon->setIcon(QIcon::fromTheme("text-html")); // clearRightIcons(); repaint(); @@ -143,12 +142,14 @@ void UrlBar::loadStarted() void UrlBar::loadProgress(int progress) { if (sender() != m_currentView) return; + m_currentView_progress = progress; repaint(); } void UrlBar::loadFinished() { if (sender() != m_currentView) return; + m_currentView_progress = 100; // refreshFavicon(); // updateRightIcons(); @@ -162,44 +163,28 @@ void UrlBar::paintEvent(QPaintEvent *event) { if (!m_currentView) return QLineEdit::paintEvent(event); - const auto backgroundColor = qApp->palette().color(QPalette::Base); - const auto foregroundColor = qApp->palette().color(QPalette::Text); - - /*if (_tab->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) - { - backgroundColor = QColor(220, 220, 220); // light gray - foregroundColor = Qt::black; - } - else*/ - // set background color of UrlBar QPalette p = palette(); - const int progress = m_currentView->progress(); - if (progress == 0 || progress == 100) { - p.setBrush(QPalette::Base, backgroundColor); - p.setBrush(QPalette::Text, foregroundColor); - } + if (m_currentView_progress == 0 || m_currentView_progress == 100) p.setBrush(QPalette::Base, backgroundColor); else { - QColor highlight = qApp->palette().color(QPalette::Highlight); - - int r = (highlight.red() + 2 * backgroundColor.red()) / 3; - int g = (highlight.green() + 2 * backgroundColor.green()) / 3; - int b = (highlight.blue() + 2 * backgroundColor.blue()) / 3; + int r = (highlightColor.red() + 2 * backgroundColor.red()) / 3; + int g = (highlightColor.green() + 2 * backgroundColor.green()) / 3; + int b = (highlightColor.blue() + 2 * backgroundColor.blue()) / 3; QColor loadingColor(r, g, b); if (abs(loadingColor.lightness() - backgroundColor.lightness()) < 20) // eg. Gaia color scheme { - r = (2 * highlight.red() + backgroundColor.red()) / 3; - g = (2 * highlight.green() + backgroundColor.green()) / 3; - b = (2 * highlight.blue() + backgroundColor.blue()) / 3; + r = (2 * highlightColor.red() + backgroundColor.red()) / 3; + g = (2 * highlightColor.green() + backgroundColor.green()) / 3; + b = (2 * highlightColor.blue() + backgroundColor.blue()) / 3; loadingColor = QColor(r, g, b); } QLinearGradient gradient(0, 0, width(), 0); gradient.setColorAt(0, backgroundColor); - gradient.setColorAt(((double)progress) / 100 - .000001, loadingColor); + gradient.setColorAt(((double)m_currentView_progress) / 100, loadingColor); gradient.setColorAt(1, loadingColor); p.setBrush(QPalette::Base, gradient); } -- cgit v1.2.1