Skip to content

Commit

Permalink
Correct dialog button keyboard event handling
Browse files Browse the repository at this point in the history
And remove test CSS that was inadvertently left in
  • Loading branch information
rmol committed Jul 20, 2021
1 parent ad69c76 commit e682c72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 8 additions & 11 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2690,13 +2690,19 @@ def configure_buttons(self):

if self.dangerous:
self.cancel_button.setAutoDefault(True)
self.continue_button.setDefault(False)
self.cancel_button.setDefault(False)
self.cancel_button.setObjectName("ModalDialog_primary_button")

self.continue_button.setAutoDefault(False)
self.continue_button.setDefault(False)
self.continue_button.setObjectName("ModalDialog_cancel_button")
else:
self.cancel_button.setAutoDefault(False)
self.continue_button.setDefault(True)
self.cancel_button.setDefault(False)
self.cancel_button.setObjectName("ModalDialog_cancel_button")

self.continue_button.setAutoDefault(True)
self.continue_button.setDefault(False)
self.continue_button.setObjectName("ModalDialog_primary_button")

button_box.addButton(self.cancel_button, QDialogButtonBox.ActionRole)
Expand All @@ -2714,15 +2720,6 @@ def configure_buttons(self):

return window_buttons

def keyPressEvent(self, event: QKeyEvent):
if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
if self.cancel_button.hasFocus():
self.cancel_button.click()
else:
self.continue_button.click()
else:
super().keyPressEvent(event)

def animate_activestate(self):
self.continue_button.setIcon(QIcon(self.button_animation.currentPixmap()))

Expand Down
4 changes: 0 additions & 4 deletions securedrop_client/resources/css/sdclient.css
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,6 @@ QWidget#FileWidget_horizontal_line {
color: #ff3366;
}

#ModalDialog_button_box {
border: 1px solid #ff0000;
}

#ModalDialog_button_box QPushButton {
margin: 0px 0px 0px 12px;
height: 40px;
Expand Down

0 comments on commit e682c72

Please sign in to comment.