mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
IconButton
This commit is contained in:
@@ -35,6 +35,10 @@ PanelWindow {
|
|||||||
label: "Label"
|
label: "Label"
|
||||||
description: "Description"
|
description: "Description"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NoctaliaIconButton {
|
||||||
|
icon: "refresh"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import qs.Settings
|
import qs.Services
|
||||||
|
import qs.Theme
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
// Local scale convenience with safe fallback
|
||||||
|
readonly property real scale: (typeof screen !== 'undefined'
|
||||||
|
&& screen) ? Scaling.scale(screen) : 1.0
|
||||||
|
|
||||||
property string icon
|
property string icon
|
||||||
property bool enabled: true
|
property bool enabled: true
|
||||||
property bool hovering: false
|
property bool hovering: false
|
||||||
property real size: 32
|
property real size: 32
|
||||||
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
implicitWidth: size
|
implicitWidth: size
|
||||||
implicitHeight: size
|
implicitHeight: size
|
||||||
@@ -18,19 +25,21 @@ MouseArea {
|
|||||||
onExited: hovering = false
|
onExited: hovering = false
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: 8
|
radius: width * 0.5
|
||||||
color: root.hovering ? Theme.accentPrimary : "transparent"
|
color: root.hovering ? Theme.accentPrimary : "transparent"
|
||||||
}
|
|
||||||
Text {
|
Text {
|
||||||
id: iconText
|
id: iconText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: root.icon
|
text: root.icon
|
||||||
font.family: "Material Symbols Outlined"
|
font.family: "Material Symbols Outlined"
|
||||||
font.pixelSize: 24 * Theme.scale(screen)
|
font.pixelSize: 24 * scale
|
||||||
color: root.hovering ? Theme.onAccent : Theme.textPrimary
|
color: root.hovering ? Theme.onAccent : Theme.textPrimary
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
opacity: root.enabled ? 1.0 : 0.5
|
opacity: root.enabled ? 1.0 : 0.5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user