mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
feat(styles): create global styles entry point and organize global styles feat(styles): implement base HTML element styles and utility classes for flexbox feat(styles): establish layout, position, spacing, and text utility classes feat(styles): introduce mixins for animations, cards, dialogs, flexbox, grid, and responsive design test(quick_guide): add component and metadata validation tests for quick_guide package test(ui_level6): implement metadata validation tests for ui_level6 package
77 lines
2.1 KiB
QML
77 lines
2.1 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
|
|
Item {
|
|
id: control
|
|
|
|
property string icon: ""
|
|
property string size: "md" // sm, md, lg
|
|
property string variant: "default" // default, primary, ghost
|
|
property bool loading: false
|
|
property string tooltip: ""
|
|
|
|
signal clicked()
|
|
|
|
width: size === "sm" ? 32 : size === "lg" ? 48 : 40
|
|
height: width
|
|
|
|
Rectangle {
|
|
id: bg
|
|
anchors.fill: parent
|
|
radius: width / 2
|
|
color: {
|
|
if (!control.enabled) return "transparent"
|
|
if (mouseArea.pressed) {
|
|
switch(control.variant) {
|
|
case "primary": return Qt.darker(Theme.primary, 1.2)
|
|
default: return "#404040"
|
|
}
|
|
}
|
|
if (mouseArea.containsMouse) {
|
|
switch(control.variant) {
|
|
case "primary": return Theme.primary
|
|
default: return "#3d3d3d"
|
|
}
|
|
}
|
|
switch(control.variant) {
|
|
case "primary": return Theme.primary
|
|
case "ghost": return "transparent"
|
|
default: return Theme.surface
|
|
}
|
|
}
|
|
|
|
Behavior on color { ColorAnimation { duration: 150 } }
|
|
}
|
|
|
|
BusyIndicator {
|
|
anchors.centerIn: parent
|
|
width: parent.width * 0.5
|
|
height: width
|
|
running: control.loading
|
|
visible: control.loading
|
|
}
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: control.icon
|
|
font.pixelSize: control.size === "sm" ? 14 : control.size === "lg" ? 22 : 18
|
|
color: control.enabled ? (control.variant === "primary" ? "#ffffff" : Theme.textSecondary) : Theme.textDisabled
|
|
visible: !control.loading
|
|
}
|
|
|
|
MouseArea {
|
|
id: mouseArea
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: control.clicked()
|
|
}
|
|
|
|
ToolTip.visible: tooltip && mouseArea.containsMouse
|
|
ToolTip.text: tooltip
|
|
ToolTip.delay: 500
|
|
|
|
opacity: enabled ? 1.0 : 0.5
|
|
Behavior on opacity { NumberAnimation { duration: 150 } }
|
|
}
|