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/test | |
parent | Add UrlBar and TabBar (diff) | |
download | rekonq-fcd11edde50d65f272cfc1ebf211697d778af77e.tar.xz |
Add RekonqView_fake class
Diffstat (limited to 'src/test')
-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 |
3 files changed, 215 insertions, 0 deletions
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> |