Skip to content

Commit f1ec815

Browse files
committed
Adjust the clickable area for logging out to include the user's icon.
1 parent e7f8761 commit f1ec815

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

securedrop_client/gui/widgets.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,20 @@ def __init__(self):
448448
# Login button
449449
self.login_button = LoginButton()
450450

451+
# User button
452+
self.user_button = UserButton()
453+
451454
# User icon
452-
self.user_icon = QLabel()
455+
self.user_icon = UserIconLabel()
453456
self.user_icon.setObjectName('user_icon') # Set css id
454457
self.user_icon.setFixedSize(QSize(30, 30))
455458
self.user_icon.setAlignment(Qt.AlignCenter)
456459
self.user_icon_font = QFont()
457460
self.user_icon_font.setLetterSpacing(QFont.AbsoluteSpacing, 0.58)
458461
self.user_icon.setFont(self.user_icon_font)
459-
460-
# User button
461-
self.user_button = UserButton()
462+
self.user_icon.clicked.connect(self.user_button.click)
463+
# Set cursor.
464+
self.user_icon.setCursor(QCursor(Qt.PointingHandCursor))
462465

463466
# Add widgets to user auth layout
464467
layout.addWidget(self.login_button, 1)
@@ -488,6 +491,17 @@ def hide(self):
488491
self.login_button.show()
489492

490493

494+
class UserIconLabel(QLabel):
495+
"""
496+
Makes a label clickable. (For the label containing the user icon.)
497+
"""
498+
499+
clicked = pyqtSignal()
500+
501+
def mousePressEvent(self, e):
502+
self.clicked.emit()
503+
504+
491505
class UserButton(SvgPushButton):
492506
"""An menu button for the journalist menu
493507

tests/gui/test_widgets.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
ErrorStatusBar, ActivityStatusBar, UserProfile, UserButton, UserMenu, LoginButton, \
2323
ReplyBoxWidget, ReplyTextEdit, SourceConversationWrapper, StarToggleButton, LoginOfflineLink, \
2424
LoginErrorBar, EmptyConversationView, FramelessDialog, ExportDialog, PrintDialog, \
25-
PasswordEdit, SourceProfileShortWidget
25+
PasswordEdit, SourceProfileShortWidget, UserIconLabel
2626
from tests import factory
2727

2828

@@ -383,6 +383,13 @@ def test_UserProfile_hide(mocker):
383383
up.login_button.show.assert_called_once_with()
384384

385385

386+
def test_UserIconLabel_clicks(mocker):
387+
uil = UserIconLabel()
388+
uil.clicked = mocker.MagicMock()
389+
uil.mousePressEvent(None)
390+
uil.clicked.emit.assert_called_once_with()
391+
392+
386393
def test_UserButton_setup(mocker):
387394
ub = UserButton()
388395
ub.menu = mocker.MagicMock()

0 commit comments

Comments
 (0)