1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

bluetooth+plugins: some repairs for bad references and dialogs plugins: switch to ID-based references

This commit is contained in:
bbedward
2025-10-23 14:30:25 -04:00
parent 799ae1a20e
commit b59b87d84e
3 changed files with 92 additions and 77 deletions

View File

@@ -8,6 +8,8 @@ import qs.Widgets
import qs.Modals
Rectangle {
id: root
implicitHeight: BluetoothService.adapter && BluetoothService.adapter.enabled ? headerRow.height + bluetoothContent.height + Theme.spacingM : headerRow.height
radius: Theme.cornerRadius
color: Theme.surfaceContainerHigh
@@ -23,6 +25,25 @@ Rectangle {
return devicesBeingPaired.has(deviceAddress)
}
function handlePairDevice(device) {
if (!device) return
const deviceAddr = device.address
devicesBeingPaired.add(deviceAddr)
devicesBeingPairedChanged()
BluetoothService.pairDevice(device, function(response) {
devicesBeingPaired.delete(deviceAddr)
devicesBeingPairedChanged()
if (response.error) {
ToastService.showError(I18n.tr("Pairing failed"), response.error)
} else if (!BluetoothService.enhancedPairingAvailable) {
ToastService.showSuccess(I18n.tr("Device paired"))
}
})
}
function updateDeviceCodecDisplay(deviceAddress, codecName) {
for (let i = 0; i < pairedRepeater.count; i++) {
let item = pairedRepeater.itemAt(i)
@@ -412,22 +433,7 @@ Rectangle {
cursorShape: canConnect && !isBusy ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: canConnect && !isBusy
onClicked: {
if (modelData) {
const deviceAddr = modelData.address
devicesBeingPaired.add(deviceAddr)
devicesBeingPairedChanged()
BluetoothService.pairDevice(modelData, response => {
devicesBeingPaired.delete(deviceAddr)
devicesBeingPairedChanged()
if (response.error) {
ToastService.showError(I18n.tr("Pairing failed"), response.error)
} else if (!BluetoothService.enhancedPairingAvailable) {
ToastService.showSuccess(I18n.tr("Device paired"))
}
})
}
root.handlePairDevice(modelData)
}
}
@@ -535,7 +541,16 @@ Rectangle {
onTriggered: {
if (bluetoothContextMenu.currentDevice) {
bluetoothContextMenu.currentDevice.forget()
if (BluetoothService.enhancedPairingAvailable) {
const devicePath = BluetoothService.getDevicePath(bluetoothContextMenu.currentDevice)
DMSService.bluetoothRemove(devicePath, response => {
if (response.error) {
ToastService.showError(I18n.tr("Failed to remove device"), response.error)
}
})
} else {
bluetoothContextMenu.currentDevice.forget()
}
}
}
}

View File

@@ -247,8 +247,8 @@ FocusScope {
property bool hasSettings: pluginData && pluginData.settings !== undefined && pluginData.settings !== ""
property bool isExpanded: pluginsTab.expandedPluginId === pluginId
property bool hasUpdate: {
if (DMSService.apiVersion < 8) return true
return pluginsTab.installedPluginsData[pluginDirectoryName] || pluginsTab.installedPluginsData[pluginId] || pluginsTab.installedPluginsData[pluginName] || false
if (DMSService.apiVersion < 8) return false
return pluginsTab.installedPluginsData[pluginId] || pluginsTab.installedPluginsData[pluginName] || false
}
@@ -346,10 +346,9 @@ FocusScope {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
const currentPluginDirName = pluginDelegate.pluginDirectoryName
const currentPluginName = pluginDelegate.pluginName
const currentPluginId = pluginDelegate.pluginId
DMSService.update(currentPluginDirName, response => {
DMSService.update(currentPluginName, response => {
if (response.error) {
ToastService.showError("Update failed: " + response.error)
} else {
@@ -397,9 +396,8 @@ FocusScope {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
const currentPluginDirName = pluginDelegate.pluginDirectoryName
const currentPluginName = pluginDelegate.pluginName
DMSService.uninstall(currentPluginDirName, response => {
DMSService.uninstall(currentPluginName, response => {
if (response.error) {
ToastService.showError("Uninstall failed: " + response.error)
} else {
@@ -677,8 +675,8 @@ FocusScope {
for (var i = 0; i < plugins.length; i++) {
var plugin = plugins[i]
var hasUpdate = plugin.hasUpdate || false
if (plugin.path) {
pluginMap[plugin.path] = hasUpdate
if (plugin.id) {
pluginMap[plugin.id] = hasUpdate
}
if (plugin.name) {
pluginMap[plugin.name] = hasUpdate