From 5b9176c9d4c19429d6f917d91e6e35a350e636eb Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 18 Sep 2014 00:37:19 +0000 Subject: [PATCH] combined Start Server and Stop Server buttons into a single button --- onionshare/strings.json | 3 ++- onionshare_gui/file_selection.py | 1 - onionshare_gui/server_status.py | 33 +++++++++++++++++--------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/onionshare/strings.json b/onionshare/strings.json index a168ef51..b21adb54 100644 --- a/onionshare/strings.json +++ b/onionshare/strings.json @@ -37,7 +37,8 @@ "gui_copy_url": "Copy URL", "gui_downloads": "Downloads:", "gui_copied_url": "Copied URL to clipboard", - "gui_starting_server": "Please wait, starting server..." + "gui_starting_server": "Please wait, starting server...", + "gui_please_wait": "Please wait..." }, "no": { "connecting_ctrlport": "Kobler til Tors kontroll-port for å sette opp en gjemt tjeneste på port {0}.", "cant_connect_ctrlport": "Klarte ikke å koble til Tors kontroll-porter {0}. Sjekk at Tor kjører.", diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py index 4a8aa2dc..d5c21dca 100644 --- a/onionshare_gui/file_selection.py +++ b/onionshare_gui/file_selection.py @@ -162,7 +162,6 @@ class FileSelection(QtGui.QVBoxLayout): # add the widgets self.addWidget(self.file_list) self.addLayout(button_layout) - self.addWidget(self.filesize_warning) self.update() diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 4de3adef..6cd386fb 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -48,14 +48,11 @@ class ServerStatus(QtGui.QVBoxLayout): self.status_image_started = QtGui.QImage(common.get_image_path('server_started.png')) self.status_image_label = QtGui.QLabel() self.status_image_label.setFixedWidth(30) - self.start_server_button = QtGui.QPushButton(strings._('gui_start_server', True)) - self.start_server_button.clicked.connect(self.start_server) - self.stop_server_button = QtGui.QPushButton(strings._('gui_stop_server', True)) - self.stop_server_button.clicked.connect(self.stop_server) + self.server_button = QtGui.QPushButton() + self.server_button.clicked.connect(self.server_button_clicked) server_layout = QtGui.QHBoxLayout() server_layout.addWidget(self.status_image_label) - server_layout.addWidget(self.start_server_button) - server_layout.addWidget(self.stop_server_button) + server_layout.addWidget(self.server_button) # url layout url_font = QtGui.QFont() @@ -94,20 +91,26 @@ class ServerStatus(QtGui.QVBoxLayout): self.url_label.hide() self.copy_url_button.hide() - # buttons enabled + # button if self.file_selection.get_num_files() == 0: - self.start_server_button.setEnabled(False) - self.stop_server_button.setEnabled(False) + self.server_button.setEnabled(False) + self.server_button.setText(strings._('gui_start_server', True)) else: if self.status == self.STATUS_STOPPED: - self.start_server_button.setEnabled(True) - self.stop_server_button.setEnabled(False) + self.server_button.setEnabled(True) + self.server_button.setText(strings._('gui_start_server', True)) elif self.status == self.STATUS_STARTED: - self.start_server_button.setEnabled(False) - self.stop_server_button.setEnabled(True) + self.server_button.setEnabled(True) + self.server_button.setText(strings._('gui_stop_server', True)) else: - self.start_server_button.setEnabled(False) - self.stop_server_button.setEnabled(False) + self.server_button.setEnabled(False) + self.server_button.setText(strings._('gui_please_wait')) + + def server_button_clicked(self): + if self.status == self.STATUS_STOPPED: + self.start_server() + elif self.status == self.STATUS_STARTED: + self.stop_server() def start_server(self): self.status = self.STATUS_WORKING