diff --git a/onionshare_gui/main_window.py b/onionshare_gui/main_window.py index 6d8f034d..c2db80ec 100644 --- a/onionshare_gui/main_window.py +++ b/onionshare_gui/main_window.py @@ -77,6 +77,17 @@ class MainWindow(QtWidgets.QMainWindow): self.status_bar.setStyleSheet(self.common.gui.css["status_bar"]) self.setStatusBar(self.status_bar) + # Server status indicator icons + self.status_bar.server_status_image_stopped = QtGui.QImage( + self.common.get_resource_path("images/server_stopped.png") + ) + self.status_bar.server_status_image_working = QtGui.QImage( + self.common.get_resource_path("images/server_working.png") + ) + self.status_bar.server_status_image_started = QtGui.QImage( + self.common.get_resource_path("images/server_started.png") + ) + # Server status indicator on the status bar self.status_bar.server_status_image_label = QtWidgets.QLabel() self.status_bar.server_status_image_label.setFixedWidth(20) @@ -98,8 +109,7 @@ class MainWindow(QtWidgets.QMainWindow): # Settings button self.settings_button = QtWidgets.QPushButton() self.settings_button.setDefault(False) - self.settings_button.setFixedWidth(40) - self.settings_button.setFixedHeight(50) + self.settings_button.setFixedSize(40, 50) self.settings_button.setIcon( QtGui.QIcon(self.common.get_resource_path("images/settings.png")) ) diff --git a/onionshare_gui/tab/tab.py b/onionshare_gui/tab/tab.py index 8cdf3afa..a164a96d 100644 --- a/onionshare_gui/tab/tab.py +++ b/onionshare_gui/tab/tab.py @@ -103,17 +103,6 @@ class Tab(QtWidgets.QWidget): self.new_tab.setLayout(new_tab_outer_layout) self.new_tab.show() - # Server status indicator icons - self.status_bar.server_status_image_stopped = QtGui.QImage( - self.common.get_resource_path("images/server_stopped.png") - ) - self.status_bar.server_status_image_working = QtGui.QImage( - self.common.get_resource_path("images/server_working.png") - ) - self.status_bar.server_status_image_started = QtGui.QImage( - self.common.get_resource_path("images/server_started.png") - ) - # Layout self.layout = QtWidgets.QVBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) @@ -127,6 +116,17 @@ class Tab(QtWidgets.QWidget): self.timer = QtCore.QTimer() self.timer.timeout.connect(self.timer_callback) + # Settings for this tab + self.tab_settings = {"persistence": False} + + # Persistence button + self.persistence_button = QtWidgets.QPushButton() + self.persistence_button.setDefault(False) + self.persistence_button.setFlat(True) + self.persistence_button.setFixedSize(30, 30) + self.persistence_button.clicked.connect(self.persistence_button_clicked) + self.update_persistence_button() + def share_mode_clicked(self): self.common.log("Tab", "share_mode_clicked") self.mode = self.common.gui.MODE_SHARE @@ -500,6 +500,29 @@ class Tab(QtWidgets.QWidget): """ self.status_bar.clearMessage() + def persistence_button_clicked(self): + self.common.log("Tab", "persistence_button_clicked") + if self.tab_settings["persistence"]: + self.tab_settings["persistence"] = False + else: + self.tab_settings["persistence"] = True + self.update_persistence_button() + + def update_persistence_button(self): + self.common.log("Tab", "update_persistence_button") + if self.tab_settings["persistence"]: + self.persistence_button.setIcon( + QtGui.QIcon( + self.common.get_resource_path("images/persistent_enabled.png") + ) + ) + else: + self.persistence_button.setIcon( + QtGui.QIcon( + self.common.get_resource_path("images/persistent_disabled.png") + ) + ) + def close_tab(self): self.common.log("Tab", "close_tab") if self.mode is None: diff --git a/onionshare_gui/tab_widget.py b/onionshare_gui/tab_widget.py index 189c742f..73dea2bd 100644 --- a/onionshare_gui/tab_widget.py +++ b/onionshare_gui/tab_widget.py @@ -100,6 +100,11 @@ class TabWidget(QtWidgets.QTabWidget): index = self.indexOf(self.tabs[tab_id]) self.setTabText(index, title) + # Now that a mode has been selected, add persistence button + self.tabBar().setTabButton( + index, QtWidgets.QTabBar.LeftSide, self.tabs[tab_id].persistence_button + ) + def close_tab(self, index): self.common.log("TabWidget", "close_tab", f"{index}") tab = self.widget(index) diff --git a/share/images/persistent_disabled.png b/share/images/persistent_disabled.png new file mode 100644 index 00000000..2f2e34ab Binary files /dev/null and b/share/images/persistent_disabled.png differ diff --git a/share/images/persistent_enabled.png b/share/images/persistent_enabled.png new file mode 100644 index 00000000..68a5a74f Binary files /dev/null and b/share/images/persistent_enabled.png differ