diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/application.cpp | 17 | ||||
-rw-r--r-- | src/rekonqwindow.cpp | 3 | ||||
-rw-r--r-- | src/test/rview_fake.cpp | 56 | ||||
-rw-r--r-- | src/test/rview_fake.h | 24 | ||||
-rw-r--r-- | src/test/rview_fake.ui | 135 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 43 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 4 |
8 files changed, 254 insertions, 31 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d46537e9..75905f36 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,9 @@ set(rekonq_SRCS plugins/rplugininterface.hpp #---------------------------------------- ) +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + list(APPEND rekonq_SRCS test/rview_fake.cpp test/rview_fake.h test/rview_fake.ui) +endif() list(TRANSFORM rekonq_SRCS PREPEND src/) set(rekonq_SRCS ${rekonq_SRCS} PARENT_SCOPE) diff --git a/src/application.cpp b/src/application.cpp index aba1fc69..88466d73 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -20,6 +20,10 @@ #include <QStandardPaths> #include <spdlog/spdlog.h> +#ifdef QT_DEBUG +#include "test/rview_fake.h" +#endif + // --------------------------------------------------------------------------------------------------------------- // Ctor and Dtor @@ -383,6 +387,19 @@ RekonqWindow *Application::newWindow() RekonqView *Application::newView(const QUrl &url, RekonqWindow *window) { +#ifdef QT_DEBUG + if (url.isEmpty()) { + auto *view = new RekonqView_fake(window); + if (window == nullptr) { + m_views.append(view); + view->show(); + } + else + window->addView(view); + return view; + } +#endif + RekonqPluginInterface *interface = nullptr; for (const auto &plugin : m_plugins) if (plugin->hasScheme(url.scheme())) { diff --git a/src/rekonqwindow.cpp b/src/rekonqwindow.cpp index dff85dfb..34a8f5b5 100644 --- a/src/rekonqwindow.cpp +++ b/src/rekonqwindow.cpp @@ -34,8 +34,7 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re [this]() { (new SettingsDialog(Application::instance()->settings(), this))->show(); }); connect(ui->actionTaskManager, &QAction::triggered, this, [this]() { (new TaskManager(this))->show(); }); - connect(ui->newTab, &QToolButton::clicked, this, - [this]() { Application::instance()->newView(QUrl("http://duckduckgo.com"), this); }); + connect(ui->newTab, &QToolButton::clicked, this, [this]() { Application::instance()->newView(QUrl(), this); }); } RekonqWindow::~RekonqWindow() { delete ui; } diff --git a/src/test/rview_fake.cpp b/src/test/rview_fake.cpp new file mode 100644 index 00000000..bb7e91d6 --- /dev/null +++ b/src/test/rview_fake.cpp @@ -0,0 +1,56 @@ +#include "rview_fake.h" +#include "ui_rview_fake.h" +#include <source_location> +#include <spdlog/spdlog.h> + +RekonqView_fake::RekonqView_fake(QWidget *parent) : RekonqView(QUrl(), parent), ui(new Ui::RekonqView_fake) +{ + ui->setupUi(this); + + connect(ui->progress, &QSlider::valueChanged, this, [this](int value) { + switch (value) { + case 1: + emit loadStarted(); + spdlog::debug("RekonqView_fake loadStarted"); + break; + case 0: + case 100: + emit loadFinished(); + spdlog::debug("RekonqView_fake loadFinished"); + break; + default: + emit loadProgress(value); + break; + } + }); + connect(ui->setTitle, &QToolButton::clicked, this, [this]() { emit titleChanged(ui->title->text()); }); + connect(ui->setUrl, &QToolButton::clicked, this, [this]() { emit urlChanged(QUrl(ui->url->text())); }); +} +RekonqView_fake::~RekonqView_fake() { delete ui; } + +void RekonqView_fake::load(const QUrl &url) +{ + ui->url->setText(url.toString()); + spdlog::debug("{} url={}", std::source_location::current().function_name(), qUtf8Printable(url.toString())); +} +int RekonqView_fake::progress() const +{ + spdlog::debug("{} -> {}", std::source_location::current().function_name(), ui->progress->value()); + return ui->progress->value(); +} + +QIcon RekonqView_fake::icon() const +{ + spdlog::debug("{} -> empty QIcon", std::source_location::current().function_name()); + return {}; +} +QString RekonqView_fake::title() const +{ + spdlog::debug("{} -> {}", std::source_location::current().function_name(), qUtf8Printable(ui->title->text())); + return ui->title->text(); +} +QUrl RekonqView_fake::url() const +{ + spdlog::debug("{} -> {}", std::source_location::current().function_name(), qUtf8Printable(ui->url->text())); + return {ui->url->text()}; +} diff --git a/src/test/rview_fake.h b/src/test/rview_fake.h new file mode 100644 index 00000000..64a8351d --- /dev/null +++ b/src/test/rview_fake.h @@ -0,0 +1,24 @@ +#pragma once + +#include <rview.hpp> + +namespace Ui { +class RekonqView_fake; +} +class RekonqView_fake final : public RekonqView { + Q_OBJECT + +public: + explicit RekonqView_fake(QWidget *parent = nullptr); + ~RekonqView_fake() override; + + void load(const QUrl &url) override; + int progress() const override; + + QIcon icon() const override; + QString title() const override; + QUrl url() const override; + +private: + Ui::RekonqView_fake *ui; +}; diff --git a/src/test/rview_fake.ui b/src/test/rview_fake.ui new file mode 100644 index 00000000..a97ac61e --- /dev/null +++ b/src/test/rview_fake.ui @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>RekonqView_fake</class> + <widget class="QWidget" name="RekonqView_fake"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="palette"> + <palette> + <active/> + <inactive/> + <disabled/> + </palette> + </property> + <property name="windowTitle"> + <string>RekonqView_fake</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Progress</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <item> + <widget class="QSlider" name="progress"> + <property name="maximum"> + <number>100</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Title</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>URL</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLineEdit" name="title"> + <property name="text"> + <string>RekonqView_fake</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="setTitle"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="url"> + <property name="text"> + <string>rekonq__debug</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="setUrl"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> 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; }; |