From bbc26473c4efca9c584c39fa566f2574b0da8af4 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 27 Oct 2019 15:04:04 -0700 Subject: [PATCH] Open a new tab to begin with, and open a new tab when the last tab is closed --- onionshare_gui/main_window.py | 7 ++----- onionshare_gui/tab_widget.py | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/onionshare_gui/main_window.py b/onionshare_gui/main_window.py index 497fde62..b10333b5 100644 --- a/onionshare_gui/main_window.py +++ b/onionshare_gui/main_window.py @@ -98,14 +98,11 @@ class MainWindow(QtWidgets.QMainWindow): # Tabs self.tabs = TabWidget(self.common, self.system_tray, self.status_bar) - # Start with a tab - # new_tab = Tab(self.common, self.system_tray, self.status_bar, filenames) - # self.tabs.insertTab(0, new_tab, strings._("gui_new_tab")) - # self.tabs.setCurrentIndex(0) + # Start with opening the first tab + self.tabs.new_tab_clicked() # Layout layout = QtWidgets.QVBoxLayout() - # layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.tabs) central_widget = QtWidgets.QWidget() diff --git a/onionshare_gui/tab_widget.py b/onionshare_gui/tab_widget.py index 4a94743f..6207dde4 100644 --- a/onionshare_gui/tab_widget.py +++ b/onionshare_gui/tab_widget.py @@ -105,6 +105,10 @@ class TabWidget(QtWidgets.QTabWidget): self.removeTab(index) del self.tabs[tab.tab_id] + # If the last tab is closed, open a new one + if self.count() == 0: + self.new_tab_clicked() + def resizeEvent(self, event): # Make sure to move new tab button on each resize super(TabWidget, self).resizeEvent(event)