mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 11:47:27 -03:00
Show ClientAuth private key as QR code
This commit is contained in:
parent
60d3564a9b
commit
662f9171c5
3 changed files with 36 additions and 7 deletions
|
@ -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.",
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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_()
|
||||
|
|
Loading…
Reference in a new issue