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/test/rview_fake.cpp | 56 ++++++++++++++++++++ src/test/rview_fake.h | 24 +++++++++ src/test/rview_fake.ui | 135 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 src/test/rview_fake.cpp create mode 100644 src/test/rview_fake.h create mode 100644 src/test/rview_fake.ui (limited to 'src/test') 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 +#include + +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 + +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 @@ + + + RekonqView_fake + + + + 0 + 0 + 400 + 300 + + + + + + + + + + + RekonqView_fake + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Progress + + + + 0 + + + 0 + + + 0 + + + + + 100 + + + Qt::Horizontal + + + + + + + + + + + + Title + + + + + + + URL + + + + + + + + + RekonqView_fake + + + + + + + ... + + + + + + + + + + + rekonq__debug + + + + + + + ... + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + -- cgit v1.2.1