From 6c91d8977ac607a42f6245d62a8ad74c3d336418 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 23 Apr 2018 19:51:51 -0700 Subject: [PATCH] Begin to add the mode switcher (between "Share Files" and "Receive Files", with the settings button) --- onionshare_gui/onionshare_gui.py | 62 ++++++++++++++++++++++++++----- share/images/settings.png | Bin 411 -> 443 bytes share/locale/en.json | 4 +- 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index d5a0889a..b2327b45 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -46,6 +46,9 @@ class OnionShareGui(QtWidgets.QMainWindow): starting_server_step3 = QtCore.pyqtSignal() starting_server_error = QtCore.pyqtSignal(str) + MODE_SHARE = 'share' + MODE_RECEIVE = 'receive' + def __init__(self, common, web, onion, qtapp, app, filenames, config=False, local_only=False): super(OnionShareGui, self).__init__() @@ -60,6 +63,8 @@ class OnionShareGui(QtWidgets.QMainWindow): self.app = app self.local_only = local_only + self.mode = self.MODE_SHARE + self.setWindowTitle('OnionShare') self.setWindowIcon(QtGui.QIcon(self.common.get_resource_path('images/logo.png'))) self.setMinimumWidth(430) @@ -68,6 +73,43 @@ class OnionShareGui(QtWidgets.QMainWindow): self.config = config self.common.load_settings(self.config) + # Mode switcher, to switch between share files and receive files + self.mode_switcher_selected_style = """ + QPushButton { + color: #ffffff; + background-color: #4e064f; + border: 0; + border-right: 1px solid #69266b; + font-weight: bold; + border-radius: 0; + }""" + self.mode_switcher_unselected_style = """ + QPushButton { + color: #ffffff; + background-color: #601f61; + border: 0; + border-right: 1px solid #69266b; + font-weight: normal; + border-radius: 0; + }""" + self.share_mode_button = QtWidgets.QPushButton(strings._('gui_mode_share_button', True)); + self.share_mode_button.setFixedHeight(50) + self.receive_mode_button = QtWidgets.QPushButton(strings._('gui_mode_receive_button', True)); + self.receive_mode_button.setFixedHeight(50) + self.settings_button = QtWidgets.QPushButton() + self.settings_button.setDefault(False) + self.settings_button.setFixedWidth(40) + self.settings_button.setFixedHeight(50) + self.settings_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/settings.png')) ) + self.settings_button.clicked.connect(self.open_settings) + self.settings_button.setStyleSheet('QPushButton { background-color: #601f61; border: 0; border-radius: 0; }') + mode_switcher_layout = QtWidgets.QHBoxLayout(); + mode_switcher_layout.setSpacing(0) + mode_switcher_layout.addWidget(self.share_mode_button) + mode_switcher_layout.addWidget(self.receive_mode_button) + mode_switcher_layout.addWidget(self.settings_button) + self.update_mode_switcher() + # File selection self.file_selection = FileSelection(self.common) if filenames: @@ -142,14 +184,6 @@ class OnionShareGui(QtWidgets.QMainWindow): self.info_widget.setLayout(self.info_layout) self.info_widget.hide() - # Settings button on the status bar - self.settings_button = QtWidgets.QPushButton() - self.settings_button.setDefault(False) - self.settings_button.setFlat(True) - self.settings_button.setFixedWidth(40) - self.settings_button.setIcon( QtGui.QIcon(self.common.get_resource_path('images/settings.png')) ) - self.settings_button.clicked.connect(self.open_settings) - # Server status indicator on the status bar self.server_status_image_stopped = QtGui.QImage(self.common.get_resource_path('images/server_stopped.png')) self.server_status_image_working = QtGui.QImage(self.common.get_resource_path('images/server_working.png')) @@ -180,7 +214,6 @@ class OnionShareGui(QtWidgets.QMainWindow): self.status_bar.setStyleSheet(statusBar_cssStyleData) self.status_bar.addPermanentWidget(self.server_status_indicator) - self.status_bar.addPermanentWidget(self.settings_button) self.setStatusBar(self.status_bar) # Status bar, zip progress bar @@ -201,6 +234,7 @@ class OnionShareGui(QtWidgets.QMainWindow): # Main layout self.layout = QtWidgets.QVBoxLayout() + self.layout.addLayout(mode_switcher_layout) self.layout.addWidget(self.info_widget) self.layout.addLayout(self.file_selection) self.layout.addWidget(self.primary_action) @@ -232,6 +266,16 @@ class OnionShareGui(QtWidgets.QMainWindow): # After connecting to Tor, check for updates self.check_for_updates() + def update_mode_switcher(self): + # Based on the current mode, switch the mode switcher button styles, + # and show and hide widgets to switch modes + if self.mode == self.MODE_SHARE: + self.share_mode_button.setStyleSheet(self.mode_switcher_selected_style) + self.receive_mode_button.setStyleSheet(self.mode_switcher_unselected_style) + else: + self.share_mode_button.setStyleSheet(self.mode_switcher_unselected_style) + self.receive_mode_button.setStyleSheet(self.mode_switcher_selected_style) + def update_primary_action(self): # Show or hide primary action layout file_count = self.file_selection.file_list.count() diff --git a/share/images/settings.png b/share/images/settings.png index 4c69de072a9257687b736caeb933c874a971b47f..ec35400a174af4f7117b000982aaf28d78c64263 100644 GIT binary patch delta 371 zcmV-(0gV2e1G@u|QGenD7y>O8AP@3M00033@$Spa7JBJD?VdZ3YPq z1|#IGNsMF!#OrDwZUXF1N^SzB?&WG?Xbjbe z*tyfhgS@1o^K1mSfO3y#yOKtn(x(j=mDF(ND=j*b=5l7%l2i^Z-%|*D2Imtqd+qh6 zmaL`Z;U79)T?3QAEN}rlr~QGhB4UqO{==t8%oWTJ5WJW4BI!Fho1_~r;RiYe;ohxS R&MEq^`O?b2K-npA(ik&?3?9A*l zOWM})o%7{XLVF#;iAZd;6~f_2Y)FH4g>#Ic8^@7$Gv7uR#(!~vTApk%m++V%E5giX zWIcFmfS{hgpwfX=%p^wfioMX*B+3Q2GVWnMaqB@Ov08xr#8d_vz*D4!RMo$+4`FnF zY%TJVMYfy6ZpL(2*1Wyv1HBO${HNvTph++t1{xc5H9~fnc*KoT*o>kTT*3nO!+8ar ziOTz-654B3*i0W7%$VnzSiQW=cJk%cf{%s8-%603qAyf*gxf~ta1tTAZsk9`iNunG lr8