summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <mgraesslin@kde.org>2012-04-09 09:28:04 (GMT)
committerMartin Gräßlin <mgraesslin@kde.org>2012-04-16 15:41:57 (GMT)
commit41b0647ad4ad052a3b6b049cb8ffdc526a6e03fd (patch)
tree70259a8433a354e2c83be1e0c7732875b60b804d
parent61c5a84706f4346a657158fe14366982f3a650c5 (diff)
Constrain width of text element in Thumbnail Layout
Fixes a layouting issue when caption does not fit into the window switcher box. REVIEW: 104507 CCBUG: 297028
-rw-r--r--kwin/tabbox/qml/clients/thumbnails/contents/ui/main.qml22
1 files changed, 22 insertions, 0 deletions
diff --git a/kwin/tabbox/qml/clients/thumbnails/contents/ui/main.qml b/kwin/tabbox/qml/clients/thumbnails/contents/ui/main.qml
index 7af4b8f..cba0e80 100644
--- a/kwin/tabbox/qml/clients/thumbnails/contents/ui/main.qml
+++ b/kwin/tabbox/qml/clients/thumbnails/contents/ui/main.qml
@@ -120,6 +120,7 @@ Item {
}
Item {
height: 40
+ id: captionFrame
anchors {
top: thumbnailListView.bottom
left: parent.left
@@ -146,11 +147,23 @@ Item {
}
}
Text {
+ function constrainWidth() {
+ if (textItem.width > textItem.maxWidth && textItem.width > 0 && textItem.maxWidth > 0) {
+ textItem.width = textItem.maxWidth;
+ } else {
+ textItem.width = undefined;
+ }
+ }
+ function calculateMaxWidth() {
+ textItem.maxWidth = thumbnailTabBox.width - captionFrame.anchors.leftMargin - captionFrame.anchors.rightMargin - iconItem.width * 2 - captionFrame.anchors.rightMargin;
+ }
id: textItem
+ property int maxWidth: 0
text: thumbnailListView.currentItem ? thumbnailListView.currentItem.data.caption : ""
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: theme.textColor
+ elide: Text.ElideMiddle
font {
bold: true
}
@@ -158,6 +171,15 @@ Item {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
}
+ onTextChanged: textItem.constrainWidth()
+ Component.onCompleted: textItem.calculateMaxWidth()
+ Connections {
+ target: thumbnailTabBox
+ onWidthChanged: {
+ textItem.calculateMaxWidth();
+ textItem.constrainWidth();
+ }
+ }
}
}
/*