aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/WebViewStack.hpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-20 22:10:57 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-20 22:10:57 +0530
commitfdeb33d34a97d062a120f72da919f81d7b1d45bf (patch)
tree91165d5e3e718d4008bf73259f45d1705965f4b0 /src/widgets/WebViewStack.hpp
parent9e3474b5d8ee4afdd9c03cfb4a151ffebfca36b7 (diff)
downloadnull-browser-fdeb33d34a97d062a120f72da919f81d7b1d45bf.tar.gz
null-browser-fdeb33d34a97d062a120f72da919f81d7b1d45bf.zip
Move header files to src
Diffstat (limited to 'src/widgets/WebViewStack.hpp')
-rw-r--r--src/widgets/WebViewStack.hpp55
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;
+};