From 216fbd4e87aee17ea614d6a8368731e0a553a383 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 27 Oct 2019 15:52:45 -0700 Subject: [PATCH] Add persistent pin --- onionshare_gui/main_window.py | 14 +++++++-- onionshare_gui/tab/tab.py | 45 ++++++++++++++++++++------- onionshare_gui/tab_widget.py | 5 +++ share/images/persistent_disabled.png | Bin 0 -> 1299 bytes share/images/persistent_enabled.png | Bin 0 -> 4368 bytes 5 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 share/images/persistent_disabled.png create mode 100644 share/images/persistent_enabled.png 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 0000000000000000000000000000000000000000..2f2e34ab2c484ab5666fb67ef7d68af1112a8bd7 GIT binary patch literal 1299 zcmV+u1?>8XP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U=K3lH@21h4-9dj$la$iQ`~?BKih%{CQx?S(#Pc z5!2I)S!5DvV_7`leX_GE^uK?M@E1Omo?C+3*BpyS8&xz2RNb-XV6zDLjT zaNl5r1ZTM}(~eU?Tpt50?)do}4_3F1Z=rqTLr~_-jLy#UEhK!!Xu4~eDT2a*yO10>&Vejgfn+H&h9isdj41kws~L~qdl&BRi+OkN#k-^IxI9}C zjPepe~yo8!X3pNt{ZL+LFatkf%os$5rlRZ41C6%&k}q2?!hsg-wYL zV>TlA=-^YZa+b&^2#_i_3Il9J65u$`xiQ9Q<+Ab>#;XM&RFW9b-~j@x7!~zn(NRN1 zMPpFaq^7P}OOh0mrj#trcT_R4XllvK+_DuHkFK8F+&z2AoCU8i%_&>Ro^vh*lNLx9 zj4sG1<>XV&cJN?XOsVJWstJYMldd;;oZqo4hx6~{&Z@HCD9i`M`*Pgm{@41(O zS{pLr(2<4>A9<9U+NSzUjb6z8ni_3tlUQ7N_MnEa*@pzp*NIMMAjXkE+$I4OG*4!S zQ;a;xO=d@CJQT{HMmpg%n#4dbc48fLvwM*HCAXmQUvcA~kqZ;upCA_|x=rpYw{NJm zvVKuy0h&+Y^z@K{7aJ0~7xprLlYaXg{;R-S=q>aXdJDaU-a>Do|BukX9}oCfGyDS} z^^rg05RH5Q000JJOGiWi{{a60|De66lK=n!32;bRa{vGf6951U69E94oEQKA00(qQ zO+^Re3L6$Q4%L+kfdBvjwMj%lR7l6Y)=g{FP!z`T-^{cYwQrzJbu1#Nh`1FhqAvUz zepkPM1y?QvTk9w~mP#$Pq8*KHP9T(Kl1!4G&4ruf{&U`*a|ep8hfO@gJjPnI!4&8t z+(91+e&C>Ma0boWb?oA#EAS@np0VG@8n(Lt7eO<-6zkVE!DZ0Qk^mpK0j>(o3U3|n zkTwB7#J!r|UBFU!J;aqbYf|-RdUz3Q8}<)h@TRN|23Ww=mcYG;#BHqLb5R5a@$h%# zt>2R33ehhYb|*H7F%_cYY(3Sez5`c)ht^5D{_+! zh*qIW!kOY@7f==QxKb1PI@+@_xL*_c98aqV(xBw|T!=wcXoAH!cihCIgOI_h(99m- zW)twFNC0w$)Gv_5$5@^<)bR6+aObP{FW$#l$tkCX(U$2f;Nz(7)smJO<2!ETBDoOX z?al%ggCq&<-J0^=VZ1ZUwbgRe$=>NP)`iXC2{v+jFT;Ua9@n)r7vA+)H)3znC0On@ zx*yQ_xSQ`F?HUY6G3&2Ip)F!`9^m|}U&1X+&I_F7eS|-_{~r@jV*rh3v5Wu!002ov JPDHLkV1n_-Xv+Wq literal 0 HcmV?d00001 diff --git a/share/images/persistent_enabled.png b/share/images/persistent_enabled.png new file mode 100644 index 0000000000000000000000000000000000000000..68a5a74f60280cc95948590c36b429689ae0703f GIT binary patch literal 4368 zcmV+r5%2DaP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3&scH26WhW}#~y#x$}0!lbz5ITPlAXj! z?oGaK>sX{A3Iu9+2RhjQ{Pzw2#gD|%gVfe_s78Kd$jFnE9$!DNV~X;;zy7fIXX(fB z@cBVzsBkQ=KlMGHCgb(n7n;1s*N@|&?e{$WJ<TL`8A&2e~0n@ z-jwgQ^ZqUEnd0-}uYXG;7^gB=a>!OviM;z4b72K#l<8x<=hCu|RL(0$f0tj!E_|MT z3Et<~m)OPm9xp$JB1C;(pkHG29#8exv3nx)L)O0C`G*f|M~mP8d>6ZWPruh*yPKj! zO2d0oA6t3OxNs55@_bEsHGV7S?RgDeoh@#He#qwHwL=;y6WN<2oix);_8fQGEK#y$ z!ku&8xjbW?@Q=Koq=>)L&5iV&P&&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