diff options
Diffstat (limited to 'src/widgets/WebViewStack.hpp')
| -rw-r--r-- | src/widgets/WebViewStack.hpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp new file mode 100644 index 0000000..e5b7ecc --- /dev/null +++ b/src/widgets/WebViewStack.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include <QStackedLayout> +#include <QWebEngineProfile> +#include <sys/types.h> + +#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(long index); + void next(); + void previous(); + + void close(long index); + void closeCurrent(); + +private: + void setCurrentUrl(QUrl url); + WebView *createNewWebView(QUrl url, bool focus = false); + +private slots: + void onNewWebViewRequest(QWebEngineNewWindowRequest &request); + +private: + const Configuration *configuration; + QWebEngineProfile *profile; + QStackedLayout *layout; + QList<WebView *> webViewList; +}; |
