mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-11 07:52:50 -05:00
feat: Priority pinned items in Control Center
This commit is contained in:
@@ -7,6 +7,8 @@ import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property bool hasInputVolumeSliderInCC: {
|
||||
const widgets = SettingsData.controlCenterWidgets || []
|
||||
return widgets.some(widget => widget.id === "inputVolumeSlider")
|
||||
@@ -124,9 +126,25 @@ Rectangle {
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: Pipewire.nodes.values.filter(node => {
|
||||
return node.audio && !node.isSink && !node.isStream
|
||||
})
|
||||
values: {
|
||||
const nodes = Pipewire.nodes.values.filter(node => {
|
||||
return node.audio && !node.isSink && !node.isStream
|
||||
})
|
||||
const pins = SettingsData.audioInputDevicePins || {}
|
||||
const pinnedName = pins["preferredInput"]
|
||||
|
||||
let sorted = [...nodes]
|
||||
sorted.sort((a, b) => {
|
||||
// Pinned device first
|
||||
if (a.name === pinnedName && b.name !== pinnedName) return -1
|
||||
if (b.name === pinnedName && a.name !== pinnedName) return 1
|
||||
// Then active device
|
||||
if (a === AudioService.source && b !== AudioService.source) return -1
|
||||
if (b === AudioService.source && a !== AudioService.source) return 1
|
||||
return 0
|
||||
})
|
||||
return sorted
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Rectangle {
|
||||
@@ -185,9 +203,69 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: pinInputRow.width + Theme.spacingS * 2
|
||||
height: 28
|
||||
radius: height / 2
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.audioInputDevicePins || {})["preferredInput"] === modelData.name
|
||||
return isThisDevicePinned ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05)
|
||||
}
|
||||
|
||||
Row {
|
||||
id: pinInputRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
DankIcon {
|
||||
name: "push_pin"
|
||||
size: 16
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.audioInputDevicePins || {})["preferredInput"] === modelData.name
|
||||
return isThisDevicePinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
const isThisDevicePinned = (SettingsData.audioInputDevicePins || {})["preferredInput"] === modelData.name
|
||||
return isThisDevicePinned ? "Pinned" : "Pin"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.audioInputDevicePins || {})["preferredInput"] === modelData.name
|
||||
return isThisDevicePinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.audioInputDevicePins || {}))
|
||||
const isCurrentlyPinned = pins["preferredInput"] === modelData.name
|
||||
|
||||
if (isCurrentlyPinned) {
|
||||
delete pins["preferredInput"]
|
||||
} else {
|
||||
pins["preferredInput"] = modelData.name
|
||||
}
|
||||
|
||||
SettingsData.set("audioInputDevicePins", pins)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: deviceMouseArea
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: pinInputRow.width + Theme.spacingS * 4
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
|
||||
@@ -7,6 +7,8 @@ import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property bool hasVolumeSliderInCC: {
|
||||
const widgets = SettingsData.controlCenterWidgets || []
|
||||
return widgets.some(widget => widget.id === "volumeSlider")
|
||||
@@ -129,9 +131,25 @@ Rectangle {
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: Pipewire.nodes.values.filter(node => {
|
||||
return node.audio && node.isSink && !node.isStream
|
||||
})
|
||||
values: {
|
||||
const nodes = Pipewire.nodes.values.filter(node => {
|
||||
return node.audio && node.isSink && !node.isStream
|
||||
})
|
||||
const pins = SettingsData.audioOutputDevicePins || {}
|
||||
const pinnedName = pins["preferredOutput"]
|
||||
|
||||
let sorted = [...nodes]
|
||||
sorted.sort((a, b) => {
|
||||
// Pinned device first
|
||||
if (a.name === pinnedName && b.name !== pinnedName) return -1
|
||||
if (b.name === pinnedName && a.name !== pinnedName) return 1
|
||||
// Then active device
|
||||
if (a === AudioService.sink && b !== AudioService.sink) return -1
|
||||
if (b === AudioService.sink && a !== AudioService.sink) return 1
|
||||
return 0
|
||||
})
|
||||
return sorted
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Rectangle {
|
||||
@@ -192,9 +210,69 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: pinOutputRow.width + Theme.spacingS * 2
|
||||
height: 28
|
||||
radius: height / 2
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.audioOutputDevicePins || {})["preferredOutput"] === modelData.name
|
||||
return isThisDevicePinned ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05)
|
||||
}
|
||||
|
||||
Row {
|
||||
id: pinOutputRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
DankIcon {
|
||||
name: "push_pin"
|
||||
size: 16
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.audioOutputDevicePins || {})["preferredOutput"] === modelData.name
|
||||
return isThisDevicePinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
const isThisDevicePinned = (SettingsData.audioOutputDevicePins || {})["preferredOutput"] === modelData.name
|
||||
return isThisDevicePinned ? "Pinned" : "Pin"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.audioOutputDevicePins || {})["preferredOutput"] === modelData.name
|
||||
return isThisDevicePinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.audioOutputDevicePins || {}))
|
||||
const isCurrentlyPinned = pins["preferredOutput"] === modelData.name
|
||||
|
||||
if (isCurrentlyPinned) {
|
||||
delete pins["preferredOutput"]
|
||||
} else {
|
||||
pins["preferredOutput"] = modelData.name
|
||||
}
|
||||
|
||||
SettingsData.set("audioOutputDevicePins", pins)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: deviceMouseArea
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: pinOutputRow.width + Theme.spacingS * 4
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
|
||||
@@ -54,6 +54,8 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Row {
|
||||
id: headerRow
|
||||
anchors.left: parent.left
|
||||
@@ -150,10 +152,18 @@ Rectangle {
|
||||
if (!BluetoothService.adapter || !BluetoothService.adapter.devices)
|
||||
return []
|
||||
|
||||
const pins = SettingsData.bluetoothDevicePins || {}
|
||||
const pinnedAddr = pins["preferredDevice"]
|
||||
|
||||
let devices = [...BluetoothService.adapter.devices.values.filter(dev => dev && (dev.paired || dev.trusted))]
|
||||
devices.sort((a, b) => {
|
||||
// Pinned device first
|
||||
if (a.address === pinnedAddr && b.address !== pinnedAddr) return -1
|
||||
if (b.address === pinnedAddr && a.address !== pinnedAddr) return 1
|
||||
// Then connected devices
|
||||
if (a.connected && !b.connected) return -1
|
||||
if (!a.connected && b.connected) return 1
|
||||
// Then by signal strength
|
||||
return (b.signalStrength || 0) - (a.signalStrength || 0)
|
||||
})
|
||||
return devices
|
||||
@@ -273,6 +283,65 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: pairedOptionsButton.left
|
||||
anchors.rightMargin: Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: pinBluetoothRow.width + Theme.spacingS * 2
|
||||
height: 28
|
||||
radius: height / 2
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.bluetoothDevicePins || {})["preferredDevice"] === modelData.address
|
||||
return isThisDevicePinned ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05)
|
||||
}
|
||||
|
||||
Row {
|
||||
id: pinBluetoothRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
DankIcon {
|
||||
name: "push_pin"
|
||||
size: 16
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.bluetoothDevicePins || {})["preferredDevice"] === modelData.address
|
||||
return isThisDevicePinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
const isThisDevicePinned = (SettingsData.bluetoothDevicePins || {})["preferredDevice"] === modelData.address
|
||||
return isThisDevicePinned ? "Pinned" : "Pin"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: {
|
||||
const isThisDevicePinned = (SettingsData.bluetoothDevicePins || {})["preferredDevice"] === modelData.address
|
||||
return isThisDevicePinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.bluetoothDevicePins || {}))
|
||||
const isCurrentlyPinned = pins["preferredDevice"] === modelData.address
|
||||
|
||||
if (isCurrentlyPinned) {
|
||||
delete pins["preferredDevice"]
|
||||
} else {
|
||||
pins["preferredDevice"] = modelData.address
|
||||
}
|
||||
|
||||
SettingsData.set("bluetoothDevicePins", pins)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: pairedOptionsButton
|
||||
anchors.right: parent.right
|
||||
@@ -293,7 +362,7 @@ Rectangle {
|
||||
MouseArea {
|
||||
id: deviceMouseArea
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: pairedOptionsButton.width + Theme.spacingS
|
||||
anchors.rightMargin: pairedOptionsButton.width + Theme.spacingM + pinBluetoothRow.width + Theme.spacingS * 4
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
|
||||
@@ -7,6 +7,8 @@ import qs.Widgets
|
||||
import qs.Modals
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
implicitHeight: {
|
||||
if (NetworkService.wifiToggling) {
|
||||
return headerRow.height + wifiToggleContent.height + Theme.spacingM
|
||||
@@ -93,6 +95,8 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item {
|
||||
id: wifiToggleContent
|
||||
anchors.top: headerRow.bottom
|
||||
@@ -411,10 +415,18 @@ Rectangle {
|
||||
values: {
|
||||
const ssid = NetworkService.currentWifiSSID
|
||||
const networks = NetworkService.wifiNetworks
|
||||
const pins = SettingsData.wifiNetworkPins || {}
|
||||
const pinnedSSID = pins["preferredWifi"]
|
||||
|
||||
let sorted = [...networks]
|
||||
sorted.sort((a, b) => {
|
||||
// Pinned network first
|
||||
if (a.ssid === pinnedSSID && b.ssid !== pinnedSSID) return -1
|
||||
if (b.ssid === pinnedSSID && a.ssid !== pinnedSSID) return 1
|
||||
// Then currently connected
|
||||
if (a.ssid === ssid) return -1
|
||||
if (b.ssid === ssid) return 1
|
||||
// Then by signal strength
|
||||
return b.signal - a.signal
|
||||
})
|
||||
if (!wifiContent.menuOpen) {
|
||||
@@ -514,10 +526,69 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: optionsButton.width + Theme.spacingM + Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: pinWifiRow.width + Theme.spacingS * 2
|
||||
height: 28
|
||||
radius: height / 2
|
||||
color: {
|
||||
const isThisNetworkPinned = (SettingsData.wifiNetworkPins || {})["preferredWifi"] === modelData.ssid
|
||||
return isThisNetworkPinned ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05)
|
||||
}
|
||||
|
||||
Row {
|
||||
id: pinWifiRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
DankIcon {
|
||||
name: "push_pin"
|
||||
size: 16
|
||||
color: {
|
||||
const isThisNetworkPinned = (SettingsData.wifiNetworkPins || {})["preferredWifi"] === modelData.ssid
|
||||
return isThisNetworkPinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
const isThisNetworkPinned = (SettingsData.wifiNetworkPins || {})["preferredWifi"] === modelData.ssid
|
||||
return isThisNetworkPinned ? "Pinned" : "Pin"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: {
|
||||
const isThisNetworkPinned = (SettingsData.wifiNetworkPins || {})["preferredWifi"] === modelData.ssid
|
||||
return isThisNetworkPinned ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.wifiNetworkPins || {}))
|
||||
const isCurrentlyPinned = pins["preferredWifi"] === modelData.ssid
|
||||
|
||||
if (isCurrentlyPinned) {
|
||||
delete pins["preferredWifi"]
|
||||
} else {
|
||||
pins["preferredWifi"] = modelData.ssid
|
||||
}
|
||||
|
||||
SettingsData.set("wifiNetworkPins", pins)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: networkMouseArea
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: optionsButton.width + Theme.spacingS
|
||||
anchors.rightMargin: optionsButton.width + Theme.spacingM + Theme.spacingS + pinWifiRow.width + Theme.spacingS * 4
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: function(event) {
|
||||
|
||||
Reference in New Issue
Block a user