Skip to content

Commit

Permalink
Add shortcuts for sending replies. Fixes # 606.
Browse files Browse the repository at this point in the history
  • Loading branch information
ntoll authored and sssoleileraaa committed Jan 7, 2020
1 parent 9c66d68 commit 01c824d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from uuid import uuid4
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal, QEvent, QTimer, QSize, pyqtBoundSignal, \
QObject, QPoint
from PyQt5.QtGui import QIcon, QPalette, QBrush, QColor, QFont, QLinearGradient
from PyQt5.QtGui import QIcon, QPalette, QBrush, QColor, QFont, QLinearGradient, QKeySequence
from PyQt5.QtWidgets import QListWidget, QLabel, QWidget, QListWidgetItem, QHBoxLayout, \
QPushButton, QVBoxLayout, QLineEdit, QScrollArea, QDialog, QAction, QMenu, QMessageBox, \
QToolButton, QSizePolicy, QPlainTextEdit, QStatusBar, QGraphicsDropShadowEffect
Expand Down Expand Up @@ -2561,6 +2561,11 @@ def __init__(self, source: Source, controller: Controller) -> None:
button_icon = QIcon(button_pixmap)
self.send_button.setIcon(button_icon)
self.send_button.setIconSize(QSize(56.5, 47))
self.send_button.setShortcut(QKeySequence("Ctrl+Return"))
self.send_button.setDefault(True)

# Ensure TAB order from text edit -> send button
self.setTabOrder(self.text_edit, self.send_button)

# Add widgets to replybox
replybox_layout.addWidget(self.text_edit)
Expand Down Expand Up @@ -2641,6 +2646,8 @@ def __init__(self, source, controller):
self.setObjectName('reply_textedit')
self.setStyleSheet(self.CSS)

self.setTabChangesFocus(True) # Needed so we can TAB to send button.

self.placeholder = QLabel()
self.placeholder.setObjectName("reply_placeholder")
self.placeholder.setParent(self)
Expand Down
2 changes: 2 additions & 0 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,8 @@ def test_ReplyBoxWidget_init(mocker):
rb = ReplyBoxWidget(mocker.MagicMock(), mocker.MagicMock())
assert rb.text_edit.isEnabled()
assert not rb.send_button.isHidden()
assert rb.send_button.isDefault() is True # Needed for "Enter" to work.
assert rb.send_button.shortcut().toString() == "Ctrl+Return"


def test_ReplyBoxWidget_init_no_auth(mocker):
Expand Down

0 comments on commit 01c824d

Please sign in to comment.