mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-25 05:52:50 -05:00
107 lines
3.0 KiB
QML
107 lines
3.0 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import Quickshell
|
|
import qs.Common
|
|
import qs.Widgets
|
|
|
|
Rectangle {
|
|
id: root
|
|
|
|
property string iconName: ""
|
|
property string text: ""
|
|
property bool isActive: false
|
|
property bool enabled: true
|
|
property string secondaryText: ""
|
|
|
|
signal clicked()
|
|
|
|
width: parent ? parent.width : 200
|
|
height: 60
|
|
radius: Theme.cornerRadius
|
|
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, Theme.getContentBackgroundAlpha() * 0.6)
|
|
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
|
border.width: 1
|
|
opacity: enabled ? 1.0 : 0.6
|
|
|
|
function hoverTint(base) {
|
|
const factor = 1.2
|
|
return Theme.isLightMode ? Qt.darker(base, factor) : Qt.lighter(base, factor)
|
|
}
|
|
|
|
readonly property color _containerBg:
|
|
Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b,
|
|
Theme.getContentBackgroundAlpha() * 0.60)
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
radius: Theme.cornerRadius
|
|
color: mouseArea.containsMouse ? hoverTint(_containerBg) : "transparent"
|
|
opacity: mouseArea.containsMouse ? 0.08 : 0.0
|
|
|
|
Behavior on opacity {
|
|
NumberAnimation { duration: Theme.shortDuration }
|
|
}
|
|
}
|
|
|
|
Row {
|
|
anchors.fill: parent
|
|
anchors.leftMargin: Theme.spacingL + 2
|
|
anchors.rightMargin: Theme.spacingM
|
|
spacing: Theme.spacingM
|
|
|
|
DankIcon {
|
|
name: root.iconName
|
|
size: Theme.iconSize
|
|
color: Theme.primary
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
Item {
|
|
width: parent.width - Theme.iconSize - parent.spacing
|
|
height: parent.height
|
|
|
|
Column {
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: 2
|
|
|
|
StyledText {
|
|
width: parent.width
|
|
text: root.text
|
|
font.pixelSize: Theme.fontSizeMedium
|
|
color: Theme.surfaceText
|
|
font.weight: Font.Medium
|
|
elide: Text.ElideRight
|
|
wrapMode: Text.NoWrap
|
|
}
|
|
|
|
StyledText {
|
|
width: parent.width
|
|
text: root.secondaryText
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.surfaceVariantText
|
|
visible: text.length > 0
|
|
elide: Text.ElideRight
|
|
wrapMode: Text.NoWrap
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
id: mouseArea
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
enabled: root.enabled
|
|
onClicked: root.clicked()
|
|
}
|
|
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: Theme.shortDuration
|
|
easing.type: Theme.standardEasing
|
|
}
|
|
}
|
|
} |