plasma-framework/tests/components/button.qml
David Edmundson 1a4c1d7eeb Fix Button minimumWidth property
Plasma's Button has an extra property "minimumWidth" which is an extra
hint not in QQC to say "what is the size to exactly fit the contents".

(it's a bit confusing, as we can perfectly handle a button below it's
"minmimum" size)

This should be based on the size the contents want to be (the
implicitWidth), not how small the contents can go (which with is pretty
meaningless when our button can elide)

It got broken at some point recently.

BUG: 353584
Change-Id: I637898c3abf98183bbae30d8f15c4d72801a3650
REVIEW: 125698
2015-10-19 11:30:19 +01:00

124 lines
2.6 KiB
QML

import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.2
Rectangle
{
width: 500
height: 500
color: "white"
Grid {
anchors.fill: parent
anchors.margins: 20
spacing: 20
columns: 2
Label {
text: "icon + text"
}
PlasmaComponents.Button {
iconSource: "list-remove"
text: "test"
}
Label {
text: "icon alone, should look small and square"
}
PlasmaComponents.Button {
iconSource: "list-remove"
}
Label {
text: "text alone, should be about 12 chars wide"
}
PlasmaComponents.Button {
text: "test"
}
Label {
text: "long text, should expand to fit"
}
PlasmaComponents.Button {
iconSource: "list-remove"
text: "This is a really really really really long button"
}
Label {
text: "long text but constrained, should be 150px and elided"
}
PlasmaComponents.Button {
iconSource: "list-remove"
text: "This is a really really really really long button"
width: 150
}
Label {
text: "button with menu"
}
PlasmaComponents.Button {
text: "test"
menu: Menu {
MenuItem {
text: "Cut"
shortcut: "Ctrl+X"
}
MenuItem {
text: "Copy"
shortcut: "Ctrl+C"
}
MenuItem {
text: "Paste"
shortcut: "Ctrl+V"
}
MenuSeparator { }
Menu {
title: "More Stuff"
MenuItem {
text: "Do Nothing"
}
}
}
}
Label {
text: "button and textfield should have the same height"
}
RowLayout {
PlasmaComponents.Button {
text: "test"
}
PlasmaComponents.TextField {
}
}
Label {
text: "minimum width property. Should be two letters wide"
}
RowLayout {
PlasmaComponents.Button {
text: "AA"
implicitWidth: minimumWidth
}
}
}
}