mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
After choosing the tab type, the title of the tab changes
This commit is contained in:
parent
4b4020c629
commit
fd2046b976
@ -38,11 +38,14 @@ class Tab(QtWidgets.QWidget):
|
||||
A GUI tab, you know, sort of like in a web browser
|
||||
"""
|
||||
|
||||
def __init__(self, common, system_tray, status_bar, filenames=None):
|
||||
change_title = QtCore.pyqtSignal(int, str)
|
||||
|
||||
def __init__(self, common, tab_id, system_tray, status_bar, filenames=None):
|
||||
super(Tab, self).__init__()
|
||||
self.common = common
|
||||
self.common.log("Tab", "__init__")
|
||||
|
||||
self.tab_id = tab_id
|
||||
self.system_tray = system_tray
|
||||
self.status_bar = status_bar
|
||||
self.filenames = filenames
|
||||
@ -173,6 +176,8 @@ class Tab(QtWidgets.QWidget):
|
||||
self.share_mode.server_status.hidservauth_copied.connect(self.copy_hidservauth)
|
||||
self.share_mode.set_server_active.connect(self.set_server_active)
|
||||
|
||||
self.change_title.emit(self.tab_id, strings._("gui_new_tab_share_button"))
|
||||
|
||||
self.update_server_status_indicator()
|
||||
self.timer.start(500)
|
||||
|
||||
@ -216,6 +221,8 @@ class Tab(QtWidgets.QWidget):
|
||||
)
|
||||
self.receive_mode.set_server_active.connect(self.set_server_active)
|
||||
|
||||
self.change_title.emit(self.tab_id, strings._("gui_new_tab_receive_button"))
|
||||
|
||||
self.update_server_status_indicator()
|
||||
self.timer.start(500)
|
||||
|
||||
@ -258,6 +265,8 @@ class Tab(QtWidgets.QWidget):
|
||||
)
|
||||
self.website_mode.set_server_active.connect(self.set_server_active)
|
||||
|
||||
self.change_title.emit(self.tab_id, strings._("gui_new_tab_website_button"))
|
||||
|
||||
self.update_server_status_indicator()
|
||||
self.timer.start(500)
|
||||
|
||||
|
@ -37,7 +37,11 @@ class TabWidget(QtWidgets.QTabWidget):
|
||||
self.system_tray = system_tray
|
||||
self.status_bar = status_bar
|
||||
|
||||
# Definte the new tab button
|
||||
# Keep track of tabs in a dictionary
|
||||
self.tabs = {}
|
||||
self.tab_id = 0 # each tab has a unique id
|
||||
|
||||
# Define the new tab button
|
||||
self.new_tab_button = QtWidgets.QPushButton("+", parent=self)
|
||||
self.new_tab_button.setFlat(True)
|
||||
self.new_tab_button.setAutoFillBackground(True)
|
||||
@ -83,11 +87,20 @@ class TabWidget(QtWidgets.QTabWidget):
|
||||
self.move_new_tab_button()
|
||||
|
||||
def new_tab_clicked(self):
|
||||
# Add a new tab
|
||||
tab = Tab(self.common, self.system_tray, self.status_bar)
|
||||
# Create the tab
|
||||
tab = Tab(self.common, self.tab_id, self.system_tray, self.status_bar)
|
||||
tab.change_title.connect(self.change_title)
|
||||
self.tabs[self.tab_id] = tab
|
||||
self.tab_id += 1
|
||||
|
||||
# Add it
|
||||
index = self.addTab(tab, "New Tab")
|
||||
self.setCurrentIndex(index)
|
||||
|
||||
def change_title(self, tab_id, title):
|
||||
index = self.indexOf(self.tabs[tab_id])
|
||||
self.setTabText(index, title)
|
||||
|
||||
|
||||
class TabBar(QtWidgets.QTabBar):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user