Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/dde-control-center/plugin/DccWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ D.ApplicationWindow {
property string appLicense: "GPL-3.0-or-later"
property real currentIndex: 1
property var sidebarPage: null
// 在全局快捷键抓取期间临时保持窗口激活外观
property bool forceActiveAppearance: false
// 本次抓取期间是否还需要尝试一次重新激活
property bool pendingReactivation: false

minimumWidth: 520
minimumHeight: 400
Expand All @@ -23,6 +27,16 @@ D.ApplicationWindow {
modality: Qt.ApplicationModal
color: "transparent"
D.DWindow.enabled: true
onActiveChanged: if (!active && forceActiveAppearance && pendingReactivation) {
pendingReactivation = false
requestActivateTimer.start()
}
Timer {
id: requestActivateTimer
interval: 1
repeat: false
onTriggered: if (mainWindow.forceActiveAppearance) mainWindow.requestActivate()
}

D.StyledBehindWindowBlur {
anchors.fill: parent
Expand Down
31 changes: 29 additions & 2 deletions src/plugin-keyboard/qml/ShortcutSettingDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ D.DialogWindow {
}
onRequestKeys: {
keys = [];
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = true
if (win.pendingReactivation !== undefined)
win.pendingReactivation = true
}
dccData.updateKey(ddialog.keyId, 1);
}
}
Expand Down Expand Up @@ -192,9 +199,15 @@ D.DialogWindow {
Connections {
target: dccData
function onRequestRestore() {
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = false
if (win.pendingReactivation !== undefined)
win.pendingReactivation = false
}
edit.keys = ddialog.saveKeys;
conflictText.text = "";
// 重置名称验证状态
if (nameEdit.text.trim().length > 0) {
ddialog.nameExists = dccData.isShortcutNameExists(nameEdit.text.trim(), ddialog.keyId);
} else {
Expand All @@ -205,11 +218,25 @@ D.DialogWindow {
onRequestRestore();
}
function onKeyConflicted(oldAccels, newAccels) {
edit.accels = newAccels; // 冲突也可以覆盖
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = false
if (win.pendingReactivation !== undefined)
win.pendingReactivation = false
}
edit.accels = newAccels;
var actionText = ddialog.keyId.length > 0 ? qsTr("click Save to make this shortcut key effective") : qsTr("click Add to make this shortcut key effective");
conflictText.text = dccData.conflictText + ", " + actionText;
}
function onKeyDone(accels) {
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = false
if (win.pendingReactivation !== undefined)
win.pendingReactivation = false
}
edit.keys = dccData.formatKeys(accels);
edit.accels = accels;
conflictText.text = "";
Expand Down
37 changes: 35 additions & 2 deletions src/plugin-keyboard/qml/Shortcuts.qml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ DccObject {
}

edit.keys = ""
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = true
if (win.pendingReactivation !== undefined)
win.pendingReactivation = true
}
dccData.updateKey(model.id, model.type)
shortcutView.editItem = edit
shortcutView.conflictText = conflictText
Expand All @@ -179,12 +186,10 @@ DccObject {
dialogloader.active = true
}
onRequestDeleteKeys: {
console.log("onRequestDeleteKeys", model.id)
dccData.deleteCustomShortcut(model.id)
}

function modifyShortcut(accels) {
console.log("modifyShortcut", model.id, accels, model.type)
if (accels.length > 0)
dccData.modifyShortcut(model.id, accels, model.type)
}
Expand Down Expand Up @@ -327,18 +332,46 @@ DccObject {
Connections {
target: dccData
function onRequestRestore() {
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = false
if (win.pendingReactivation !== undefined)
win.pendingReactivation = false
}
shortcutView.restoreShortcutView()
}
function onRequestClear() {
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = false
if (win.pendingReactivation !== undefined)
win.pendingReactivation = false
}
shortcutView.editItem.clearShortcut()
}
function onKeyConflicted(oldAccels, newAccels) {
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = false
if (win.pendingReactivation !== undefined)
win.pendingReactivation = false
}
if (shortcutView.conflictText)
shortcutView.conflictText.visible = true

shortcutSettingsBody.conflictAccels = newAccels
}
function onKeyDone(accels) {
var win = DccApp.mainWindow()
if (win) {
if (win.forceActiveAppearance !== undefined)
win.forceActiveAppearance = false
if (win.pendingReactivation !== undefined)
win.pendingReactivation = false
}
if (!shortcutView.editItem)
return
shortcutView.editItem.focus = false
Expand Down