in client/securedrop_client/gui/widgets.py [0:0]
def __init__(self, source: Source, controller: Controller) -> None:
super().__init__()
self.source = source
self.controller = controller
# Set css id
self.setObjectName("ReplyBoxWidget")
# Set layout
main_layout = QVBoxLayout()
self.setLayout(main_layout)
# Set margins
main_layout.setContentsMargins(0, 0, 0, 0)
main_layout.setSpacing(0)
# Create top horizontal line
horizontal_line = QWidget()
horizontal_line.setObjectName("ReplyBoxWidget_horizontal_line")
horizontal_line.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
# Create replybox
self.replybox = QWidget()
self.replybox.setObjectName("ReplyBoxWidget_replybox")
replybox_layout = QHBoxLayout(self.replybox)
replybox_layout.setContentsMargins(32, 19, 28, 18)
replybox_layout.setSpacing(0)
# Create reply text box
self.text_edit = ReplyTextEdit(self.source, self.controller)
# Create reply send button (airplane)
self.send_button = QPushButton()
self.send_button.setObjectName("ReplyBoxWidget_send_button")
self.send_button.clicked.connect(self.send_reply)
send_button_icon = QIcon(load_image("send.svg"))
send_button_icon.addPixmap(load_image("send-disabled.svg"), QIcon.Disabled)
self.send_button.setIcon(send_button_icon)
self.send_button.setIconSize(QSize(56, 47))
self.send_button.setShortcut(Shortcuts.SEND.value)
self.send_button.setDefault(True)
# Set cursor.
self.send_button.setCursor(QCursor(Qt.PointingHandCursor))
# Add widgets to replybox
replybox_layout.addWidget(self.text_edit)
replybox_layout.addWidget(self.send_button, alignment=Qt.AlignBottom)
# Ensure TAB order from text edit -> send button
self.setTabOrder(self.text_edit, self.send_button)
# Add widgets
main_layout.addWidget(horizontal_line)
main_layout.addWidget(self.replybox)
# Determine whether or not this widget should be rendered in offline mode
self.update_authentication_state(self.controller.is_authenticated)
# Text area refocus flag.
self.refocus_after_sync = False
# Connect signals to slots
self.controller.authentication_state.connect(self._on_authentication_changed)
self.controller.sync_started.connect(self._on_sync_started)
self.controller.sync_succeeded.connect(self._on_sync_succeeded)