blob: 473f6997ac74d1b7b18acb2ab6031bd6caab4a56 (
plain) (
blame)
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
|
#pragma once
#include <QStackedLayout>
#include <QWebEngineProfile>
#include <vector>
#include "Configuration.hpp"
#include "widgets/WebView.hpp"
enum OpenType { OpenUrl, OpenUrlInTab, OpenUrlInBgTab, OpenUrlInWindow };
struct Tab {
QString url;
QString title;
};
class WebViewStack : public QWidget {
Q_OBJECT
public:
inline static const QUrl NewtabURL = QUrl("about:blank");
public:
WebViewStack(const Configuration *configuration,
QWebEngineProfile *profile = new QWebEngineProfile,
QWidget *parent = nullptr);
void openUrl(QUrl url, OpenType openType = OpenType::OpenUrl);
std::vector<QUrl> urls();
QList<Tab> getTabList();
u_int32_t currentWebViewIndex();
u_int32_t count();
QUrl currentUrl();
void focusWebView(int32_t index);
void next();
void previous();
void close(int32_t index);
void closeCurrent();
private:
void setCurrentUrl(QUrl url);
WebView *createNewWebView(QUrl url, bool focus = false);
private slots:
void onNewWebViewRequest(const QWebEngineNewWindowRequest &request);
private:
const Configuration *configuration;
QWebEngineProfile *profile;
QStackedLayout *layout;
QList<WebView *> webViewList;
};
|