forked from Shinonome/dots-hyprland
fancier radiobuttons
This commit is contained in:
@@ -26,6 +26,7 @@ Button {
|
|||||||
(button.down ? Appearance.colors.colSurfaceContainerHighestActive :
|
(button.down ? Appearance.colors.colSurfaceContainerHighestActive :
|
||||||
button.hovered ? Appearance.colors.colSurfaceContainerHighestHover :
|
button.hovered ? Appearance.colors.colSurfaceContainerHighestHover :
|
||||||
Appearance.m3colors.m3surfaceContainerHighest)
|
Appearance.m3colors.m3surfaceContainerHighest)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: StyledText {
|
contentItem: StyledText {
|
||||||
|
|||||||
@@ -251,8 +251,12 @@ Item {
|
|||||||
color: Appearance.m3colors.m3secondaryContainer
|
color: Appearance.m3colors.m3secondaryContainer
|
||||||
MaterialSymbol {
|
MaterialSymbol {
|
||||||
visible: notificationObject.appIcon == ""
|
visible: notificationObject.appIcon == ""
|
||||||
text: (notificationObject.urgency == NotificationUrgency.Critical) ? "release_alert" :
|
text: {
|
||||||
NotificationUtils.guessMessageType(notificationObject.summary)
|
const defaultIcon = NotificationUtils.findSuitableMaterialSymbol("")
|
||||||
|
const guessedIcon = NotificationUtils.findSuitableMaterialSymbol(notificationObject.summary)
|
||||||
|
return (notificationObject.urgency == NotificationUrgency.Critical && guessedIcon === defaultIcon) ?
|
||||||
|
"release_alert" : guessedIcon
|
||||||
|
}
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: (notificationObject.urgency == NotificationUrgency.Critical) ?
|
color: (notificationObject.urgency == NotificationUrgency.Critical) ?
|
||||||
Appearance.mix(Appearance.m3colors.m3onSecondary, Appearance.m3colors.m3onSecondaryContainer, 0.1) :
|
Appearance.mix(Appearance.m3colors.m3onSecondary, Appearance.m3colors.m3onSecondaryContainer, 0.1) :
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
function guessMessageType(summary) {
|
|
||||||
|
|
||||||
|
function findSuitableMaterialSymbol(summary = "") {
|
||||||
|
const defaultType = 'chat';
|
||||||
|
if(summary.length === 0) return defaultType;
|
||||||
|
|
||||||
const keywordsToTypes = {
|
const keywordsToTypes = {
|
||||||
'reboot': 'restart_alt',
|
'reboot': 'restart_alt',
|
||||||
'recording': 'screen_record',
|
'recording': 'screen_record',
|
||||||
@@ -26,7 +31,7 @@ function guessMessageType(summary) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'chat';
|
return defaultType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const getFriendlyNotifTimeString = (timeObject) => {
|
// const getFriendlyNotifTimeString = (timeObject) => {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Button {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font.pixelSize: Appearance.font.pixelSize.smaller
|
font.pixelSize: Appearance.font.pixelSize.smaller
|
||||||
text: input ? Pipewire.defaultAudioSource?.description : Pipewire.defaultAudioSink?.description
|
text: (input ? Pipewire.defaultAudioSource?.description : Pipewire.defaultAudioSink?.description) ?? "Unknown"
|
||||||
color: Appearance.m3colors.m3outline
|
color: Appearance.m3colors.m3outline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,25 +200,33 @@ Item {
|
|||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: devicesColumnLayout
|
id: devicesColumnLayout
|
||||||
anchors.top: parent.top
|
anchors.fill: parent
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Pipewire.nodes.values.filter(node => {
|
model: Pipewire.nodes.values.filter(node => {
|
||||||
return !node.isStream && node.isSink !== root.deviceSelectorInput && node.audio
|
return !node.isStream && node.isSink !== root.deviceSelectorInput && node.audio
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// This could and should be refractored, but all data becomes null when passed wtf
|
||||||
delegate: RadioButton {
|
delegate: RadioButton {
|
||||||
|
id: radioButton
|
||||||
Layout.leftMargin: root.dialogMargins
|
Layout.leftMargin: root.dialogMargins
|
||||||
Layout.rightMargin: root.dialogMargins
|
Layout.rightMargin: root.dialogMargins
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
leftInset: 4
|
implicitHeight: 40
|
||||||
rightInset: 4
|
checked: modelData.id === Pipewire.defaultAudioSink?.id
|
||||||
topInset: 4
|
|
||||||
bottomInset: 4
|
Connections {
|
||||||
checked: modelData.id === Pipewire.defaultAudioSink.id
|
target: root
|
||||||
|
function onShowDeviceSelectorChanged() {
|
||||||
|
if(!root.showDeviceSelector) return;
|
||||||
|
radioButton.checked = (modelData.id === Pipewire.defaultAudioSink?.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PointingHandInteraction {}
|
||||||
|
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
@@ -230,25 +238,75 @@ Item {
|
|||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: 8
|
spacing: 12
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: radio
|
id: radio
|
||||||
Layout.fillWidth: false
|
Layout.fillWidth: false
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
width: 20
|
width: 20
|
||||||
height: 20
|
height: 20
|
||||||
radius: 10
|
radius: Appearance.rounding.full
|
||||||
border.color: checked ? Appearance.m3colors.m3primary : Appearance.m3colors.m3outline
|
border.color: checked ? Appearance.m3colors.m3primary : Appearance.m3colors.m3onSurfaceVariant
|
||||||
border.width: 2
|
border.width: 2
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
|
// Checked indicator
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: 10
|
width: checked ? 10 : 4
|
||||||
height: 10
|
height: checked ? 10 : 4
|
||||||
radius: 5
|
radius: Appearance.rounding.full
|
||||||
color: checked ? Appearance.m3colors.m3primary : "transparent"
|
color: Appearance.m3colors.m3primary
|
||||||
visible: checked
|
opacity: checked ? 1 : 0
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.animation.elementDecelFast.duration
|
||||||
|
easing.type: Appearance.animation.elementDecelFast.type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on width {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.animation.elementDecelFast.duration
|
||||||
|
easing.type: Appearance.animation.elementDecelFast.type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on height {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.animation.elementDecelFast.duration
|
||||||
|
easing.type: Appearance.animation.elementDecelFast.type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hover
|
||||||
|
Rectangle {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: radioButton.hovered ? 40 : 20
|
||||||
|
height: radioButton.hovered ? 40 : 20
|
||||||
|
radius: Appearance.rounding.full
|
||||||
|
color: Appearance.m3colors.m3onSurface
|
||||||
|
opacity: radioButton.hovered ? 0.1 : 0
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.animation.elementDecelFast.duration
|
||||||
|
easing.type: Appearance.animation.elementDecelFast.type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on width {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.animation.elementDecelFast.duration
|
||||||
|
easing.type: Appearance.animation.elementDecelFast.type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on height {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Appearance.animation.elementDecelFast.duration
|
||||||
|
easing.type: Appearance.animation.elementDecelFast.type
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StyledText {
|
StyledText {
|
||||||
@@ -261,6 +319,9 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Item {
|
||||||
|
implicitHeight: dialogMargins
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user