Skip to content

Commit

Permalink
[DialerPage] Make some order
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Oct 22, 2023
1 parent a6827ee commit 58cc723
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 241 deletions.
207 changes: 207 additions & 0 deletions src/qml/components/Dialer.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
/*
* Copyright 2014 Aleksi Suomalainen <[email protected]>
* Copyright (C) 2023 Chupligin Sergey <[email protected]>
*
* 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)
}
}

}
}

2 changes: 1 addition & 1 deletion src/qml/glacier-dialer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import "components"
ApplicationWindow
{
id: main
initialPage: FirstPage {
initialPage: DialerPage {
id: pageItem
}

Expand Down
4 changes: 2 additions & 2 deletions src/qml/glacier-dialer.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<file>pages/CallView.qml</file>
<file>pages/ContactDelegate.qml</file>
<file>pages/ContactDetails.qml</file>
<file>pages/DialerPage.qml</file>
<file>pages/FirstPage.qml</file>
<file>pages/ContactsPage.qml</file>
<file>pages/CallLogPage.qml</file>
<file>components/Dialer.qml</file>
<file>pages/DialerPage.qml</file>
</qresource>
</RCC>
2 changes: 1 addition & 1 deletion src/qml/pages/ContactsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.nemomobile.qmlcontacts 1.0
import "../components"

Page {
id: contacts
id: contactsPage

signal selectContact(string number)

Expand Down
Loading

0 comments on commit 58cc723

Please sign in to comment.