summaryrefslogtreecommitdiff
path: root/src/test/rview_fake.cpp
blob: bb7e91d61e49f2eb4d8a7ca2a0929a01fa1d99cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()};
}