diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-25 21:11:42 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-25 21:11:42 +0530 |
| commit | a54f6ae81b54ca59bf913bba16f271a35ca08d9d (patch) | |
| tree | d8e5be08f87cc2d90b984fc6a9e8323457785606 /src/widgets | |
| parent | 1284f8cf39e8ba44e837d4dac0bace89cb7a0c26 (diff) | |
| download | null-browser-a54f6ae81b54ca59bf913bba16f271a35ca08d9d.tar.gz null-browser-a54f6ae81b54ca59bf913bba16f271a35ca08d9d.zip | |
Add web.tabs.list and web.tabs.select + example for tab next/prev and selection ui
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/WebViewStack.cpp | 8 | ||||
| -rw-r--r-- | src/widgets/WebViewStack.hpp | 21 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp index 1d0a35e..fda4f28 100644 --- a/src/widgets/WebViewStack.cpp +++ b/src/widgets/WebViewStack.cpp @@ -50,10 +50,12 @@ WebView *WebViewStack::create_new_webview(const QUrl &url, bool focus) { return webview; } -QList<Tab> WebViewStack::get_webview_list() { - QList<Tab> urls; +QList<WebViewData> WebViewStack::get_webview_list() { + QList<WebViewData> urls; for (auto &view : webview_list) - urls.append(Tab{.url = view->url().toString(), .title = view->title()}); + urls.append(WebViewData{.id = view->get_id(), + .url = view->url().toString(), + .title = view->title()}); return urls; } diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp index 3c69888..b675af5 100644 --- a/src/widgets/WebViewStack.hpp +++ b/src/widgets/WebViewStack.hpp @@ -17,7 +17,8 @@ enum OpenType : uint8_t { OpenUrlInWindow }; -struct Tab { +struct WebViewData { + WebViewId id; QString url; QString title; }; @@ -31,29 +32,29 @@ public: QWidget *parent = nullptr); std::vector<QUrl> urls(); // TODO: Remove - QList<Tab> get_webview_list(); + QList<WebViewData> get_webview_list(); WebView *current_webview(); WebViewId current_webview_id(); uint32_t count(); QUrl current_url(); - WebView *get_webview(WebViewId webview_id); uint32_t current_webview_index(); -public slots: // NOLINT(readability-redundant-access-specifiers) +protected: + void set_current_url(const QUrl &url); + WebView *create_new_webview(const QUrl &url, bool focus = false); + int32_t get_webview_index(WebViewId webview_id); + WebView *get_webview(WebViewId webview_id); + +public slots: void open_url(const QUrl &url, OpenType open_type = OpenType::OpenUrl); void webview_history_back(WebViewId webview_id, qsizetype history_index); void webview_history_forward(WebViewId webview_id, qsizetype history_index); void close(WebViewId webview_id); void focus_webview(WebViewId webview_id); -private slots: +protected slots: void on_new_webview_request(const QWebEngineNewWindowRequest &request); -protected: - void set_current_url(const QUrl &url); - WebView *create_new_webview(const QUrl &url, bool focus = false); - int32_t get_webview_index(WebViewId webview_id); - private: const Configuration *configuration; QWebEngineProfile *profile; |
