Open a new tab to begin with, and open a new tab when the last tab is closed

This commit is contained in:
Micah Lee 2019-10-27 15:04:04 -07:00
parent df658a0e70
commit bbc26473c4
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 6 additions and 5 deletions

View File

@ -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()

View File

@ -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)