mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Make it so when you open the GUI, all of the persistent tabs automatically open as well
This commit is contained in:
parent
a5f8fee065
commit
7819a894be
@ -383,6 +383,9 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
||||
# Update the file list
|
||||
self.file_list.update()
|
||||
|
||||
# Save the latest file list to mode settings
|
||||
self.save_filenames()
|
||||
|
||||
def add(self):
|
||||
"""
|
||||
Add button clicked.
|
||||
@ -452,6 +455,25 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
||||
"""
|
||||
return len(range(self.file_list.count()))
|
||||
|
||||
def get_filenames(self):
|
||||
"""
|
||||
Return the list of file and folder names
|
||||
"""
|
||||
filenames = []
|
||||
for index in range(self.file_list.count()):
|
||||
filenames.append(self.file_list.item(index).filename)
|
||||
return filenames
|
||||
|
||||
def save_filenames(self):
|
||||
"""
|
||||
Save the filenames to mode settings
|
||||
"""
|
||||
filenames = self.get_filenames()
|
||||
if self.parent.tab.mode == self.common.gui.MODE_SHARE:
|
||||
self.parent.settings.set("share", "filenames", filenames)
|
||||
elif self.parent.tab.mode == self.common.gui.MODE_WEBSITE:
|
||||
self.parent.settings.set("website", "filenames", filenames)
|
||||
|
||||
def setFocus(self):
|
||||
"""
|
||||
Set the Qt app focus on the file selection box.
|
||||
|
@ -204,9 +204,7 @@ class ShareMode(Mode):
|
||||
"""
|
||||
# Add progress bar to the status bar, indicating the compressing of files.
|
||||
self._zip_progress_bar = ZipProgressBar(self.common, 0)
|
||||
self.filenames = []
|
||||
for index in range(self.file_selection.file_list.count()):
|
||||
self.filenames.append(self.file_selection.file_list.item(index).filename)
|
||||
self.filenames = self.file_selection.get_filenames()
|
||||
|
||||
self._zip_progress_bar.total_files_size = ShareMode._compute_total_size(
|
||||
self.filenames
|
||||
|
@ -138,15 +138,18 @@ class Tab(QtWidgets.QWidget):
|
||||
)
|
||||
self.persistent_image_label.setFixedSize(20, 20)
|
||||
|
||||
def init(self, mode_settings=None):
|
||||
if mode_settings:
|
||||
# Load this tab
|
||||
self.settings = mode_settings
|
||||
mode = self.settings.get("persistent", "mode")
|
||||
if mode == "share":
|
||||
self.filenames = self.settings.get("share", "filenames")
|
||||
self.share_mode_clicked()
|
||||
elif mode == "receive":
|
||||
self.receive_mode_clicked()
|
||||
elif mode == "website":
|
||||
self.filenames = self.settings.get("website", "filenames")
|
||||
self.website_mode_clicked()
|
||||
else:
|
||||
# This is a new tab
|
||||
|
@ -40,7 +40,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
||||
|
||||
# Keep track of tabs in a dictionary
|
||||
self.tabs = {}
|
||||
self.tab_id = 0 # each tab has a unique id
|
||||
self.current_tab_id = 0 # Each tab has a unique id
|
||||
|
||||
# Define the new tab button
|
||||
self.new_tab_button = QtWidgets.QPushButton("+", parent=self)
|
||||
@ -88,31 +88,29 @@ class TabWidget(QtWidgets.QTabWidget):
|
||||
|
||||
def new_tab_clicked(self):
|
||||
# Create a new tab
|
||||
tab = Tab(self.common, self.tab_id, self.system_tray, self.status_bar)
|
||||
self.add_tab(tab)
|
||||
self.add_tab()
|
||||
|
||||
def load_tab(self, mode_settings_id):
|
||||
# Load the tab's mode settings
|
||||
mode_settings = ModeSettings(self.common, id=mode_settings_id)
|
||||
tab = Tab(
|
||||
self.common,
|
||||
self.tab_id,
|
||||
self.system_tray,
|
||||
self.status_bar,
|
||||
mode_settings=mode_settings,
|
||||
)
|
||||
self.add_tab(tab)
|
||||
self.add_tab(mode_settings)
|
||||
|
||||
def add_tab(self, tab):
|
||||
def add_tab(self, mode_settings=None):
|
||||
tab = Tab(self.common, self.current_tab_id, self.system_tray, self.status_bar)
|
||||
tab.change_title.connect(self.change_title)
|
||||
tab.change_icon.connect(self.change_icon)
|
||||
tab.change_persistent.connect(self.change_persistent)
|
||||
self.tabs[self.tab_id] = tab
|
||||
self.tab_id += 1
|
||||
|
||||
index = self.addTab(tab, "New Tab")
|
||||
self.tabs[self.current_tab_id] = tab
|
||||
self.current_tab_id += 1
|
||||
|
||||
index = self.addTab(tab, strings._("gui_new_tab"))
|
||||
self.setCurrentIndex(index)
|
||||
|
||||
tab.init(mode_settings)
|
||||
# If it's persistent, set the persistent image in the tab
|
||||
self.change_persistent(tab.tab_id, tab.settings.get("persistent", "enabled"))
|
||||
|
||||
def change_title(self, tab_id, title):
|
||||
index = self.indexOf(self.tabs[tab_id])
|
||||
self.setTabText(index, title)
|
||||
|
Loading…
Reference in New Issue
Block a user