v0.31.9: Share Library dialog opens tall enough for all its text

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-30 23:56:55 -07:00
co-authored by Claude Opus 5.5
parent 4e860737de
commit 4a019d4e27
2 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.31.8"
__version__ = "0.31.9"
+11 -1
View File
@@ -37,7 +37,6 @@ class ShareInviteDialog(QDialog):
def __init__(self, code: str, parent=None):
super().__init__(parent)
self.setWindowTitle("Share Library with a Friend")
self.resize(520, 260)
layout = QVBoxLayout(self)
intro = QLabel(
"Send this code to one friend. They paste it into "
@@ -51,6 +50,11 @@ class ShareInviteDialog(QDialog):
self.code = QPlainTextEdit(code)
self.code.setReadOnly(True)
self.code.setLineWrapMode(QPlainTextEdit.LineWrapMode.WidgetWidth)
# Room for the whole code (four lines at this width) without scrolling.
lines = 5
self.code.setMinimumHeight(
self.code.fontMetrics().lineSpacing() * lines
+ 2 * (self.code.frameWidth() + int(self.code.document().documentMargin())))
layout.addWidget(self.code, stretch=1)
row = QHBoxLayout()
self.copy = QPushButton("Copy Code")
@@ -63,6 +67,12 @@ class ShareInviteDialog(QDialog):
done.clicked.connect(self.accept)
row.addWidget(done)
layout.addLayout(row)
# Open tall enough for the wrapped intro: a fixed height cut its last
# line off, since a word-wrapped label only knows its height for a
# given width.
width = 560
self.resize(width, max(layout.totalHeightForWidth(width),
layout.totalMinimumSize().height()))
def _copy(self):
QGuiApplication.clipboard().setText(self.code.toPlainText())