-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elide source designation at lower window widths #1145
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3133,8 +3133,25 @@ def setText(self, text): | |
self.placeholder.hide() | ||
super(ReplyTextEdit, self).setPlainText(text) | ||
|
||
def resizeEvent(self, event): | ||
# Adjust available source label width to elide text when necessary | ||
self.placeholder.update_label_width(event.size().width()) | ||
super().resizeEvent(event) | ||
|
||
|
||
class ReplyTextEditPlaceholder(QWidget): | ||
|
||
# These values are used to determine the width that can be taken up by | ||
# the source designation as the widget is initialized or the window is | ||
# resized. | ||
INITIAL_MAX_WIDTH = 150 | ||
RESERVED_WIDTH = 250 | ||
|
||
# We allocate a fixed with to the source designation because its text is | ||
# dynamically resized, which otherwise causes Qt's layout engine to | ||
# incorrectly reposition it | ||
FIXED_LABEL_WIDTH = 800 | ||
|
||
def __init__(self, source_name): | ||
super().__init__() | ||
|
||
|
@@ -3147,14 +3164,18 @@ def __init__(self, source_name): | |
# Signed in | ||
compose_a_reply_to = QLabel(_("Compose a reply to ")) | ||
compose_a_reply_to.setObjectName("ReplyTextEditPlaceholder_text") | ||
source_name = SecureQLabel(source_name, wordwrap=False) | ||
source_name.setObjectName("ReplyTextEditPlaceholder_bold_blue") | ||
self.source_name = source_name | ||
self.source_name_label = SecureQLabel( | ||
source_name, wordwrap=False, max_length=self.INITIAL_MAX_WIDTH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, setting max_length here will turn on elided text |
||
) | ||
self.source_name_label.setObjectName("ReplyTextEditPlaceholder_bold_blue") | ||
self.source_name_label.setFixedWidth(self.FIXED_LABEL_WIDTH) | ||
self.signed_in = QWidget() | ||
signed_in_layout = QHBoxLayout() | ||
signed_in_layout.setSpacing(0) | ||
self.signed_in.setLayout(signed_in_layout) | ||
signed_in_layout.addWidget(compose_a_reply_to) | ||
signed_in_layout.addWidget(source_name) | ||
signed_in_layout.addWidget(self.source_name_label) | ||
self.signed_in.hide() | ||
|
||
# Awaiting key | ||
|
@@ -3203,6 +3224,13 @@ def show_signed_out(self): | |
self.signed_in.hide() | ||
self.signed_out.show() | ||
|
||
def update_label_width(self, width): | ||
if width > self.RESERVED_WIDTH: | ||
# Ensure source designations are elided with "..." if needed per | ||
# current container size | ||
self.source_name_label.max_length = width - self.RESERVED_WIDTH | ||
self.source_name_label.setText(self.source_name) | ||
|
||
|
||
class DeleteSourceAction(QAction): | ||
"""Use this action to delete the source record.""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hooking into the resize event works as expected