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