mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
bluez: fix disappearing popouts with modal maanger
This commit is contained in:
@@ -165,12 +165,11 @@ func (a *BluezAgent) DisplayPasskey(device dbus.ObjectPath, passkey uint32, ente
|
||||
log.Infof("[BluezAgent] DisplayPasskey: device=%s, passkey=%06d, entered=%d", device, passkey, entered)
|
||||
|
||||
if entered == 0 {
|
||||
pk := passkey
|
||||
_, err := a.promptFor(device, "display-passkey", []string{}, nil)
|
||||
passkeyStr := strconv.FormatUint(uint64(passkey), 10)
|
||||
_, err := a.promptFor(device, "display-passkey", []string{}, &passkeyStr)
|
||||
if err != nil {
|
||||
log.Warnf("[BluezAgent] DisplayPasskey acknowledgment failed: %v", err)
|
||||
}
|
||||
_ = pk
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -179,7 +178,8 @@ func (a *BluezAgent) DisplayPasskey(device dbus.ObjectPath, passkey uint32, ente
|
||||
func (a *BluezAgent) RequestConfirmation(device dbus.ObjectPath, passkey uint32) *dbus.Error {
|
||||
log.Infof("[BluezAgent] RequestConfirmation: device=%s, passkey=%06d", device, passkey)
|
||||
|
||||
secrets, err := a.promptFor(device, "confirm", []string{"decision"}, nil)
|
||||
passkeyStr := strconv.FormatUint(uint64(passkey), 10)
|
||||
secrets, err := a.promptFor(device, "confirm", []string{"decision"}, &passkeyStr)
|
||||
if err != nil {
|
||||
log.Warnf("[BluezAgent] RequestConfirmation failed: %v", err)
|
||||
return a.errorFrom(err)
|
||||
|
||||
@@ -354,21 +354,25 @@ func (m *Manager) handleDevicePropertiesChanged(path dbus.ObjectPath, changed ma
|
||||
_, hasTrusted := changed["Trusted"]
|
||||
|
||||
if hasPaired {
|
||||
if paired, ok := pairedVar.Value().(bool); ok && paired {
|
||||
devicePath := string(path)
|
||||
_, wasPending := m.pendingPairings.LoadAndDelete(devicePath)
|
||||
devicePath := string(path)
|
||||
if paired, ok := pairedVar.Value().(bool); ok {
|
||||
if paired {
|
||||
_, wasPending := m.pendingPairings.LoadAndDelete(devicePath)
|
||||
|
||||
if wasPending {
|
||||
select {
|
||||
case m.eventQueue <- func() {
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
log.Infof("[Bluetooth] Auto-connecting newly paired device: %s", devicePath)
|
||||
if err := m.ConnectDevice(devicePath); err != nil {
|
||||
log.Warnf("[Bluetooth] Auto-connect failed: %v", err)
|
||||
if wasPending {
|
||||
select {
|
||||
case m.eventQueue <- func() {
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
log.Infof("[Bluetooth] Auto-connecting newly paired device: %s", devicePath)
|
||||
if err := m.ConnectDevice(devicePath); err != nil {
|
||||
log.Warnf("[Bluetooth] Auto-connect failed: %v", err)
|
||||
}
|
||||
}:
|
||||
default:
|
||||
}
|
||||
}:
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
m.pendingPairings.Delete(devicePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,9 @@ Singleton {
|
||||
popout.currentTabIndex = tabIndex
|
||||
}
|
||||
|
||||
ModalManager.closeAllModalsExcept(null)
|
||||
if (currentPopout !== popout) {
|
||||
ModalManager.closeAllModalsExcept(null)
|
||||
}
|
||||
TrayMenuManager.closeAllMenus()
|
||||
|
||||
if (justClosedSamePopout) {
|
||||
|
||||
@@ -217,6 +217,14 @@ Item {
|
||||
id: polkitAuthModal
|
||||
}
|
||||
|
||||
BluetoothPairingModal {
|
||||
id: bluetoothPairingModal
|
||||
|
||||
Component.onCompleted: {
|
||||
PopoutService.bluetoothPairingModal = bluetoothPairingModal
|
||||
}
|
||||
}
|
||||
|
||||
property string lastCredentialsToken: ""
|
||||
property var lastCredentialsTime: 0
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ DankModal {
|
||||
property string passkeyInput: ""
|
||||
|
||||
function show(pairingData) {
|
||||
console.log("BluetoothPairingModal.show() called:", JSON.stringify(pairingData))
|
||||
token = pairingData.token || ""
|
||||
deviceName = pairingData.deviceName || ""
|
||||
deviceAddress = pairingData.deviceAddr || ""
|
||||
@@ -26,6 +27,7 @@ DankModal {
|
||||
pinInput = ""
|
||||
passkeyInput = ""
|
||||
|
||||
console.log("BluetoothPairingModal: Calling open()")
|
||||
open()
|
||||
Qt.callLater(() => {
|
||||
if (contentLoader.item) {
|
||||
@@ -39,6 +41,8 @@ DankModal {
|
||||
}
|
||||
|
||||
shouldBeVisible: false
|
||||
allowStacking: true
|
||||
keepPopoutsOpen: true
|
||||
width: 420
|
||||
height: contentLoader.item ? contentLoader.item.implicitHeight + Theme.spacingM * 2 : 240
|
||||
|
||||
@@ -62,8 +66,11 @@ DankModal {
|
||||
}
|
||||
|
||||
onBackgroundClicked: () => {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
if (token) {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
}
|
||||
close()
|
||||
token = ""
|
||||
pinInput = ""
|
||||
passkeyInput = ""
|
||||
}
|
||||
@@ -80,8 +87,11 @@ DankModal {
|
||||
implicitHeight: mainColumn.implicitHeight
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
if (token) {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
}
|
||||
close()
|
||||
token = ""
|
||||
pinInput = ""
|
||||
passkeyInput = ""
|
||||
event.accepted = true
|
||||
@@ -110,17 +120,22 @@ DankModal {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (requestType === "confirm")
|
||||
switch (requestType) {
|
||||
case "confirm":
|
||||
return I18n.tr("Confirm passkey for ") + deviceName
|
||||
if (requestType === "authorize")
|
||||
case "display-passkey":
|
||||
return I18n.tr("Enter this passkey on ") + deviceName
|
||||
case "authorize":
|
||||
return I18n.tr("Authorize pairing with ") + deviceName
|
||||
if (requestType.startsWith("authorize-service"))
|
||||
return I18n.tr("Authorize service for ") + deviceName
|
||||
if (requestType === "pin")
|
||||
case "pin":
|
||||
return I18n.tr("Enter PIN for ") + deviceName
|
||||
if (requestType === "passkey")
|
||||
case "passkey":
|
||||
return I18n.tr("Enter passkey for ") + deviceName
|
||||
return deviceName
|
||||
default:
|
||||
if (requestType.startsWith("authorize-service"))
|
||||
return I18n.tr("Authorize service for ") + deviceName
|
||||
return deviceName
|
||||
}
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceTextMedium
|
||||
@@ -204,7 +219,7 @@ DankModal {
|
||||
height: 56
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.withAlpha(Theme.surfaceContainerHighest, Theme.popupTransparency)
|
||||
visible: requestType === "confirm"
|
||||
visible: requestType === "confirm" || requestType === "display-passkey"
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
@@ -261,8 +276,11 @@ DankModal {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: () => {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
if (token) {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
}
|
||||
close()
|
||||
token = ""
|
||||
pinInput = ""
|
||||
passkeyInput = ""
|
||||
}
|
||||
@@ -288,11 +306,17 @@ DankModal {
|
||||
|
||||
anchors.centerIn: parent
|
||||
text: {
|
||||
if (requestType === "confirm")
|
||||
switch (requestType) {
|
||||
case "confirm":
|
||||
case "display-passkey":
|
||||
return I18n.tr("Confirm")
|
||||
if (requestType === "authorize" || requestType.startsWith("authorize-service"))
|
||||
case "authorize":
|
||||
return I18n.tr("Authorize")
|
||||
return I18n.tr("Pair")
|
||||
default:
|
||||
if (requestType.startsWith("authorize-service"))
|
||||
return I18n.tr("Authorize")
|
||||
return I18n.tr("Pair")
|
||||
}
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.background
|
||||
@@ -331,8 +355,11 @@ DankModal {
|
||||
iconSize: Theme.iconSize - 4
|
||||
iconColor: Theme.surfaceText
|
||||
onClicked: () => {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
if (token) {
|
||||
DMSService.bluetoothCancelPairing(token)
|
||||
}
|
||||
close()
|
||||
token = ""
|
||||
pinInput = ""
|
||||
passkeyInput = ""
|
||||
}
|
||||
@@ -343,12 +370,23 @@ DankModal {
|
||||
function submitPairing() {
|
||||
const secrets = {}
|
||||
|
||||
if (requestType === "pin") {
|
||||
switch (requestType) {
|
||||
case "pin":
|
||||
secrets["pin"] = pinInput
|
||||
} else if (requestType === "passkey") {
|
||||
break
|
||||
case "passkey":
|
||||
secrets["passkey"] = passkeyInput
|
||||
} else if (requestType === "confirm" || requestType === "authorize" || requestType.startsWith("authorize-service")) {
|
||||
break
|
||||
case "confirm":
|
||||
case "display-passkey":
|
||||
case "authorize":
|
||||
secrets["decision"] = "yes"
|
||||
break
|
||||
default:
|
||||
if (requestType.startsWith("authorize-service")) {
|
||||
secrets["decision"] = "yes"
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
DMSService.bluetoothSubmitPairing(token, secrets, true, response => {
|
||||
@@ -358,6 +396,7 @@ DankModal {
|
||||
})
|
||||
|
||||
close()
|
||||
token = ""
|
||||
pinInput = ""
|
||||
passkeyInput = ""
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ PanelWindow {
|
||||
}
|
||||
|
||||
function close() {
|
||||
console.log("DankModal.close() called on:", layerNamespace, "Stack trace:", new Error().stack)
|
||||
shouldBeVisible = false
|
||||
shouldHaveFocus = false
|
||||
closeTimer.restart()
|
||||
|
||||
@@ -29,11 +29,13 @@ Rectangle {
|
||||
if (!device) return
|
||||
|
||||
const deviceAddr = device.address
|
||||
devicesBeingPaired.add(deviceAddr)
|
||||
const pairingSet = devicesBeingPaired
|
||||
|
||||
pairingSet.add(deviceAddr)
|
||||
devicesBeingPairedChanged()
|
||||
|
||||
BluetoothService.pairDevice(device, function(response) {
|
||||
devicesBeingPaired.delete(deviceAddr)
|
||||
pairingSet.delete(deviceAddr)
|
||||
devicesBeingPairedChanged()
|
||||
|
||||
if (response.error) {
|
||||
@@ -625,15 +627,14 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
BluetoothPairingModal {
|
||||
id: bluetoothPairingModal
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
|
||||
function onBluetoothPairingRequest(data) {
|
||||
bluetoothPairingModal.show(data)
|
||||
const modal = PopoutService.bluetoothPairingModal
|
||||
if (modal && modal.token !== data.token) {
|
||||
modal.show(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,20 +49,20 @@ Singleton {
|
||||
return devices.sort((a, b) => {
|
||||
const aName = a.name || a.deviceName || ""
|
||||
const bName = b.name || b.deviceName || ""
|
||||
const aAddr = a.address || ""
|
||||
const bAddr = b.address || ""
|
||||
|
||||
const aHasRealName = aName.includes(" ") && aName.length > 3
|
||||
const bHasRealName = bName.includes(" ") && bName.length > 3
|
||||
|
||||
if (aHasRealName && !bHasRealName) {
|
||||
return -1
|
||||
}
|
||||
if (!aHasRealName && bHasRealName) {
|
||||
return 1
|
||||
if (aHasRealName && !bHasRealName) return -1
|
||||
if (!aHasRealName && bHasRealName) return 1
|
||||
|
||||
if (aHasRealName && bHasRealName) {
|
||||
return aName.localeCompare(bName)
|
||||
}
|
||||
|
||||
const aSignal = (a.signalStrength !== undefined && a.signalStrength > 0) ? a.signalStrength : 0
|
||||
const bSignal = (b.signalStrength !== undefined && b.signalStrength > 0) ? b.signalStrength : 0
|
||||
return bSignal - aSignal
|
||||
return aAddr.localeCompare(bAddr)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ Singleton {
|
||||
property var colorPickerModal: null
|
||||
property var notificationModal: null
|
||||
property var wifiPasswordModal: null
|
||||
property var bluetoothPairingModal: null
|
||||
property var networkInfoModal: null
|
||||
|
||||
property var notepadSlideouts: []
|
||||
|
||||
Reference in New Issue
Block a user