Fix numeric pad buttons : link search bars with a numeric pad popup.

This commit is contained in:
Julien Wadel 2024-10-24 10:19:58 +02:00
parent ea8d2aafe7
commit 0b91d8c986
4 changed files with 20 additions and 30 deletions

View file

@ -19,7 +19,7 @@ FocusScope {
readonly property bool hasActiveFocus: textField.activeFocus readonly property bool hasActiveFocus: textField.activeFocus
property alias color: backgroundItem.color property alias color: backgroundItem.color
onVisibleChanged: if (!visible && numericPadPopup) numericPadPopup.close() signal openNumericPadRequested()// Useful for redirection before displaying numeric pad.
function clearText() { function clearText() {
textField.text = "" textField.text = ""
@ -28,8 +28,6 @@ FocusScope {
Connections { Connections {
enabled: numericPadPopup != undefined enabled: numericPadPopup != undefined
target: numericPadPopup ? numericPadPopup : null target: numericPadPopup ? numericPadPopup : null
function onAboutToHide() { mainItem.numericPadButton.checked = false }
function onAboutToShow() { mainItem.numericPadButton.checked = true }
function onButtonPressed(text) { function onButtonPressed(text) {
console.log("text", text) console.log("text", text)
textField.text += text textField.text += text
@ -89,8 +87,7 @@ FocusScope {
Button { Button {
id: dialerButton id: dialerButton
visible: numericPadPopup != undefined && textField.text.length === 0 visible: numericPadPopup != undefined && textField.text.length === 0
checkable: true checked: numericPadPopup?.visible || false
checked: false
background: Rectangle { background: Rectangle {
color: "transparent" color: "transparent"
} }
@ -102,6 +99,12 @@ FocusScope {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15 * DefaultStyle.dp anchors.rightMargin: 15 * DefaultStyle.dp
onClicked: {
if(!checked){
mainItem.openNumericPadRequested()
mainItem.numericPadPopup.open()
} else mainItem.numericPadPopup.close()
}
} }
Button { Button {
id: clearTextButton id: clearTextButton

View file

@ -157,13 +157,9 @@ Item {
focusedBorderColor: DefaultStyle.main1_500_main focusedBorderColor: DefaultStyle.main1_500_main
numericPadButton.visible: text.length === 0 numericPadButton.visible: text.length === 0
numericPadButton.checkable: false numericPadButton.checkable: false
Connections {
target: magicSearchBar.numericPadButton onOpenNumericPadRequested:mainItem.goToNewCall()
function onClicked() {
mainItem.goToNewCall()
mainItem.openNumPadRequest()
}
}
Connections { Connections {
target: mainItem target: mainItem
function onCallCreated() { function onCallCreated() {
@ -609,6 +605,9 @@ Item {
onCreateContactRequested: (name, address) => { onCreateContactRequested: (name, address) => {
mainItem.createContact(name, address) mainItem.createContact(name, address)
} }
Component.onCompleted: {
magicSearchBar.numericPadPopup = callPage.numericPadPopup
}
} }
ContactPage{ ContactPage{
id: contactPage id: contactPage

View file

@ -34,6 +34,8 @@ AbstractMainPage {
signal createContactRequested(string name, string address) signal createContactRequested(string name, string address)
signal openNumPadRequest() signal openNumPadRequest()
property alias numericPadPopup: numericPadPopupItem
Connections { Connections {
enabled: confInfoGui enabled: confInfoGui
target: confInfoGui ? confInfoGui.core : null target: confInfoGui ? confInfoGui.core : null
@ -111,7 +113,7 @@ AbstractMainPage {
anchors.right: parent.right anchors.right: parent.right
height: 402 * DefaultStyle.dp height: 402 * DefaultStyle.dp
NumericPadPopup { NumericPadPopup {
id: numericPadPopup id: numericPadPopupItem
width: parent.width width: parent.width
height: parent.height height: parent.height
visible: false visible: false
@ -479,7 +481,7 @@ AbstractMainPage {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
focus: true focus: true
numPadPopup: numericPadPopup numPadPopup: numericPadPopupItem
groupCallVisible: true groupCallVisible: true
searchBarColor: DefaultStyle.grey_100 searchBarColor: DefaultStyle.grey_100
onContactClicked: (contact) => { onContactClicked: (contact) => {
@ -492,13 +494,6 @@ AbstractMainPage {
Connections { Connections {
target: mainItem target: mainItem
function onCreateCallFromSearchBarRequested(){ UtilsCpp.createCall(callContactsList.searchBar.text)} function onCreateCallFromSearchBarRequested(){ UtilsCpp.createCall(callContactsList.searchBar.text)}
function onOpenNumPadRequest(){ if (!callContactsList.searchBar.numericPadButton.checked) callContactsList.searchBar.numericPadButton.checked = true}
}
Binding {
target: numericPadPopup
property: "visible"
value: true
when: callContactsList.searchBar.numericPadButton.checked
} }
} }
} }

View file

@ -596,13 +596,6 @@ AbstractWindow {
) )
} }
numPadPopup: numPadPopup numPadPopup: numPadPopup
Binding {
target: numPadPopup
property: "visible"
value: true
when: newCallForm.searchBar.numericPadButton.checked
restoreMode: Binding.RestoreValue
}
NumericPadPopup { NumericPadPopup {
id: numPadPopup id: numPadPopup