Commit 9f1b5df9 authored by Nicolas Fella's avatar Nicolas Fella Committed by Jonah Brüchert

Move add contact UI from sheet to a page

parent 490a263e
/*
* Copyright 2018 Fabian Riethmayer
* Copyright 2019 Nicolas Fella <nicolas.fella@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
......@@ -16,15 +16,15 @@
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.2
import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
import QtGraphicalEffects 1.0
ColumnLayout {
id: root
spacing: 2 * Kirigami.Units.largeSpacing
Kirigami.Page {
title: state === "create" ? i18n("Add contact") : i18n("Edit contact")
property string personUri
......@@ -37,56 +37,41 @@ ColumnLayout {
}
]
Label {
id: header
text: i18n("Edit details")
font.pointSize: 16
actions {
main: Kirigami.Action {
icon.name: "dialog-ok-apply"
text: i18n("Save")
onTriggered: {
if (root.state === "create") {
phonebook.addContact(firstname.text + " " + lastname.text, phoneNumber.text, email.text)
}
else if (root.state === "update") {
phonebook.updateContact(root.personUri, firstname.text + " " + lastname.text, phoneNumber.text, email.text)
}
pageStack.pop()
}
}
}
Kirigami.FormLayout {
id: form
Layout.fillWidth: true
anchors.fill: parent
TextField {
Kirigami.FormData.label: i18n("Firstname:")
Kirigami.FormData.label: i18n("First name:")
id: firstname
}
TextField {
Kirigami.FormData.label: i18n("Lastname:")
Kirigami.FormData.label: i18n("Last name:")
id: lastname
}
TextField {
id: phoneNumber
Kirigami.FormData.label: i18n("Phone")
Kirigami.FormData.label: i18n("Phone:")
}
TextField {
id: email
Kirigami.FormData.label: i18n("Email")
}
Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Email:")
}
}
Button {
text: "Save"
Layout.alignment: Qt.AlignRight
anchors.rightMargin: Kirigami.Units.largeSpacing
onClicked: {
if (root.state === "create") {
phonebook.addContact(firstname.text + " " + lastname.text, phoneNumber.text, email.text)
}
else if (root.state === "update") {
phonebook.updateContact(root.personUri, firstname.text + " " + lastname.text, phoneNumber.text, email.text)
}
firstname.text = ""
lastname.text = ""
phoneNumber.text = ""
email.text = ""
formSheet.close()
}
}
}
......@@ -37,17 +37,12 @@ Kirigami.ScrollablePage {
color: Kirigami.Theme.backgroundColor
}
FormPage {
id: form
}
actions {
main: Kirigami.Action {
icon.name: "contact-new-symbolic"
text: i18n("Create new")
onTriggered: {
form.state = "create"
form.open()
pageStack.push(Qt.resolvedUrl("AddContactPage.qml"), {state: "create"})
}
}
}
......
/*
* Copyright 2018 Fabian Riethmayer
*
* This program 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, or
* (at your option) any later version.
*
* This program 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 program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
Kirigami.OverlaySheet {
Kirigami.Theme.colorSet: Kirigami.Theme.View
id: formSheet
Layout.fillWidth: true
property alias state: form.state
property alias personUri: form.personUri
background: Rectangle {
color: Kirigami.Theme.backgroundColor
}
Form {
id: form
}
/*actions {
main: Kirigami.Action {
iconName: "dialog-ok-apply"
//onTriggered: d.state = "large"
}
}
/*contextualActions: [
Kirigami.Action {
iconName: "edit"
text: "Action text"
}
]*/
}
......@@ -6,9 +6,8 @@
<file alias="RoundImage.qml">contents/ui/RoundImage.qml</file>
<file alias="Detail.qml">contents/ui/Detail.qml</file>
<file alias="DetailPage.qml">contents/ui/DetailPage.qml</file>
<file alias="FormPage.qml">contents/ui/FormPage.qml</file>
<file alias="lib/Header.qml">contents/ui/lib/Header.qml</file>
<file alias="Form.qml">contents/ui/Form.qml</file>
<file alias="AddContactPage.qml">contents/ui/AddContactPage.qml</file>
<file alias="DetailListItem.qml">contents/ui/DetailListItem.qml</file>
</qresource>
</RCC>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment