From 3e3d669a49d21514744a08c0d6359bb85ee267ee Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 16 May 2017 15:24:14 -0700 Subject: [PATCH] Remove the menu bar, and replace it with a settings button owned by the OnionShareGui object --- onionshare_gui/file_selection.py | 6 ++++ onionshare_gui/menu.py | 51 ------------------------------- onionshare_gui/onionshare_gui.py | 29 +++++++++++------- share/images/settings.png | Bin 0 -> 411 bytes 4 files changed, 24 insertions(+), 62 deletions(-) delete mode 100644 onionshare_gui/menu.py create mode 100644 share/images/settings.png diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index 5fbf5a75..6accc117 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -256,3 +256,9 @@ class FileSelection(QtWidgets.QVBoxLayout): Returns the total number of files and folders in the list. """ return len(self.file_list.filenames) + + def setFocus(self): + """ + Set the Qt app focus on the file selection box. + """ + self.file_list.setFocus() diff --git a/onionshare_gui/menu.py b/onionshare_gui/menu.py deleted file mode 100644 index 4697d396..00000000 --- a/onionshare_gui/menu.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -""" -OnionShare | https://onionshare.org/ - -Copyright (C) 2017 Micah Lee - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" -from PyQt5 import QtCore, QtWidgets - -from onionshare import strings -from .settings_dialog import SettingsDialog - -class Menu(QtWidgets.QMenuBar): - """ - OnionShare's menu bar. - """ - def __init__(self, onion, qtapp): - super(Menu, self).__init__() - self.onion = onion - self.qtapp = qtapp - - file_menu = self.addMenu(strings._('gui_menu_file_menu', True)) - - settings_action = file_menu.addAction(strings._('gui_menu_settings_action', True)) - settings_action.triggered.connect(self.settings) - quit_action = file_menu.addAction(strings._('gui_menu_quit_action', True)) - quit_action.triggered.connect(self.quit) - - def settings(self): - """ - Settings action triggered. - """ - SettingsDialog(self.onion, self.qtapp) - - def quit(self): - """ - Quit action triggered. - """ - self.parent().qtapp.quit() diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 76811ccb..6471aa44 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -26,7 +26,6 @@ from onionshare.onion import * from .tor_connection_dialog import TorConnectionDialog from .settings_dialog import SettingsDialog -from .menu import Menu from .file_selection import FileSelection from .server_status import ServerStatus from .downloads import Downloads @@ -66,9 +65,6 @@ class OnionShareGui(QtWidgets.QMainWindow): tor_con.open_settings.connect(self._tor_connection_open_settings) tor_con.start() - # Menu bar - self.setMenuBar(Menu(self.onion, self.qtapp)) - # Check for updates in a new thread, if enabled system = platform.system() if system == 'Windows' or system == 'Darwin': @@ -121,8 +117,13 @@ class OnionShareGui(QtWidgets.QMainWindow): self.status_bar = QtWidgets.QStatusBar() self.status_bar.setSizeGripEnabled(False) version_label = QtWidgets.QLabel('v{0:s}'.format(common.get_version())) - version_label.setStyleSheet('color: #666666; padding: 0 10px;') + version_label.setStyleSheet('color: #666666') + settings_button = QtWidgets.QPushButton() + settings_button.setDefault(False) + settings_button.setIcon( QtGui.QIcon(common.get_resource_path('images/settings.png')) ) + settings_button.clicked.connect(self.open_settings) self.status_bar.addPermanentWidget(version_label) + self.status_bar.addPermanentWidget(settings_button) self.setStatusBar(self.status_bar) # Status bar, zip progress bar @@ -139,11 +140,14 @@ class OnionShareGui(QtWidgets.QMainWindow): self.setCentralWidget(central_widget) self.show() - # check for requests frequently + # Check for requests frequently self.timer = QtCore.QTimer() self.timer.timeout.connect(self.check_for_requests) self.timer.start(500) + # Always start with focus on file selection + self.file_selection.setFocus() + def _tor_connection_canceled(self): """ If the user cancels before Tor finishes connecting, ask if they want to @@ -161,7 +165,7 @@ class OnionShareGui(QtWidgets.QMainWindow): a.exec_() if a.clickedButton() == settings_button: - SettingsDialog(self.onion, self.qtapp) + self.open_settings() else: self.qtapp.quit() @@ -174,11 +178,14 @@ class OnionShareGui(QtWidgets.QMainWindow): """ common.log('OnionShareGui', '_tor_connection_open_settings') - def open_settings(): - SettingsDialog(self.onion, self.qtapp) - # Wait 1ms for the event loop to finish closing the TorConnectionDialog - QtCore.QTimer.singleShot(1, open_settings) + QtCore.QTimer.singleShot(1, self.open_settings) + + def open_settings(self): + """ + Open the SettingsDialog. + """ + SettingsDialog(self.onion, self.qtapp) def start_server(self): """ diff --git a/share/images/settings.png b/share/images/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..4c69de072a9257687b736caeb933c874a971b47f GIT binary patch literal 411 zcmV;M0c8G(P)@!Q+*72S5zt@ru3B)+EXWxH9fxK5^?o zB(Yk6{lruT8o*Peg;dqQu@7N%e{3!Cl0~+g!*0fOSk}C~=L5YF8T_Z^=b%Y29R?a3 zbTvYDn0UmEQrL{56