mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-12 07:49:39 -05:00
Rearrange moat dialog so pressing enter submits
This commit is contained in:
parent
a89412e79d
commit
3b6b74f649
@ -55,11 +55,9 @@ class MoatDialog(QtWidgets.QDialog):
|
|||||||
# Solution input
|
# Solution input
|
||||||
self.solution_lineedit = QtWidgets.QLineEdit()
|
self.solution_lineedit = QtWidgets.QLineEdit()
|
||||||
self.solution_lineedit.setPlaceholderText(strings._("moat_captcha_placeholder"))
|
self.solution_lineedit.setPlaceholderText(strings._("moat_captcha_placeholder"))
|
||||||
self.reload_button = QtWidgets.QPushButton(strings._("moat_captcha_reload"))
|
self.solution_lineedit.editingFinished.connect(
|
||||||
self.reload_button.clicked.connect(self.reload_clicked)
|
self.solution_lineedit_editing_finished
|
||||||
solution_layout = QtWidgets.QHBoxLayout()
|
)
|
||||||
solution_layout.addWidget(self.solution_lineedit)
|
|
||||||
solution_layout.addWidget(self.reload_button)
|
|
||||||
|
|
||||||
# Error label
|
# Error label
|
||||||
self.error_label = QtWidgets.QLabel()
|
self.error_label = QtWidgets.QLabel()
|
||||||
@ -69,20 +67,23 @@ class MoatDialog(QtWidgets.QDialog):
|
|||||||
# Buttons
|
# Buttons
|
||||||
self.submit_button = QtWidgets.QPushButton(strings._("moat_captcha_submit"))
|
self.submit_button = QtWidgets.QPushButton(strings._("moat_captcha_submit"))
|
||||||
self.submit_button.clicked.connect(self.submit_clicked)
|
self.submit_button.clicked.connect(self.submit_clicked)
|
||||||
|
self.reload_button = QtWidgets.QPushButton(strings._("moat_captcha_reload"))
|
||||||
|
self.reload_button.clicked.connect(self.reload_clicked)
|
||||||
self.cancel_button = QtWidgets.QPushButton(
|
self.cancel_button = QtWidgets.QPushButton(
|
||||||
strings._("gui_settings_button_cancel")
|
strings._("gui_settings_button_cancel")
|
||||||
)
|
)
|
||||||
self.cancel_button.clicked.connect(self.cancel_clicked)
|
self.cancel_button.clicked.connect(self.cancel_clicked)
|
||||||
buttons_layout = QtWidgets.QHBoxLayout()
|
buttons_layout = QtWidgets.QHBoxLayout()
|
||||||
buttons_layout.addStretch()
|
|
||||||
buttons_layout.addWidget(self.submit_button)
|
buttons_layout.addWidget(self.submit_button)
|
||||||
|
buttons_layout.addStretch()
|
||||||
|
buttons_layout.addWidget(self.reload_button)
|
||||||
buttons_layout.addWidget(self.cancel_button)
|
buttons_layout.addWidget(self.cancel_button)
|
||||||
|
|
||||||
# Layout
|
# Layout
|
||||||
layout = QtWidgets.QVBoxLayout()
|
layout = QtWidgets.QVBoxLayout()
|
||||||
layout.addWidget(self.label)
|
layout.addWidget(self.label)
|
||||||
layout.addWidget(self.captcha)
|
layout.addWidget(self.captcha)
|
||||||
layout.addLayout(solution_layout)
|
layout.addWidget(self.solution_lineedit)
|
||||||
layout.addStretch()
|
layout.addStretch()
|
||||||
layout.addWidget(self.error_label)
|
layout.addWidget(self.error_label)
|
||||||
layout.addLayout(buttons_layout)
|
layout.addLayout(buttons_layout)
|
||||||
@ -117,6 +118,7 @@ class MoatDialog(QtWidgets.QDialog):
|
|||||||
Submit button clicked.
|
Submit button clicked.
|
||||||
"""
|
"""
|
||||||
self.error_label.hide()
|
self.error_label.hide()
|
||||||
|
self.solution_lineedit.setEnabled(False)
|
||||||
|
|
||||||
solution = self.solution_lineedit.text().strip()
|
solution = self.solution_lineedit.text().strip()
|
||||||
if len(solution) == 0:
|
if len(solution) == 0:
|
||||||
@ -148,6 +150,8 @@ class MoatDialog(QtWidgets.QDialog):
|
|||||||
self.error_label.setText(strings._("moat_bridgedb_error"))
|
self.error_label.setText(strings._("moat_bridgedb_error"))
|
||||||
self.error_label.show()
|
self.error_label.show()
|
||||||
|
|
||||||
|
self.solution_lineedit.setEnabled(True)
|
||||||
|
|
||||||
def captcha_error(self, msg):
|
def captcha_error(self, msg):
|
||||||
self.common.log("MoatDialog", "captcha_error")
|
self.common.log("MoatDialog", "captcha_error")
|
||||||
if msg == "":
|
if msg == "":
|
||||||
@ -156,6 +160,8 @@ class MoatDialog(QtWidgets.QDialog):
|
|||||||
self.error_label.setText(msg)
|
self.error_label.setText(msg)
|
||||||
self.error_label.show()
|
self.error_label.show()
|
||||||
|
|
||||||
|
self.solution_lineedit.setEnabled(True)
|
||||||
|
|
||||||
def captcha_ready(self, image, challenge):
|
def captcha_ready(self, image, challenge):
|
||||||
self.common.log("MoatDialog", "captcha_ready")
|
self.common.log("MoatDialog", "captcha_ready")
|
||||||
|
|
||||||
@ -172,11 +178,16 @@ class MoatDialog(QtWidgets.QDialog):
|
|||||||
|
|
||||||
self.label.setText(strings._("moat_captcha_label"))
|
self.label.setText(strings._("moat_captcha_label"))
|
||||||
self.captcha.show()
|
self.captcha.show()
|
||||||
|
self.solution_lineedit.setEnabled(True)
|
||||||
self.solution_lineedit.setText("")
|
self.solution_lineedit.setText("")
|
||||||
self.solution_lineedit.show()
|
self.solution_lineedit.show()
|
||||||
|
self.solution_lineedit.setFocus()
|
||||||
self.reload_button.show()
|
self.reload_button.show()
|
||||||
self.submit_button.show()
|
self.submit_button.show()
|
||||||
|
|
||||||
|
def solution_lineedit_editing_finished(self):
|
||||||
|
self.common.log("MoatDialog", "solution_lineedit_editing_finished")
|
||||||
|
|
||||||
def bridges_ready(self, bridges):
|
def bridges_ready(self, bridges):
|
||||||
self.common.log("MoatDialog", "bridges_ready", bridges)
|
self.common.log("MoatDialog", "bridges_ready", bridges)
|
||||||
self.got_bridges.emit(bridges)
|
self.got_bridges.emit(bridges)
|
||||||
|
Loading…
Reference in New Issue
Block a user