mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-01 17:24:48 +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 {
|
Dialpad {
|
||||||
width: topFlickable.width
|
width: topFlickable.width
|
||||||
height: topFlickable.height
|
height: topFlickable.height
|
||||||
|
|
||||||
callback: function (string) {
|
|
||||||
//TODO
|
|
||||||
// ofonoWrapper.sendToneToCall(string);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,27 +54,14 @@ Kirigami.Page {
|
||||||
Layout.minimumHeight: units.gridUnit * 3
|
Layout.minimumHeight: units.gridUnit * 3
|
||||||
Layout.maximumHeight: Layout.minimumHeight
|
Layout.maximumHeight: Layout.minimumHeight
|
||||||
font.pixelSize: units.gridUnit * 2.3
|
font.pixelSize: units.gridUnit * 2.3
|
||||||
|
|
||||||
|
text: dialerUtils.formatNumber(dialPad.number)
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialpad {
|
Dialpad {
|
||||||
|
id: dialPad
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: 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.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
signal clicked(string text)
|
||||||
|
|
||||||
property string text
|
property string text
|
||||||
property string sub
|
property string sub
|
||||||
property string display
|
property string display
|
||||||
|
|
@ -55,30 +57,12 @@ Item {
|
||||||
id: mouse
|
id: mouse
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
onPressed: {
|
onClicked: root.clicked(parent.text)
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
var text = parent.sub.length > 0 ? parent.sub : parent.text
|
var text = parent.sub.length > 0 ? parent.sub : parent.text
|
||||||
if (pad.callback && text.length === 1) {
|
if (text.length === 1) {
|
||||||
pad.callback(text);
|
root.clicked(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
signal pressed()
|
||||||
|
|
||||||
property var callback
|
property var callback
|
||||||
property var pressedCallback
|
|
||||||
property var releasedCallback
|
|
||||||
property string sub
|
property string sub
|
||||||
property alias source: icon.source
|
property alias source: icon.source
|
||||||
property alias text: label.text
|
property alias text: label.text
|
||||||
|
|
@ -72,27 +72,6 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouse
|
id: mouse
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: buttonRoot.pressed()
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,31 +31,29 @@ GridLayout {
|
||||||
Layout.leftMargin: Kirigami.Units.largeSpacing * 2
|
Layout.leftMargin: Kirigami.Units.largeSpacing * 2
|
||||||
Layout.rightMargin: Kirigami.Units.largeSpacing * 2
|
Layout.rightMargin: Kirigami.Units.largeSpacing * 2
|
||||||
|
|
||||||
property var callback
|
property string number
|
||||||
property var pressedCallback
|
|
||||||
property var releasedCallback
|
|
||||||
property var deleteCallback
|
|
||||||
|
|
||||||
DialerButton { id: one; text: "1" }
|
DialerButton { id: one; text: "1"; onClicked: pad.number += text }
|
||||||
DialerButton { text: "2"; sub: "ABC" }
|
DialerButton { text: "2"; sub: "ABC"; onClicked: pad.number += text }
|
||||||
DialerButton { text: "3"; sub: "DEF" }
|
DialerButton { text: "3"; sub: "DEF"; onClicked: pad.number += text }
|
||||||
|
|
||||||
DialerButton { text: "4"; sub: "GHI" }
|
DialerButton { text: "4"; sub: "GHI"; onClicked: pad.number += text }
|
||||||
DialerButton { text: "5"; sub: "JKL" }
|
DialerButton { text: "5"; sub: "JKL"; onClicked: pad.number += text }
|
||||||
DialerButton { text: "6"; sub: "MNO" }
|
DialerButton { text: "6"; sub: "MNO"; onClicked: pad.number += text }
|
||||||
|
|
||||||
DialerButton { text: "7"; sub: "PQRS" }
|
DialerButton { text: "7"; sub: "PQRS"; onClicked: pad.number += text }
|
||||||
DialerButton { text: "8"; sub: "TUV" }
|
DialerButton { text: "8"; sub: "TUV"; onClicked: pad.number += text }
|
||||||
DialerButton { text: "9"; sub: "WXYZ" }
|
DialerButton { text: "9"; sub: "WXYZ"; onClicked: pad.number += text }
|
||||||
|
|
||||||
DialerButton { display: "*"; text: "*"; special: true; }
|
DialerButton { display: "*"; text: "*"; special: true; onClicked: pad.number += text }
|
||||||
DialerButton { text: "0"; subdisplay: "+"; sub: "+"; }
|
DialerButton { text: "0"; subdisplay: "+"; sub: "+"; onClicked: pad.number += text }
|
||||||
DialerButton { display: "#"; text: "#"; special: true; }
|
DialerButton { display: "#"; text: "#"; special: true; onClicked: pad.number += text }
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|
||||||
DialerIconButton {
|
DialerIconButton {
|
||||||
id: callButton
|
id: callButton
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
@ -65,9 +63,7 @@ GridLayout {
|
||||||
opacity: enabled ? 1 : 0.5
|
opacity: enabled ? 1 : 0.5
|
||||||
source: "call-start"
|
source: "call-start"
|
||||||
size: Kirigami.Units.gridUnit * 3
|
size: Kirigami.Units.gridUnit * 3
|
||||||
callback: function() {
|
onPressed: call(status.text)
|
||||||
call(status.text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DialerIconButton {
|
DialerIconButton {
|
||||||
id: delButton
|
id: delButton
|
||||||
|
|
@ -78,6 +74,8 @@ GridLayout {
|
||||||
opacity: enabled ? 1 : 0.5
|
opacity: enabled ? 1 : 0.5
|
||||||
source: "edit-clear"
|
source: "edit-clear"
|
||||||
size: Kirigami.Units.gridUnit * 2
|
size: Kirigami.Units.gridUnit * 2
|
||||||
callback: pad.deleteCallback
|
onPressed: {
|
||||||
|
pad.number = pad.number.slice(0, -1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue