diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-08-23 10:28:54 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-09-05 23:07:42 +0300 |
commit | fcd11edde50d65f272cfc1ebf211697d778af77e (patch) | |
tree | 225b1aeb2245dbdb1da018a6bf01c06c7e2d3869 /src/urlbar | |
parent | Add UrlBar and TabBar (diff) | |
download | rekonq-fcd11edde50d65f272cfc1ebf211697d778af77e.tar.xz |
Add RekonqView_fake class
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/urlbar.cpp | 43 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 4 |
2 files changed, 18 insertions, 29 deletions
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); } diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index 80aabedf..cdfcc14f 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -111,7 +111,11 @@ private: // QWeakPointer<CompletionWidget> _box; RekonqView *m_currentView = nullptr; + int m_currentView_progress = 0; IconButton *_icon; IconButtonPointerList _rightIconsList; + + const QColor backgroundColor; + const QColor highlightColor; }; |