Completely refactor common to make a Common class, and pass that class down into all parts of the program

This commit is contained in:
Micah Lee 2018-03-08 10:18:31 -08:00
parent 49e352d131
commit 50409167d4
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
17 changed files with 458 additions and 444 deletions

View file

@ -21,7 +21,7 @@ import platform
from .alert import Alert
from PyQt5 import QtCore, QtWidgets, QtGui
from onionshare import strings, common, settings
from onionshare import strings
class ServerStatus(QtWidgets.QWidget):
"""
@ -38,8 +38,11 @@ class ServerStatus(QtWidgets.QWidget):
STATUS_WORKING = 1
STATUS_STARTED = 2
def __init__(self, qtapp, app, web, file_selection, settings):
def __init__(self, common, qtapp, app, web, file_selection, settings):
super(ServerStatus, self).__init__()
self.common = common
self.status = self.STATUS_STOPPED
self.qtapp = qtapp
@ -129,7 +132,7 @@ class ServerStatus(QtWidgets.QWidget):
if self.status == self.STATUS_STARTED:
self.url_description.show()
info_image = common.get_resource_path('images/info.png')
info_image = self.common.get_resource_path('images/info.png')
self.url_description.setText(strings._('gui_url_description', True).format(info_image))
# Show a Tool Tip explaining the lifecycle of this URL
if self.settings.get('save_private_key'):
@ -212,7 +215,7 @@ class ServerStatus(QtWidgets.QWidget):
self.timeout = self.shutdown_timeout.dateTime().toPyDateTime().replace(second=0, microsecond=0)
# If the timeout has actually passed already before the user hit Start, refuse to start the server.
if QtCore.QDateTime.currentDateTime().toPyDateTime() > self.timeout:
Alert(strings._('gui_server_timeout_expired', QtWidgets.QMessageBox.Warning))
Alert(self.common, strings._('gui_server_timeout_expired', QtWidgets.QMessageBox.Warning))
else:
self.start_server()
else:
@ -252,7 +255,7 @@ class ServerStatus(QtWidgets.QWidget):
"""
Cancel the server.
"""
common.log('ServerStatus', 'cancel_server', 'Canceling the server mid-startup')
self.common.log('ServerStatus', 'cancel_server', 'Canceling the server mid-startup')
self.status = self.STATUS_WORKING
self.shutdown_timeout_reset()
self.update()