diff --git a/desktop/src/onionshare/resources/locale/en.json b/desktop/src/onionshare/resources/locale/en.json index 0c7ec57a..723d4c12 100644 --- a/desktop/src/onionshare/resources/locale/en.json +++ b/desktop/src/onionshare/resources/locale/en.json @@ -32,6 +32,8 @@ "gui_copied_client_auth": "Private Key copied to clipboard", "gui_show_url_qr_code": "Show QR Code", "gui_qr_code_dialog_title": "OnionShare QR Code", + "gui_qr_label_url_title": "OnionShare Address", + "gui_qr_label_auth_string_title": "Private Key", "gui_waiting_to_start": "Scheduled to start in {}. Click to cancel.", "gui_please_wait_no_button": "Starting…", "gui_please_wait": "Starting… Click to cancel.", diff --git a/desktop/src/onionshare/tab/server_status.py b/desktop/src/onionshare/tab/server_status.py index 6cd905ad..3d4c723d 100644 --- a/desktop/src/onionshare/tab/server_status.py +++ b/desktop/src/onionshare/tab/server_status.py @@ -411,7 +411,11 @@ class ServerStatus(QtWidgets.QWidget): """ Show a QR code of the onion URL. """ - self.qr_code_dialog = QRCodeDialog(self.common, self.get_url()) + if self.settings.get("general", "public"): + self.qr_code_dialog = QRCodeDialog(self.common, self.get_url()) + else: + # Make a QR Code for the ClientAuth too + self.qr_code_dialog = QRCodeDialog(self.common, self.get_url(), self.app.auth_string) def start_server(self): """ diff --git a/desktop/src/onionshare/widgets.py b/desktop/src/onionshare/widgets.py index c239d03a..ad54a22d 100644 --- a/desktop/src/onionshare/widgets.py +++ b/desktop/src/onionshare/widgets.py @@ -130,20 +130,43 @@ class QRCodeDialog(QtWidgets.QDialog): A dialog showing a QR code. """ - def __init__(self, common, text): + def __init__(self, common, url, auth_string=None): super(QRCodeDialog, self).__init__() self.common = common - self.text = text self.common.log("QrCode", "__init__") - self.qr_label = QtWidgets.QLabel(self) - self.qr_label.setPixmap(qrcode.make(self.text, image_factory=Image).pixmap()) + self.qr_label_url = QtWidgets.QLabel(self) + self.qr_label_url.setPixmap(qrcode.make(url, image_factory=Image).pixmap()) + self.qr_label_url_title = QtWidgets.QLabel(self) + self.qr_label_url_title.setText(strings._("gui_qr_label_url_title")) + self.qr_label_url_title.setAlignment(QtCore.Qt.AlignCenter) self.setWindowTitle(strings._("gui_qr_code_dialog_title")) self.setWindowIcon(QtGui.QIcon(GuiCommon.get_resource_path("images/logo.png"))) - layout = QtWidgets.QVBoxLayout(self) - layout.addWidget(self.qr_label) + layout = QtWidgets.QHBoxLayout(self) + url_layout = QtWidgets.QVBoxLayout(self) + url_layout.addWidget(self.qr_label_url_title) + url_layout.addWidget(self.qr_label_url) + + url_code_with_label = QtWidgets.QWidget() + url_code_with_label.setLayout(url_layout) + layout.addWidget(url_code_with_label) + + if auth_string: + self.qr_label_auth_string = QtWidgets.QLabel(self) + self.qr_label_auth_string.setPixmap(qrcode.make(auth_string, image_factory=Image).pixmap()) + self.qr_label_auth_string_title = QtWidgets.QLabel(self) + self.qr_label_auth_string_title.setText(strings._("gui_qr_label_auth_string_title")) + self.qr_label_auth_string_title.setAlignment(QtCore.Qt.AlignCenter) + + auth_string_layout = QtWidgets.QVBoxLayout(self) + auth_string_layout.addWidget(self.qr_label_auth_string_title) + auth_string_layout.addWidget(self.qr_label_auth_string) + + auth_string_code_with_label = QtWidgets.QWidget() + auth_string_code_with_label.setLayout(auth_string_layout) + layout.addWidget(auth_string_code_with_label) self.exec_()