Add persistent pin

This commit is contained in:
Micah Lee 2019-10-27 15:52:45 -07:00
parent 656d3d1564
commit 216fbd4e87
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
5 changed files with 51 additions and 13 deletions

View File

@ -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"))
)

View File

@ -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:

View File

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB