Files
metabuilder/fakemui/qml-components/core/CIconButton.qml
JohnDoe6345789 58a94d0489 feat(styles): add component-specific styles for TaskDetail, SearchDialog, and Documentation
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
2025-12-30 02:29:58 +00:00

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 } }
}