mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-03 22:56:49 +00:00
feat(scripts/utils): supports window creation and returned status
This commit is contained in:
parent
057ef4d566
commit
05d701fa37
7 changed files with 147 additions and 13 deletions
|
|
@ -1,6 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE TS>
|
<!DOCTYPE TS>
|
||||||
<TS version="2.1">
|
<TS version="2.1">
|
||||||
|
<context>
|
||||||
|
<name>ConfirmDialog</name>
|
||||||
|
<message>
|
||||||
|
<source>cancel</source>
|
||||||
|
<translation>CANCEL</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>confirm</source>
|
||||||
|
<translation>CONFIRM</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DropZone</name>
|
<name>DropZone</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
@ -33,6 +44,14 @@
|
||||||
<source>addContact</source>
|
<source>addContact</source>
|
||||||
<translation>ADD CONTACT</translation>
|
<translation>ADD CONTACT</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>removeContactDescription</source>
|
||||||
|
<translation>Do you really want remove this contact from your book?</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>removeContactTitle</source>
|
||||||
|
<translation>Delete confirmation</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>conversation</name>
|
<name>conversation</name>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE TS>
|
<!DOCTYPE TS>
|
||||||
<TS version="2.1">
|
<TS version="2.1">
|
||||||
|
<context>
|
||||||
|
<name>ConfirmDialog</name>
|
||||||
|
<message>
|
||||||
|
<source>cancel</source>
|
||||||
|
<translation>ANNULER</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>confirm</source>
|
||||||
|
<translation>CONFIRMER</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DropZone</name>
|
<name>DropZone</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
@ -33,6 +44,14 @@
|
||||||
<source>addContact</source>
|
<source>addContact</source>
|
||||||
<translation>AJOUTER CONTACT</translation>
|
<translation>AJOUTER CONTACT</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>removeContactDescription</source>
|
||||||
|
<translation>Voulez-vous vraiment supprimer ce contact de votre carnet ?</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>removeContactTitle</source>
|
||||||
|
<translation>Confirmation de la suppression</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>conversation</name>
|
<name>conversation</name>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
<file>ui/components/contact/Contact.qml</file>
|
<file>ui/components/contact/Contact.qml</file>
|
||||||
<file>ui/components/contact/ShortContactDescription.qml</file>
|
<file>ui/components/contact/ShortContactDescription.qml</file>
|
||||||
<file>ui/components/contact/Avatar.qml</file>
|
<file>ui/components/contact/Avatar.qml</file>
|
||||||
|
<file>ui/components/dialog/ConfirmDialog.qml</file>
|
||||||
<file>ui/components/dialog/DialogDescription.qml</file>
|
<file>ui/components/dialog/DialogDescription.qml</file>
|
||||||
<file>ui/components/dialog/DialogPlus.qml</file>
|
<file>ui/components/dialog/DialogPlus.qml</file>
|
||||||
<file>ui/components/form/CheckBoxText.qml</file>
|
<file>ui/components/form/CheckBoxText.qml</file>
|
||||||
|
|
|
||||||
24
tests/ui/components/dialog/ConfirmDialog.qml
Normal file
24
tests/ui/components/dialog/ConfirmDialog.qml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import QtQuick 2.7
|
||||||
|
|
||||||
|
import 'qrc:/ui/components/form'
|
||||||
|
|
||||||
|
// ===================================================================
|
||||||
|
|
||||||
|
DialogPlus {
|
||||||
|
buttons: [
|
||||||
|
DarkButton {
|
||||||
|
onClicked: exit(0)
|
||||||
|
text: qsTr('cancel')
|
||||||
|
},
|
||||||
|
DarkButton {
|
||||||
|
onClicked: exit(1)
|
||||||
|
text: qsTr('confirm')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
centeredButtons: true
|
||||||
|
id: dialog
|
||||||
|
maximumWidth: 370
|
||||||
|
maximumHeight: 150
|
||||||
|
minimumWidth: 370
|
||||||
|
minimumHeight: 150
|
||||||
|
}
|
||||||
|
|
@ -12,8 +12,24 @@ Window {
|
||||||
property alias descriptionText: description.text // Optionnal.
|
property alias descriptionText: description.text // Optionnal.
|
||||||
property bool centeredButtons // Optionnal.
|
property bool centeredButtons // Optionnal.
|
||||||
|
|
||||||
|
property bool disableExitStatus // Internal property.
|
||||||
|
|
||||||
|
signal exitStatus (int status)
|
||||||
|
|
||||||
modality: Qt.WindowModal
|
modality: Qt.WindowModal
|
||||||
|
|
||||||
|
// Handle normal windows close.
|
||||||
|
onClosing: !disableExitStatus && exitStatus(0)
|
||||||
|
|
||||||
|
// Derived class must use this function instead of close.
|
||||||
|
function exit (status) {
|
||||||
|
if (!disableExitStatus) {
|
||||||
|
disableExitStatus = true
|
||||||
|
exitStatus(status)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,64 @@
|
||||||
// Contains many common helpers.
|
// Contains many common helpers.
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
function openWindow (windowName, parent) {
|
// Load by default a window in the ui/views folder.
|
||||||
|
// If options.isString is equals to true, a marshalling component can
|
||||||
|
// be used.
|
||||||
|
//
|
||||||
|
// Supported options: isString, exitHandler.
|
||||||
|
//
|
||||||
|
// If exitHandler is used, window must implement returnedValue
|
||||||
|
// signal.
|
||||||
|
function openWindow (window, parent, options) {
|
||||||
|
var object
|
||||||
|
if (options && options.isString) {
|
||||||
|
object = Qt.createQmlObject(window, parent)
|
||||||
|
} else {
|
||||||
var component = Qt.createComponent(
|
var component = Qt.createComponent(
|
||||||
'qrc:/ui/views/' + windowName + '.qml'
|
'qrc:/ui/views/' + window + '.qml'
|
||||||
);
|
)
|
||||||
|
|
||||||
if (component.status !== Component.Ready) {
|
if (component.status !== Component.Ready) {
|
||||||
console.debug('Window ' + windowName + ' not ready.')
|
console.debug('Window not ready.')
|
||||||
if(component.status === Component.Error) {
|
if(component.status === Component.Error) {
|
||||||
console.debug('Error:' + component.errorString())
|
console.debug('Error:' + component.errorString())
|
||||||
}
|
}
|
||||||
} else {
|
return // Error.
|
||||||
component.createObject(parent).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object = component.createObject(parent)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.debug('Open window.')
|
||||||
|
|
||||||
|
object.closing.connect(function () {
|
||||||
|
console.debug('Destroy window.')
|
||||||
|
object.destroy()
|
||||||
|
})
|
||||||
|
|
||||||
|
if (options && options.exitHandler) {
|
||||||
|
object.exitStatus.connect(
|
||||||
|
// Bind to access parent properties.
|
||||||
|
options.exitHandler.bind(parent)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
object.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Display a simple ConfirmDialog component. Wrap the openWindow function.
|
||||||
|
function openConfirmDialog (parent, options) {
|
||||||
|
openWindow(
|
||||||
|
'import QtQuick 2.7;' +
|
||||||
|
'import \'qrc:/ui/components/dialog\';' +
|
||||||
|
'ConfirmDialog {' +
|
||||||
|
'descriptionText: \'' + options.descriptionText + '\';' +
|
||||||
|
'title: \'' + options.title + '\'' +
|
||||||
|
'}',
|
||||||
|
parent, {
|
||||||
|
isString: true,
|
||||||
|
exitHandler: options.exitHandler
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import 'qrc:/ui/components/contact'
|
||||||
import 'qrc:/ui/components/form'
|
import 'qrc:/ui/components/form'
|
||||||
import 'qrc:/ui/components/scrollBar'
|
import 'qrc:/ui/components/scrollBar'
|
||||||
|
|
||||||
|
import 'qrc:/ui/scripts/utils.js' as Utils
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
||||||
|
|
@ -169,7 +171,7 @@ ColumnLayout {
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: 15
|
anchors.leftMargin: 15
|
||||||
anchors.rightMargin: 15
|
anchors.rightMargin: 25
|
||||||
spacing: 15
|
spacing: 15
|
||||||
|
|
||||||
// Avatar.
|
// Avatar.
|
||||||
|
|
@ -233,7 +235,13 @@ ColumnLayout {
|
||||||
ActionButton {
|
ActionButton {
|
||||||
iconSize: parent.height
|
iconSize: parent.height
|
||||||
icon: 'delete'
|
icon: 'delete'
|
||||||
onClicked: console.log('action: delete')
|
onClicked: Utils.openConfirmDialog(contact, {
|
||||||
|
descriptionText: qsTr('removeContactDescription'),
|
||||||
|
exitHandler: function (status) {
|
||||||
|
console.log('remove contact', status)
|
||||||
|
},
|
||||||
|
title: qsTr('removeContactTitle')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue