mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
Simplify dialer button signal handling
This commit is contained in:
parent
d524bcc576
commit
9f6414a025
5 changed files with 30 additions and 87 deletions
|
|
@ -74,11 +74,6 @@ Kirigami.Page {
|
|||
Dialpad {
|
||||
width: topFlickable.width
|
||||
height: topFlickable.height
|
||||
|
||||
callback: function (string) {
|
||||
//TODO
|
||||
// ofonoWrapper.sendToneToCall(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,27 +54,14 @@ Kirigami.Page {
|
|||
Layout.minimumHeight: units.gridUnit * 3
|
||||
Layout.maximumHeight: Layout.minimumHeight
|
||||
font.pixelSize: units.gridUnit * 2.3
|
||||
|
||||
text: dialerUtils.formatNumber(dialPad.number)
|
||||
}
|
||||
|
||||
Dialpad {
|
||||
id: dialPad
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
callback: function (string) {
|
||||
var newText = status.text + string
|
||||
status.text = dialerUtils.formatNumber(newText);
|
||||
}
|
||||
deleteCallback: function () {
|
||||
var newText = status.text.slice(0, -1)
|
||||
status.text = dialerUtils.formatNumber(newText);
|
||||
}
|
||||
pressedCallback: function (string) {
|
||||
// TODO
|
||||
// ofonoWrapper.startTone(string);
|
||||
}
|
||||
releasedCallback: function (string) {
|
||||
// ofonoWrapper.stopTone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ Item {
|
|||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
signal clicked(string text)
|
||||
|
||||
property string text
|
||||
property string sub
|
||||
property string display
|
||||
|
|
@ -55,30 +57,12 @@ Item {
|
|||
id: mouse
|
||||
anchors.fill: parent
|
||||
|
||||
onPressed: {
|
||||
if (pad.pressedCallback) {
|
||||
pad.pressedCallback(parent.text);
|
||||
}
|
||||
}
|
||||
onReleased: {
|
||||
if (pad.releasedCallback) {
|
||||
pad.releasedCallback(parent.text);
|
||||
}
|
||||
}
|
||||
onCanceled: {
|
||||
if (pad.releasedCallback) {
|
||||
pad.releasedCallback(parent.text);
|
||||
}
|
||||
}
|
||||
onClicked: {
|
||||
if (pad.callback) {
|
||||
pad.callback(parent.text);
|
||||
}
|
||||
}
|
||||
onClicked: root.clicked(parent.text)
|
||||
|
||||
onPressAndHold: {
|
||||
var text = parent.sub.length > 0 ? parent.sub : parent.text
|
||||
if (pad.callback && text.length === 1) {
|
||||
pad.callback(text);
|
||||
if (text.length === 1) {
|
||||
root.clicked(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ Item {
|
|||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
signal pressed()
|
||||
|
||||
property var callback
|
||||
property var pressedCallback
|
||||
property var releasedCallback
|
||||
property string sub
|
||||
property alias source: icon.source
|
||||
property alias text: label.text
|
||||
|
|
@ -72,27 +72,6 @@ Item {
|
|||
MouseArea {
|
||||
id: mouse
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (callback) {
|
||||
callback(parent.text);
|
||||
} else {
|
||||
addNumber(parent.text);
|
||||
}
|
||||
}
|
||||
|
||||
onPressAndHold: {
|
||||
var text;
|
||||
if (longHold.visible) {
|
||||
text = longHold.text;
|
||||
} else {
|
||||
text = parent.text;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(text);
|
||||
} else if (pad.callback) {
|
||||
pad.callback(text);
|
||||
}
|
||||
}
|
||||
onClicked: buttonRoot.pressed()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,31 +31,29 @@ GridLayout {
|
|||
Layout.leftMargin: Kirigami.Units.largeSpacing * 2
|
||||
Layout.rightMargin: Kirigami.Units.largeSpacing * 2
|
||||
|
||||
property var callback
|
||||
property var pressedCallback
|
||||
property var releasedCallback
|
||||
property var deleteCallback
|
||||
property string number
|
||||
|
||||
DialerButton { id: one; text: "1" }
|
||||
DialerButton { text: "2"; sub: "ABC" }
|
||||
DialerButton { text: "3"; sub: "DEF" }
|
||||
DialerButton { id: one; text: "1"; onClicked: pad.number += text }
|
||||
DialerButton { text: "2"; sub: "ABC"; onClicked: pad.number += text }
|
||||
DialerButton { text: "3"; sub: "DEF"; onClicked: pad.number += text }
|
||||
|
||||
DialerButton { text: "4"; sub: "GHI" }
|
||||
DialerButton { text: "5"; sub: "JKL" }
|
||||
DialerButton { text: "6"; sub: "MNO" }
|
||||
DialerButton { text: "4"; sub: "GHI"; onClicked: pad.number += text }
|
||||
DialerButton { text: "5"; sub: "JKL"; onClicked: pad.number += text }
|
||||
DialerButton { text: "6"; sub: "MNO"; onClicked: pad.number += text }
|
||||
|
||||
DialerButton { text: "7"; sub: "PQRS" }
|
||||
DialerButton { text: "8"; sub: "TUV" }
|
||||
DialerButton { text: "9"; sub: "WXYZ" }
|
||||
DialerButton { text: "7"; sub: "PQRS"; onClicked: pad.number += text }
|
||||
DialerButton { text: "8"; sub: "TUV"; onClicked: pad.number += text }
|
||||
DialerButton { text: "9"; sub: "WXYZ"; onClicked: pad.number += text }
|
||||
|
||||
DialerButton { display: "*"; text: "*"; special: true; }
|
||||
DialerButton { text: "0"; subdisplay: "+"; sub: "+"; }
|
||||
DialerButton { display: "#"; text: "#"; special: true; }
|
||||
DialerButton { display: "*"; text: "*"; special: true; onClicked: pad.number += text }
|
||||
DialerButton { text: "0"; subdisplay: "+"; sub: "+"; onClicked: pad.number += text }
|
||||
DialerButton { display: "#"; text: "#"; special: true; onClicked: pad.number += text }
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
DialerIconButton {
|
||||
id: callButton
|
||||
Layout.fillWidth: true
|
||||
|
|
@ -65,9 +63,7 @@ GridLayout {
|
|||
opacity: enabled ? 1 : 0.5
|
||||
source: "call-start"
|
||||
size: Kirigami.Units.gridUnit * 3
|
||||
callback: function() {
|
||||
call(status.text);
|
||||
}
|
||||
onPressed: call(status.text)
|
||||
}
|
||||
DialerIconButton {
|
||||
id: delButton
|
||||
|
|
@ -78,6 +74,8 @@ GridLayout {
|
|||
opacity: enabled ? 1 : 0.5
|
||||
source: "edit-clear"
|
||||
size: Kirigami.Units.gridUnit * 2
|
||||
callback: pad.deleteCallback
|
||||
onPressed: {
|
||||
pad.number = pad.number.slice(0, -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue