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
|
#pragma once
#include "WebViewData.hpp"
#include "widgets/EdgeDecoration.hpp"
#include "widgets/IWebViewMediator.hpp"
#include <QWidget>
#include <QtCore>
#include <optional>
#include <qwebengineprofile.h>
/// @see DecorationType in ./lua/null-browser/api.lua
enum DecorationType : uint8_t {
DecorationTop = 1,
DecorationBottom = 2,
DecorationLeft = 3,
DecorationRight = 4,
};
class Decorations : public QWidget, public IWebViewMediator {
Q_OBJECT
public:
Decorations(QWidget *content_widget, QWebEngineProfile *profile, QWidget *parent = nullptr);
void set_enabled(DecorationType type, bool enabled);
bool get_enabled(DecorationType type);
std::optional<WebViewId> get_view_id(DecorationType type);
bool has_webview(WebViewId view_id) override;
void open_url(const QUrl &url, OpenType /*unused*/, WebViewId view_id) override;
void set_html(const QString &html, WebViewId view_id) override;
private:
EdgeDecoration *decoration_top;
EdgeDecoration *decoration_bottom;
EdgeDecoration *decoration_left;
EdgeDecoration *decoration_right;
std::vector<EdgeDecoration *> decorations() {
return {
decoration_top,
decoration_bottom,
decoration_left,
decoration_right,
};
}
std::optional<EdgeDecoration *> get_decoration_widget_type(DecorationType type);
std::optional<EdgeDecoration *> get_decoration_widget_by_view_id(WebViewId view_id);
};
|