Activate numeric pad buttons with numpad keyboard in calls window #LINQT-2310

This commit is contained in:
Gaelle Braud 2026-01-12 10:52:08 +01:00
parent 7e9e3e6f55
commit 389fae13d8
2 changed files with 120 additions and 31 deletions

View file

@ -42,49 +42,64 @@ FocusScope {
} }
Keys.onPressed: (event) => { Keys.onPressed: (event) => {
event.accepted = false
if (event.modifiers & Qt.KeypadModifier) { if (event.modifiers & Qt.KeypadModifier) {
if (event.key === Qt.Key_0) { if (event.key === Qt.Key_0) {
keypadKeyPressedAtIndex(10) keypadKeyPressedAtIndex(10)
event.accepted = true
} }
if (event.key === Qt.Key_1) { if (event.key === Qt.Key_1) {
keypadKeyPressedAtIndex(0) keypadKeyPressedAtIndex(0)
event.accepted = true
} }
if (event.key === Qt.Key_2) { if (event.key === Qt.Key_2) {
keypadKeyPressedAtIndex(1) keypadKeyPressedAtIndex(1)
event.accepted = true
} }
if (event.key === Qt.Key_3) { if (event.key === Qt.Key_3) {
keypadKeyPressedAtIndex(2) keypadKeyPressedAtIndex(2)
event.accepted = true
} }
if (event.key === Qt.Key_4) { if (event.key === Qt.Key_4) {
keypadKeyPressedAtIndex(3) keypadKeyPressedAtIndex(3)
event.accepted = true
} }
if (event.key === Qt.Key_5) { if (event.key === Qt.Key_5) {
keypadKeyPressedAtIndex(4) keypadKeyPressedAtIndex(4)
event.accepted = true
} }
if (event.key === Qt.Key_6) { if (event.key === Qt.Key_6) {
keypadKeyPressedAtIndex(5) keypadKeyPressedAtIndex(5)
event.accepted = true
} }
if (event.key === Qt.Key_7) { if (event.key === Qt.Key_7) {
keypadKeyPressedAtIndex(6) keypadKeyPressedAtIndex(6)
event.accepted = true
} }
if (event.key === Qt.Key_8) { if (event.key === Qt.Key_8) {
keypadKeyPressedAtIndex(7) keypadKeyPressedAtIndex(7)
event.accepted = true
} }
if (event.key === Qt.Key_9) { if (event.key === Qt.Key_9) {
keypadKeyPressedAtIndex(8) keypadKeyPressedAtIndex(8)
event.accepted = true
} }
if (event.key === Qt.Key_Asterisk) { if (event.key === Qt.Key_Asterisk) {
keypadKeyPressedAtIndex(9) keypadKeyPressedAtIndex(9)
event.accepted = true
} }
if (event.key === Qt.Key_Plus) { if (event.key === Qt.Key_Plus) {
mainItem.buttonPressed("+") mainItem.buttonPressed("+")
event.accepted = true
} }
if (event.key === Qt.Key_Enter) { if (event.key === Qt.Key_Enter) {
mainItem.launchCall() mainItem.launchCall()
event.accepted = true
} }
} }
if (event.key === Qt.Key_Backspace) { if (event.key === Qt.Key_Backspace) {
mainItem.wipe() mainItem.wipe()
event.accepted = true
} }
} }

View file

