simulate numeric pad button pressed when pressing numeric key on keyboard in new call form #LINQT-2313

This commit is contained in:
Gaelle Braud 2026-01-13 15:19:36 +01:00
parent 2e7c250d8d
commit 16703ec2d5
6 changed files with 73 additions and 59 deletions

View file

@ -5792,13 +5792,13 @@ Um sie in einem kommerziellen Projekt zu aktivieren, kontaktieren Sie uns bitte.
<context> <context>
<name>SearchBar</name> <name>SearchBar</name>
<message> <message>
<location filename="../../view/Control/Input/SearchBar.qml" line="124"/> <location filename="../../view/Control/Input/SearchBar.qml" line="131"/>
<source>open_dialer_acccessibility_label</source> <source>open_dialer_acccessibility_label</source>
<extracomment>&quot;Open dialer&quot;</extracomment> <extracomment>&quot;Open dialer&quot;</extracomment>
<translation>Wähltastatur öffnen</translation> <translation>Wähltastatur öffnen</translation>
</message> </message>
<message> <message>
<location filename="../../view/Control/Input/SearchBar.qml" line="144"/> <location filename="../../view/Control/Input/SearchBar.qml" line="151"/>
<source>clear_text_input_acccessibility_label</source> <source>clear_text_input_acccessibility_label</source>
<extracomment>&quot;Clear text input&quot;</extracomment> <extracomment>&quot;Clear text input&quot;</extracomment>
<translation>Texteingabe löschen</translation> <translation>Texteingabe löschen</translation>

View file

@ -5669,13 +5669,13 @@ To enable them in a commercial project, please contact us.</translation>
<context> <context>
<name>SearchBar</name> <name>SearchBar</name>
<message> <message>
<location filename="../../view/Control/Input/SearchBar.qml" line="124"/> <location filename="../../view/Control/Input/SearchBar.qml" line="131"/>
<source>open_dialer_acccessibility_label</source> <source>open_dialer_acccessibility_label</source>
<extracomment>&quot;Open dialer&quot;</extracomment> <extracomment>&quot;Open dialer&quot;</extracomment>
<translation>Open dialer</translation> <translation>Open dialer</translation>
</message> </message>
<message> <message>
<location filename="../../view/Control/Input/SearchBar.qml" line="144"/> <location filename="../../view/Control/Input/SearchBar.qml" line="151"/>
<source>clear_text_input_acccessibility_label</source> <source>clear_text_input_acccessibility_label</source>
<extracomment>&quot;Clear text input&quot;</extracomment> <extracomment>&quot;Clear text input&quot;</extracomment>
<translation>Clear text input</translation> <translation>Clear text input</translation>

View file

@ -5640,13 +5640,13 @@ Pour les activer dans un projet commercial, merci de nous contacter.</translatio
<context> <context>
<name>SearchBar</name> <name>SearchBar</name>
<message> <message>
<location filename="../../view/Control/Input/SearchBar.qml" line="124"/> <location filename="../../view/Control/Input/SearchBar.qml" line="131"/>
<source>open_dialer_acccessibility_label</source> <source>open_dialer_acccessibility_label</source>
<extracomment>&quot;Open dialer&quot;</extracomment> <extracomment>&quot;Open dialer&quot;</extracomment>
<translation>Ouvrir le numéroteur</translation> <translation>Ouvrir le numéroteur</translation>
</message> </message>
<message> <message>
<location filename="../../view/Control/Input/SearchBar.qml" line="144"/> <location filename="../../view/Control/Input/SearchBar.qml" line="151"/>
<source>clear_text_input_acccessibility_label</source> <source>clear_text_input_acccessibility_label</source>
<extracomment>&quot;Clear text input&quot;</extracomment> <extracomment>&quot;Clear text input&quot;</extracomment>
<translation>Supprimer le texte saisi</translation> <translation>Supprimer le texte saisi</translation>

View file

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

View file

@ -104,6 +104,13 @@ FocusScope {
repeat: false repeat: false
onTriggered: textField.searchText = textField.text onTriggered: textField.searchText = textField.text
} }
Keys.onPressed: (event) => {
event.accepted = false
if (mainItem.numericPadPopup && mainItem.numericPadPopup.opened && (event.modifiers & Qt.KeypadModifier)) {
mainItem.numericPadPopup.keyPadKeyPressed(event)
event.accepted = true
}
}
} }
Button { Button {
id: dialerButton id: dialerButton

View file

@ -20,6 +20,10 @@ Control.Popup {
property var currentCall property var currentCall
onOpened: numPad.forceActiveFocus() onOpened: numPad.forceActiveFocus()
signal buttonPressed(string text) signal buttonPressed(string text)
signal keyPadKeyPressed(KeyEvent event)
onKeyPadKeyPressed: (event) => {
numPad.handleKeyPadEvent(event)
}
signal launchCall() signal launchCall()
signal wipe() signal wipe()
@ -72,7 +76,6 @@ Control.Popup {
lastRowVisible: mainItem.lastRowVisible lastRowVisible: mainItem.lastRowVisible
currentCall: mainItem.currentCall currentCall: mainItem.currentCall
onButtonPressed: (text) => { onButtonPressed: (text) => {
console.log("BUTTON PRESSED NUMPAD")
mainItem.buttonPressed(text) mainItem.buttonPressed(text)
} }
onLaunchCall: mainItem.launchCall() onLaunchCall: mainItem.launchCall()