Remove the menu bar, and replace it with a settings button owned by the OnionShareGui object

This commit is contained in:
Micah Lee 2017-05-16 15:24:14 -07:00
parent 22fb34d50d
commit 3e3d669a49
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
4 changed files with 24 additions and 62 deletions

View File

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

View File

@ -1,51 +0,0 @@
# -*- coding: utf-8 -*-
"""
OnionShare | https://onionshare.org/
Copyright (C) 2017 Micah Lee <micah@micahflee.com>
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 <http://www.gnu.org/licenses/>.
"""
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()

View File

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

BIN
share/images/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B