Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/PopupSection.qml

Raw
import QtQuick

Item {
    id: root

    required property Theme theme
    default property alias body: bodyItem.data
    property string title: ""
    property string detail: ""

    implicitWidth: Math.max(titleLabel.implicitWidth + detailLabel.implicitWidth + header.spacing, bodyItem.implicitWidth)
    implicitHeight: header.height + (header.visible ? 8 : 0) + bodyItem.implicitHeight

    Row {
        id: header

        visible: root.title.length > 0 || root.detail.length > 0
        width: parent.width
        spacing: 8

        NuguText {
            id: titleLabel

            width: Math.max(0, header.width - detailLabel.width - header.spacing)
            theme: root.theme
            variant: "title"
            text: root.title
        }

        NuguText {
            id: detailLabel

            width: Math.min(implicitWidth, header.width * 0.4)
            theme: root.theme
            variant: "meta"
            text: root.detail
        }
    }

    Item {
        id: bodyItem

        y: header.visible ? header.height + 8 : 0
        width: parent.width
        readonly property Item child: children.length > 0 ? children[0] : null
        implicitWidth: child ? child.implicitWidth : 0
        implicitHeight: child ? child.implicitHeight : 0
    }
}