diff --git a/src/qml/components/Dialer.qml b/src/qml/components/Dialer.qml new file mode 100644 index 0000000..234bb5d --- /dev/null +++ b/src/qml/components/Dialer.qml @@ -0,0 +1,207 @@ +/* + * Copyright 2014 Aleksi Suomalainen + * Copyright (C) 2023 Chupligin Sergey + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +import QtQuick +import QtQuick.Controls + +import Nemo +import Nemo.Controls + +import org.nemomobile.contacts 1.0 +import QOfono 0.2 +import Nemo.Dialogs 1.0 + +import "../components" + +Item { + id: dialer + anchors.fill: parent + + property alias dialerNumber: dialedNumber.text + + OfonoManager { + id: ofonoManager; + } + + OfonoSupplementaryServices { + id: ussd + modemPath: ofonoManager.defaultModem + onUssdResponse: { + console.log("response " + response ) + ussdDialog.headingText = response + ussdDialog.open(); + } + onNotificationReceived: { + console.log("message" + message ) + } + onRequestReceived: { + console.log("message" + message ) + } + + onStateChanged: { + console.log("supplemetary services state " + state) + } + + } + + Dialog { + id: ussdDialog + acceptText: qsTr("Ok") + inline: true + onAccepted: { + close() + dialedNumber.text = "" + } + } + + + Item { + id: numForDialing + height: Theme.itemHeightLarge + width: parent.width + + TextEdit { + id: dialedNumber + width: dialer.width-dialedNumber.height + height: Theme.itemHeightLarge + font.pixelSize: numForDialing.height*0.85 + color: Theme.accentColor + horizontalAlignment: TextEdit.AlignRight + onTextChanged: { + if ((text.length > 2) && (text[text.length-1] === "#")) { + console.log("ussd.initiate("+text+")") + ussd.initiate(text) + } + } + } + + NemoIcon { + width: dialedNumber.height + height: width + source: "image://theme/angle-right" + color: dialedNumberBackspaceMouse.pressed ? Theme.accentColor : Theme.textColor + + anchors{ + left: dialedNumber.right + verticalCenter: dialedNumber.verticalCenter + } + + MouseArea{ + id: dialedNumberBackspaceMouse + anchors.fill: parent + onClicked: { + dialedNumber.text = dialedNumber.text.substring(0, dialedNumber.text.length - 1) + } + onPressAndHold: { + dialedNumber.text = ""; + } + } + } + } + + Grid { + id: dialerButtons + width: parent.width + height: Theme.itemHeightExtraLarge*4 + Theme.itemSpacingLarge*3 + anchors { + bottom: dimmer.top + bottomMargin: Theme.itemSpacingLarge + } + spacing: Theme.itemSpacingLarge + + columns: 3 + rows: 4 + + ListModel { + id: buttonsModel + ListElement { number: "1"; letters: ""; } + ListElement { number: "2"; letters: "ABC"; } + ListElement { number: "3"; letters: "DEF"; } + ListElement { number: "4"; letters: "GHI"; } + ListElement { number: "5"; letters: "JKL"; } + ListElement { number: "6"; letters: "MNO"; } + ListElement { number: "7"; letters: "PQRS"; } + ListElement { number: "8"; letters: "TUV"; } + ListElement { number: "9"; letters: "WXYZ"; } + ListElement { number: "*"; letters: ""; } + ListElement { number: "0"; letters: "+"; } + ListElement { number: "#"; letters: ""; } + } + + Repeater { + model: buttonsModel + delegate: DialerButton { + width: (dialerButtons.width - Theme.itemSpacingLarge*3) /3 + height: Theme.itemHeightExtraLarge + text: model.number + subText: model.letters + onPressed: { + telephone.startDtmfTone(model.number); + dialedNumber.insert(dialedNumber.text.length,model.number) + } + onPressAndHold: { + if (model.number === "0") { + dialedNumber.text = dialedNumber.text.replace(/0$/,"+") // replace last 0 with + + } + } + onReleased: { + telephone.stopDtmfTone(); + } + + } + } + } + + Rectangle { + id: dimmer + + height: Theme.itemHeightLarge+Theme.itemSpacingLarge + width: parent.width-Theme.itemSpacingLarge*2 + color: dimmerMouse.pressed ? Theme.fillDarkColor : "transparent" + radius: Theme.itemSpacingSmall + + anchors{ + bottom: parent.bottom + bottomMargin: Theme.itemSpacingLarge + left: parent.left + leftMargin: Theme.itemSpacingLarge + } + + NemoIcon { + id: callIconBtn + height: Theme.itemHeightLarge + width: height + source: "image://theme/phone" + anchors.centerIn: parent + color: Theme.accentColor + } + + MouseArea { + id: dimmerMouse + anchors.fill: parent + onClicked: { + var normalizedNumber = Person.normalizePhoneNumber(dialedNumber.text) + telephone.dial(telephone.defaultProviderId, normalizedNumber) + } + } + + } +} + diff --git a/src/qml/glacier-dialer.qml b/src/qml/glacier-dialer.qml index 02ae3ee..85231ee 100644 --- a/src/qml/glacier-dialer.qml +++ b/src/qml/glacier-dialer.qml @@ -35,7 +35,7 @@ import "components" ApplicationWindow { id: main - initialPage: FirstPage { + initialPage: DialerPage { id: pageItem } diff --git a/src/qml/glacier-dialer.qrc b/src/qml/glacier-dialer.qrc index fa7be2d..91e8026 100644 --- a/src/qml/glacier-dialer.qrc +++ b/src/qml/glacier-dialer.qrc @@ -9,9 +9,9 @@ pages/CallView.qml pages/ContactDelegate.qml pages/ContactDetails.qml - pages/DialerPage.qml - pages/FirstPage.qml pages/ContactsPage.qml pages/CallLogPage.qml + components/Dialer.qml + pages/DialerPage.qml diff --git a/src/qml/pages/ContactsPage.qml b/src/qml/pages/ContactsPage.qml index 22cd42f..141ac99 100644 --- a/src/qml/pages/ContactsPage.qml +++ b/src/qml/pages/ContactsPage.qml @@ -30,7 +30,7 @@ import org.nemomobile.qmlcontacts 1.0 import "../components" Page { - id: contacts + id: contactsPage signal selectContact(string number) diff --git a/src/qml/pages/DialerPage.qml b/src/qml/pages/DialerPage.qml index 6525433..4b649a2 100644 --- a/src/qml/pages/DialerPage.qml +++ b/src/qml/pages/DialerPage.qml @@ -17,189 +17,44 @@ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ + import QtQuick import QtQuick.Controls import Nemo import Nemo.Controls +import org.nemomobile.voicecall 1.0 import org.nemomobile.contacts 1.0 + import QOfono 0.2 -import Nemo.Dialogs 1.0 import "../components" Page { - id: dialer - - property alias dialerNumber: dialedNumber.text - - OfonoManager { - id: ofonoManager; - } - - OfonoSupplementaryServices { - id: ussd - modemPath: ofonoManager.defaultModem - onUssdResponse: { - console.log("response " + response ) - ussdDialog.headingText = response - ussdDialog.open(); - } - onNotificationReceived: { - console.log("message" + message ) - } - onRequestReceived: { - console.log("message" + message ) - } - - onStateChanged: { - console.log("supplemetary services state " + state) - } - - } - - Dialog { - id: ussdDialog - acceptText: qsTr("Ok") - inline: true - onAccepted: { - close() - dialedNumber.text = "" - } - } - - - Item { - id: numForDialing - height: Theme.itemHeightLarge - width: parent.width - - TextEdit { - id: dialedNumber - width: dialer.width-dialedNumber.height - height: Theme.itemHeightLarge - font.pixelSize: numForDialing.height*0.85 - color: Theme.accentColor - horizontalAlignment: TextEdit.AlignRight - onTextChanged: { - if ((text.length > 2) && (text[text.length-1] === "#")) { - console.log("ussd.initiate("+text+")") - ussd.initiate(text) - } - } - } - - NemoIcon { - width: dialedNumber.height - height: width - source: "image://theme/angle-right" - color: dialedNumberBackspaceMouse.pressed ? Theme.accentColor : Theme.textColor - - anchors{ - left: dialedNumber.right - verticalCenter: dialedNumber.verticalCenter - } - - MouseArea{ - id: dialedNumberBackspaceMouse - anchors.fill: parent + id: dialerPage + headerTools: HeaderToolsLayout { + id: tools + title: qsTr("Dialer") + tools: [ + ToolButton { + iconSource: "image://theme/history" onClicked: { - dialedNumber.text = dialedNumber.text.substring(0, dialedNumber.text.length - 1) - } - onPressAndHold: { - dialedNumber.text = ""; - } - } - } - } - - Grid { - id: dialerButtons - width: parent.width - height: Theme.itemHeightExtraLarge*4 + Theme.itemSpacingLarge*3 - anchors { - bottom: dimmer.top - bottomMargin: Theme.itemSpacingLarge - } - spacing: Theme.itemSpacingLarge - - columns: 3 - rows: 4 - - ListModel { - id: buttonsModel - ListElement { number: "1"; letters: ""; } - ListElement { number: "2"; letters: "ABC"; } - ListElement { number: "3"; letters: "DEF"; } - ListElement { number: "4"; letters: "GHI"; } - ListElement { number: "5"; letters: "JKL"; } - ListElement { number: "6"; letters: "MNO"; } - ListElement { number: "7"; letters: "PQRS"; } - ListElement { number: "8"; letters: "TUV"; } - ListElement { number: "9"; letters: "WXYZ"; } - ListElement { number: "*"; letters: ""; } - ListElement { number: "0"; letters: "+"; } - ListElement { number: "#"; letters: ""; } - } - - Repeater { - model: buttonsModel - delegate: DialerButton { - width: (dialerButtons.width - Theme.itemSpacingLarge*3) /3 - height: Theme.itemHeightExtraLarge - text: model.number - subText: model.letters - onPressed: { - telephone.startDtmfTone(model.number); - dialedNumber.insert(dialedNumber.text.length,model.number) - } - onPressAndHold: { - if (model.number === "0") { - dialedNumber.text = dialedNumber.text.replace(/0$/,"+") // replace last 0 with + - } + main.push(Qt.resolvedUrl("CallLogPage.qml")); } - onReleased: { - telephone.stopDtmfTone(); + }, + ToolButton { + iconSource: "image://theme/search" + onClicked: { + main.push(Qt.resolvedUrl("ContactsPage.qml")); } - } - } + ] } - Rectangle { - id: dimmer - - height: Theme.itemHeightLarge+Theme.itemSpacingLarge - width: parent.width-Theme.itemSpacingLarge*2 - color: dimmerMouse.pressed ? Theme.fillDarkColor : "transparent" - radius: Theme.itemSpacingSmall - - anchors{ - bottom: parent.bottom - bottomMargin: Theme.itemSpacingLarge - left: parent.left - leftMargin: Theme.itemSpacingLarge - } - - NemoIcon { - id: callIconBtn - height: Theme.itemHeightLarge - width: height - source: "image://theme/phone" - anchors.centerIn: parent - color: Theme.accentColor - } - - MouseArea { - id: dimmerMouse - anchors.fill: parent - onClicked: { - var normalizedNumber = Person.normalizePhoneNumber(dialedNumber.text) - telephone.dial(telephone.defaultProviderId, normalizedNumber) - } - } - + Dialer { + id: dialer } } + diff --git a/src/qml/pages/FirstPage.qml b/src/qml/pages/FirstPage.qml deleted file mode 100644 index f6f4ae7..0000000 --- a/src/qml/pages/FirstPage.qml +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2014 Aleksi Suomalainen - * Copyright (C) 2023 Chupligin Sergey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -import QtQuick -import QtQuick.Controls - -import Nemo -import Nemo.Controls - -import org.nemomobile.voicecall 1.0 -import org.nemomobile.contacts 1.0 - -import QOfono 0.2 - -Page { - id: first - headerTools: HeaderToolsLayout { - id: tools - title: qsTr("Dialer") - tools: [ - ToolButton { - iconSource: "image://theme/history" - onClicked: { - main.push(Qt.resolvedUrl("CallLogPage.qml")); - } - }, - ToolButton { - iconSource: "image://theme/search" - onClicked: { - main.push(Qt.resolvedUrl("ContactsPage.qml")); - } - } - ] - } - - DialerPage { - id: dialer_page - } -} - - diff --git a/translations/glacier-dialer_en.ts b/translations/glacier-dialer_en.ts index cce4fc8..f26e5f2 100644 --- a/translations/glacier-dialer_en.ts +++ b/translations/glacier-dialer_en.ts @@ -90,17 +90,17 @@ ContactDetails - + First name - + Last name - + Phone number @@ -119,17 +119,17 @@ - DialerPage + Dialer - + Ok - FirstPage + DialerPage - + Dialer diff --git a/translations/glacier-dialer_ru.ts b/translations/glacier-dialer_ru.ts index 739695f..0f281e6 100644 --- a/translations/glacier-dialer_ru.ts +++ b/translations/glacier-dialer_ru.ts @@ -95,17 +95,17 @@ ContactDetails - + First name Имя - + Last name Фамилия - + Phone number Номер телефона @@ -124,19 +124,26 @@ - DialerPage + Dialer - + Ok + + DialerPage + + + Dialer + Телефон + + FirstPage - Dialer - Телефон + Телефон