aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-04-05 23:45:55 +0530
committerAkshay Nair <phenax5@gmail.com>2025-04-06 00:47:02 +0530
commitbbde1438e9c31cc83d8c4835ea97a0eaeae4e192 (patch)
tree88840b73176dee8bd7da70c36f19a32bafdd5d6c /src/widgets
parentb77a6444f94ce8d05962af9039c31851e224be5c (diff)
downloadnull-browser-bbde1438e9c31cc83d8c4835ea97a0eaeae4e192.tar.gz
null-browser-bbde1438e9c31cc83d8c4835ea97a0eaeae4e192.zip
Close window when no tabs left
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/BrowserWindow.cpp3
-rw-r--r--src/widgets/WebViewStack.cpp11
-rw-r--r--src/widgets/WebViewStack.hpp1
3 files changed, 8 insertions, 7 deletions
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 <QStackedLayout>
#include <QVBoxLayout>
#include <QtCore>
+#include <qmainwindow.h>
#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);