mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Add persistent pin
This commit is contained in:
parent
656d3d1564
commit
216fbd4e87
@ -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"))
|
||||
)
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
BIN
share/images/persistent_disabled.png
Normal file
BIN
share/images/persistent_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
share/images/persistent_enabled.png
Normal file
BIN
share/images/persistent_enabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
Loading…
Reference in New Issue
Block a user