@ -93,14 +93,26 @@ AbstractWindow {
} }
} }
onClosing: close => { onClosing: close => {
DesktopToolsCpp.screenSaverStatus = true DesktopToolsCpp.screenSaverStatus = true
if (callsModel.haveCall) { if (callsModel.haveCall) {
close.accepted = false close.accepted = false
terminateAllCallsDialog.open() terminateAllCallsDialog.open()
} }
if (middleItemStackView.currentItem.objectName === "waitingRoom") if (middleItemStackView.currentItem.objectName === "waitingRoom")
middleItemStackView.replace(inCallItem) middleItemStackView.replace(inCallItem)
} }
Connections {
enabled: activeFocusItem !== null
target: activeFocusItem.Keys
function onPressed(event) {
if (rightPanel.contentLoader.item && rightPanel.contentLoader.item.objectName === "dialerPanel"){
mainWindow.keyPressedOnDialer(event)
}
}
}
signal keyPressedOnDialer(KeyEvent event)
function changeLayout(layoutIndex) { function changeLayout(layoutIndex) {
if (layoutIndex == 0) { if (layoutIndex == 0) {
@ -319,16 +331,18 @@ AbstractWindow {
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: DefaultStyle.grey_900 color: DefaultStyle.grey_900
Keys.onEscapePressed: { focus: true
if (mainWindow.visibility == Window.FullScreen)
Keys.onPressed: (event) => {
if ((event.key === Qt.Key_Escape || event.key === Qt.Key_Return) && mainWindow.visibility == Window.FullScreen)
mainWindow.showNormal() mainWindow.showNormal()
} }
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: Utils.getSizeWithScreenRatio(10)
anchors.bottomMargin: Utils.getSizeWithScreenRatio(10) anchors.bottomMargin: Utils.getSizeWithScreenRatio(10)
anchors.topMargin: Utils.getSizeWithScreenRatio(10) anchors.topMargin: Utils.getSizeWithScreenRatio(10)
spacing: Utils.getSizeWithScreenRatio(10)
Item { Item {
id: headerItem id: headerItem
Layout.margins: Utils.getSizeWithScreenRatio(10) Layout.margins: Utils.getSizeWithScreenRatio(10)
@ -359,20 +373,17 @@ AbstractWindow {
? AppIcons.arrowUpRight ? AppIcons.arrowUpRight
: AppIcons.arrowDownLeft : AppIcons.arrowDownLeft
colorizationColor: !mainWindow.call colorizationColor: !mainWindow.call
|| mainWindow.call.core.paused || mainWindow.call.core.paused
|| mainWindow.callState || mainWindow.callState
=== LinphoneEnums.CallState.Paused === LinphoneEnums.CallState.Paused
|| mainWindow.callState || mainWindow.callState
=== LinphoneEnums.CallState.PausedByRemote === LinphoneEnums.CallState.PausedByRemote
|| mainWindow.callState || mainWindow.callState
=== LinphoneEnums.CallState.End === LinphoneEnums.CallState.End
|| mainWindow.callState || mainWindow.callState
=== LinphoneEnums.CallState.Released === LinphoneEnums.CallState.Released
|| mainWindow.conference ? DefaultStyle.danger_500_main : mainWindow.call.core.dir === LinphoneEnums.CallDir.Outgoing ? DefaultStyle.info_500_main : DefaultStyle.success_500_main || mainWindow.conference ? DefaultStyle.danger_500_main : mainWindow.call.core.dir === LinphoneEnums.CallDir.Outgoing ? DefaultStyle.info_500_main : DefaultStyle.success_500_main
onColorizationColorChanged: {
callStatusIcon.active = !callStatusIcon.active
callStatusIcon.active = !callStatusIcon.active
}
} }
ColumnLayout { ColumnLayout {
spacing: Utils.getSizeWithScreenRatio(6) spacing: Utils.getSizeWithScreenRatio(6)
@ -921,6 +932,69 @@ AbstractWindow {
UtilsCpp.createCall(dialerTextInput.text) UtilsCpp.createCall(dialerTextInput.text)
} }
Component.onCompleted: parent.height = height Component.onCompleted: parent.height = height
Connections {
target: mainWindow
function onKeyPressedOnDialer(event) {
if (event.modifiers & Qt.KeypadModifier) {
if (event.key === Qt.Key_0) {
numPad.keypadKeyPressedAtIndex(10)
event.accepted = true
}
if (event.key === Qt.Key_1) {
numPad.keypadKeyPressedAtIndex(0)
event.accepted = true
}
if (event.key === Qt.Key_2) {
numPad.keypadKeyPressedAtIndex(1)
event.accepted = true
}
if (event.key === Qt.Key_3) {
numPad.keypadKeyPressedAtIndex(2)
event.accepted = true
}
if (event.key === Qt.Key_4) {
numPad.keypadKeyPressedAtIndex(3)
event.accepted = true
}
if (event.key === Qt.Key_5) {
numPad.keypadKeyPressedAtIndex(4)
event.accepted = true
}
if (event.key === Qt.Key_6) {
numPad.keypadKeyPressedAtIndex(5)
event.accepted = true
}
if (event.key === Qt.Key_7) {
numPad.keypadKeyPressedAtIndex(6)
event.accepted = true
}
if (event.key === Qt.Key_8) {
numPad.keypadKeyPressedAtIndex(7)
event.accepted = true
}
if (event.key === Qt.Key_9) {
numPad.keypadKeyPressedAtIndex(8)
event.accepted = true
}
if (event.key === Qt.Key_Asterisk) {
numPad.keypadKeyPressedAtIndex(9)
event.accepted = true
}
if (event.key === Qt.Key_Plus) {
numPad.buttonPressed("+")
event.accepted = true
}
if (event.key === Qt.Key_Enter) {
numPad.launchCall()
event.accepted = true
}
}
if (event.key === Qt.Key_Backspace) {
numPad.wipe()
event.accepted = true
}
}
}
} }
} }
} }
@ -932,9 +1006,9 @@ AbstractWindow {
objectName: "changeLayoutPanel" objectName: "changeLayoutPanel"
width: parent.width width: parent.width
Keys.onEscapePressed: event => { Keys.onEscapePressed: event => {
rightPanel.visible = false rightPanel.visible = false
event.accepted = true event.accepted = true
} }
call: mainWindow.call call: mainWindow.call
onChangeLayoutRequested: index => { onChangeLayoutRequested: index => {
mainWindow.changeLayout(index) mainWindow.changeLayout(index)
@ -946,9 +1020,9 @@ AbstractWindow {
ColumnLayout { ColumnLayout {
objectName: "callListPanel" objectName: "callListPanel"
Keys.onEscapePressed: event => { Keys.onEscapePressed: event => {
rightPanel.visible = false rightPanel.visible = false
event.accepted = true event.accepted = true
} }
spacing: 0 spacing: 0
Component { Component {
id: mergeCallPopupButton id: mergeCallPopupButton