From bbde1438e9c31cc83d8c4835ea97a0eaeae4e192 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 5 Apr 2025 23:45:55 +0530 Subject: Close window when no tabs left --- src/widgets/BrowserWindow.cpp | 3 ++- src/widgets/WebViewStack.cpp | 11 +++++------ src/widgets/WebViewStack.hpp | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/BrowserWindow.cpp b/src/widgets/BrowserWindow.cpp index aad551d..f1b786b 100644 --- a/src/widgets/BrowserWindow.cpp +++ b/src/widgets/BrowserWindow.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "Configuration.hpp" #include "WindowMediator.hpp" @@ -10,7 +11,7 @@ #include "widgets/WebViewStack.hpp" BrowserWindow::BrowserWindow(const Configuration &configuration, const QStringList &urls) - : configuration(configuration) { + : QMainWindow(nullptr), configuration(configuration) { setCentralWidget(new QWidget()); // Root stacked layout diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp index ae95ea6..8c432f1 100644 --- a/src/widgets/WebViewStack.cpp +++ b/src/widgets/WebViewStack.cpp @@ -125,13 +125,12 @@ void WebViewStack::close(WebViewId webview_id) { disconnect(webview->page()); webview->deleteLater(); - // TODO: Focus on different webview - // focus_webview(); - - // TODO: Close window on empty if (webview_list.isEmpty()) { - // window()->close(); - create_new_webview(configuration->new_tab_url, true); + if (configuration->close_window_when_no_tabs) { + emit close_window_requested(); + } else { + create_new_webview(configuration->new_tab_url, true); + } } } diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp index 23b9382..7cc2143 100644 --- a/src/widgets/WebViewStack.hpp +++ b/src/widgets/WebViewStack.hpp @@ -47,6 +47,7 @@ public: signals: void current_webview_title_changed(int index); void new_window_requested(const QUrl &url); + void close_window_requested(); protected: void set_current_url(const QUrl &url); -- cgit v1.3.1