39 lines
1005 B
QML
39 lines
1005 B
QML
// An expander: collapses to zero height and animates open, GNOME-style.
|
|
//
|
|
// The child is measured at its natural size and the *section* animates; the
|
|
// child itself never re-layouts, so opening a 20-row wifi list costs one
|
|
// height animation rather than twenty.
|
|
|
|
import QtQuick
|
|
import qs.config
|
|
|
|
Item {
|
|
id: root
|
|
|
|
property bool expanded: false
|
|
default property alias content: holder.data
|
|
|
|
clip: true
|
|
// Column/ColumnLayout skip invisible children, so this also collapses the
|
|
// surrounding spacing when closed.
|
|
visible: implicitHeight > 0
|
|
|
|
implicitHeight: root.expanded ? holder.implicitHeight : 0
|
|
|
|
Behavior on implicitHeight {
|
|
NumberAnimation {
|
|
duration: Theme.durNormal
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: holder
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.top: parent.top
|
|
implicitHeight: childrenRect.height
|
|
height: implicitHeight
|
|
}
|
|
}
|