/
v-str
/
cerera_android
Обзор
Документация
Войти
/
v-str
/
cerera_android
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
proj/qml/Components/AppTransparentButton.qml
116 строк
3 KB
v-str
Рефакторинг Dashboard: виджеты, анимация кнопок, пропорции
04 июл 2026, 20:14
Верифицирован
04 июл 2026, 20:14
685ee79
Код
Авторство
О чём код?
import QtQuick import QtQuick.Controls Button { id: control readonly property int normal: 0 readonly property int warning: 1 readonly property int error: 2 readonly property int neutral: 3 property int colorType: normal property int clickDelay: 280 signal delayedClick() Timer { id: clickTimer interval: control.clickDelay repeat: false onTriggered: control.delayedClick() } onClicked: clickTimer.restart() leftPadding: 15 rightPadding: 15 topPadding: 15 bottomPadding: 15 font.pixelSize: 20 transform: Translate { id: pressTransform } onPressedChanged: { if (pressed) { releaseSeq.stop() waveRect.x = -waveRect.width pressTo.start() } else { pressTo.stop() releaseSeq.start() } } PropertyAnimation { id: pressTo target: pressTransform properties: "x,y" to: 2 duration: 60 } SequentialAnimation { id: releaseSeq PropertyAnimation { target: pressTransform properties: "x,y" to: 0 duration: 60 } PropertyAnimation { target: waveRect property: "x" from: -waveRect.width to: waveRect.parent.width duration: 150 } } function borderColor() { if (!control.enabled) return "transparent" switch (control.colorType) { case warning: return SpaceMill.spaceWarning case error: return SpaceMill.spaceError case neutral: return Qt.rgba(1, 1, 1, 0.2) default: return SpaceMill.spaceSuccess } } function fgColor() { if (!control.enabled) return SpaceMill.spaceTextMuted switch (control.colorType) { case warning: return SpaceMill.spaceWarning case error: return SpaceMill.spaceError case neutral: return SpaceMill.spaceText default: return SpaceMill.spaceSuccess } } background: Rectangle { id: bg radius: 5 color: "transparent" border.width: 0.5 border.color: borderColor() clip: true Rectangle { id: waveRect width: parent.width * 0.4 height: parent.height color: Qt.rgba(1, 1, 1, 0.12) x: -width } } contentItem: Text { text: control.text font: control.font color: fgColor() horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } }