1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-30 08:22: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

@@ -38,11 +38,7 @@ DankModal {
shouldBeVisible: false shouldBeVisible: false
width: 420 width: 420
height: { height: contentLoader.item ? contentLoader.item.implicitHeight + Theme.spacingM * 2 : 240
if (requestType === "confirm" || requestType === "authorize" || requestType.startsWith("authorize-service"))
return 200
return 230
}
onShouldBeVisibleChanged: () => { onShouldBeVisibleChanged: () => {
if (!shouldBeVisible) { if (!shouldBeVisible) {
@@ -79,6 +75,7 @@ DankModal {
anchors.fill: parent anchors.fill: parent
focus: true focus: true
implicitHeight: mainColumn.implicitHeight
Keys.onEscapePressed: event => { Keys.onEscapePressed: event => {
DMSService.bluetoothCancelPairing(token) DMSService.bluetoothCancelPairing(token)
@@ -89,15 +86,17 @@ DankModal {
} }
Column { Column {
anchors.centerIn: parent id: mainColumn
width: parent.width - Theme.spacingM * 2 anchors.left: parent.left
spacing: Theme.spacingM anchors.right: parent.right
anchors.top: parent.top
Row { anchors.leftMargin: Theme.spacingM
width: parent.width anchors.rightMargin: Theme.spacingM
anchors.topMargin: Theme.spacingM
spacing: requestType === "pin" || requestType === "passkey" ? Theme.spacingM : Theme.spacingS
Column { Column {
width: parent.width - 40 width: parent.width
spacing: Theme.spacingXS spacing: Theme.spacingXS
StyledText { StyledText {
@@ -123,24 +122,11 @@ DankModal {
} }
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceTextMedium color: Theme.surfaceTextMedium
width: parent.width width: parent.width - 40
elide: Text.ElideRight elide: Text.ElideRight
} }
} }
DankActionButton {
iconName: "close"
iconSize: Theme.iconSize - 4
iconColor: Theme.surfaceText
onClicked: () => {
DMSService.bluetoothCancelPairing(token)
close()
pinInput = ""
passkeyInput = ""
}
}
}
Rectangle { Rectangle {
width: parent.width width: parent.width
height: 50 height: 50
@@ -213,14 +199,14 @@ DankModal {
Rectangle { Rectangle {
width: parent.width width: parent.width
height: 60 height: 56
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.surfaceContainerHighest color: Theme.surfaceContainerHighest
visible: requestType === "confirm" visible: requestType === "confirm"
Column { Column {
anchors.centerIn: parent anchors.centerIn: parent
spacing: Theme.spacingXS spacing: 2
StyledText { StyledText {
text: I18n.tr("Passkey:") text: I18n.tr("Passkey:")
@@ -241,12 +227,12 @@ DankModal {
Item { Item {
width: parent.width width: parent.width
height: 40 height: 36
Row { Row {
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingM spacing: Theme.spacingS
Rectangle { Rectangle {
width: Math.max(70, cancelText.contentWidth + Theme.spacingM * 2) width: Math.max(70, cancelText.contentWidth + Theme.spacingM * 2)
@@ -333,6 +319,22 @@ DankModal {
} }
} }
} }
DankActionButton {
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: Theme.spacingM
anchors.rightMargin: Theme.spacingM
iconName: "close"
iconSize: Theme.iconSize - 4
iconColor: Theme.surfaceText
onClicked: () => {
DMSService.bluetoothCancelPairing(token)
close()
pinInput = ""
passkeyInput = ""
}
}
} }
} }

View File

@@ -8,6 +8,8 @@ import qs.Widgets
import qs.Modals import qs.Modals
Rectangle { Rectangle {
id: root
implicitHeight: BluetoothService.adapter && BluetoothService.adapter.enabled ? headerRow.height + bluetoothContent.height + Theme.spacingM : headerRow.height implicitHeight: BluetoothService.adapter && BluetoothService.adapter.enabled ? headerRow.height + bluetoothContent.height + Theme.spacingM : headerRow.height
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.surfaceContainerHigh color: Theme.surfaceContainerHigh
@@ -23,6 +25,25 @@ Rectangle {
return devicesBeingPaired.has(deviceAddress) 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) { function updateDeviceCodecDisplay(deviceAddress, codecName) {
for (let i = 0; i < pairedRepeater.count; i++) { for (let i = 0; i < pairedRepeater.count; i++) {
let item = pairedRepeater.itemAt(i) let item = pairedRepeater.itemAt(i)
@@ -412,22 +433,7 @@ Rectangle {
cursorShape: canConnect && !isBusy ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: canConnect && !isBusy ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: canConnect && !isBusy enabled: canConnect && !isBusy
onClicked: { onClicked: {
if (modelData) { root.handlePairDevice(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"))
}
})
}
} }
} }
@@ -535,11 +541,20 @@ Rectangle {
onTriggered: { onTriggered: {
if (bluetoothContextMenu.currentDevice) { if (bluetoothContextMenu.currentDevice) {
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() bluetoothContextMenu.currentDevice.forget()
} }
} }
} }
} }
}
BluetoothPairingModal { BluetoothPairingModal {
id: bluetoothPairingModal id: bluetoothPairingModal

View File

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