mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-17 13:02:42 -05: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
|
# Update the file list
|
||||||
self.file_list.update()
|
self.file_list.update()
|
||||||
|
|
||||||
|
# Save the latest file list to mode settings
|
||||||
|
self.save_filenames()
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
"""
|
"""
|
||||||
Add button clicked.
|
Add button clicked.
|
||||||
@ -452,6 +455,25 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
|||||||
"""
|
"""
|
||||||
return len(range(self.file_list.count()))
|
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):
|
def setFocus(self):
|
||||||
"""
|
"""
|
||||||
Set the Qt app focus on the file selection box.
|
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.
|
# Add progress bar to the status bar, indicating the compressing of files.
|
||||||
self._zip_progress_bar = ZipProgressBar(self.common, 0)
|
self._zip_progress_bar = ZipProgressBar(self.common, 0)
|
||||||
self.filenames = []
|
self.filenames = self.file_selection.get_filenames()
|
||||||
for index in range(self.file_selection.file_list.count()):
|
|
||||||
self.filenames.append(self.file_selection.file_list.item(index).filename)
|
|
||||||
|
|
||||||
self._zip_progress_bar.total_files_size = ShareMode._compute_total_size(
|
self._zip_progress_bar.total_files_size = ShareMode._compute_total_size(
|
||||||
self.filenames
|
self.filenames
|
||||||
|
@ -138,15 +138,18 @@ class Tab(QtWidgets.QWidget):
|
|||||||
)
|
)
|
||||||
self.persistent_image_label.setFixedSize(20, 20)
|
self.persistent_image_label.setFixedSize(20, 20)
|
||||||
|
|
||||||
|
def init(self, mode_settings=None):
|
||||||
if mode_settings:
|
if mode_settings:
|
||||||
# Load this tab
|
# Load this tab
|
||||||
self.settings = mode_settings
|
self.settings = mode_settings
|
||||||
mode = self.settings.get("persistent", "mode")
|
mode = self.settings.get("persistent", "mode")
|
||||||
if mode == "share":
|
if mode == "share":
|
||||||
|
self.filenames = self.settings.get("share", "filenames")
|
||||||
self.share_mode_clicked()
|
self.share_mode_clicked()
|
||||||
elif mode == "receive":
|
elif mode == "receive":
|
||||||
self.receive_mode_clicked()
|
self.receive_mode_clicked()
|
||||||
elif mode == "website":
|
elif mode == "website":
|
||||||
|
self.filenames = self.settings.get("website", "filenames")
|
||||||
self.website_mode_clicked()
|
self.website_mode_clicked()
|
||||||
else:
|
else:
|
||||||
# This is a new tab
|
# This is a new tab
|
||||||
|
@ -40,7 +40,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
|
|
||||||
# Keep track of tabs in a dictionary
|
# Keep track of tabs in a dictionary
|
||||||
self.tabs = {}
|
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
|
# Define the new tab button
|
||||||
self.new_tab_button = QtWidgets.QPushButton("+", parent=self)
|
self.new_tab_button = QtWidgets.QPushButton("+", parent=self)
|
||||||
@ -88,31 +88,29 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
|
|
||||||
def new_tab_clicked(self):
|
def new_tab_clicked(self):
|
||||||
# Create a new tab
|
# Create a new tab
|
||||||
tab = Tab(self.common, self.tab_id, self.system_tray, self.status_bar)
|
self.add_tab()
|
||||||
self.add_tab(tab)
|
|
||||||
|
|
||||||
def load_tab(self, mode_settings_id):
|
def load_tab(self, mode_settings_id):
|
||||||
# Load the tab's mode settings
|
# Load the tab's mode settings
|
||||||
mode_settings = ModeSettings(self.common, id=mode_settings_id)
|
mode_settings = ModeSettings(self.common, id=mode_settings_id)
|
||||||
tab = Tab(
|
self.add_tab(mode_settings)
|
||||||
self.common,
|
|
||||||
self.tab_id,
|
|
||||||
self.system_tray,
|
|
||||||
self.status_bar,
|
|
||||||
mode_settings=mode_settings,
|
|
||||||
)
|
|
||||||
self.add_tab(tab)
|
|
||||||
|
|
||||||
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_title.connect(self.change_title)
|
||||||
tab.change_icon.connect(self.change_icon)
|
tab.change_icon.connect(self.change_icon)
|
||||||
tab.change_persistent.connect(self.change_persistent)
|
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)
|
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):
|
def change_title(self, tab_id, title):
|
||||||
index = self.indexOf(self.tabs[tab_id])
|
index = self.indexOf(self.tabs[tab_id])
|
||||||
self.setTabText(index, title)
|
self.setTabText(index, title)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user