diff --git a/CHANGELOG.md b/CHANGELOG.md index 67181b259..59e25a7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ since 0.4.1, and this project adheres to [Semantic Versioning](https://semver.or - Update the theme correctly on dark/light mode changes ([#1238](https://github.com/freedomofpress/dangerzone/issues/1238)) - Update Linux .desktop file with missing MIME types for HWP and ODF formats ([#646](https://github.com/freedomofpress/dangerzone/issues/646)) +- Elide long filenames in the filename label to prevent UI elements from being pushed off-screen ([#143](https://github.com/freedomofpress/dangerzone/issues/143)) ### Added diff --git a/dangerzone/gui/main_window.py b/dangerzone/gui/main_window.py index 9590f3089..04c58f51d 100644 --- a/dangerzone/gui/main_window.py +++ b/dangerzone/gui/main_window.py @@ -1667,9 +1667,14 @@ def __init__( self.dangerous_doc_label.setAlignment( QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft ) - self.dangerous_doc_label.setText(os.path.basename(self.document.input_filename)) + doc_name = os.path.basename(self.document.input_filename) + self.dangerous_doc_label.setToolTip(doc_name) self.dangerous_doc_label.setMinimumWidth(200) self.dangerous_doc_label.setMaximumWidth(200) + # Elide text with '...' when the filename is too long for the label width + metrics = self.dangerous_doc_label.fontMetrics() + elided = metrics.elidedText(doc_name, QtCore.Qt.ElideMiddle, 200) + self.dangerous_doc_label.setText(elided) # Conversion status images self.img_status_unconverted = self.load_status_image("status_unconverted.png")