Commit 92c389ce authored by Aleksi Suomalainen's avatar Aleksi Suomalainen Committed by GitHub

Merge pull request #55 from neochapay/dialogs

Update QueryDialog
parents a586e787 632cfe08
/****************************************************************************************
**
** Copyright (C) 2014 Aleksi Suomalainen <suomalainen.aleksi@gmail.com>
** Copyright (C) 2017 Chupligin Sergey <neochapay@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
......@@ -34,21 +35,73 @@ import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
import Nemo.Dialogs 1.0
Page {
id: root
headerTools: HeaderToolsLayout { showBackButton: true; title: "Query dialog example" }
headerTools: HeaderToolsLayout { showBackButton: true; title: qsTr("Query dialog example") }
Image {
id: bgImage
source: "/usr/share/glacier-components/images/example.jpg"
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
}
Button {
id: standartButton
anchors{
top: parent.top
margins: 20
horizontalCenter: parent.horizontalCenter
}
text: qsTr("Standart dialog")
onClicked: {
deleteDialog.inline = false
deleteDialog.visible = true
standartButton.visible = false
inlineButton.visible = false
}
}
Button {
id: inlineButton
anchors{
top: standartButton.bottom
margins: 20
horizontalCenter: parent.horizontalCenter
}
text: qsTr("Inline dialog")
onClicked: {
deleteDialog.inline = true
deleteDialog.visible = true
standartButton.visible = false
inlineButton.visible = false
}
}
QueryDialog {
cancelText: "Cancel"
acceptText: "Delete"
headingText: "Are you sure you want to delete this?"
subLabelText: "Continue?"
id: deleteDialog
visible: false
cancelText: qsTr("Cancel")
acceptText: qsTr("Delete")
headingText: qsTr("Are you sure you want to delete this?")
subLabelText: qsTr("Do you want to continue?")
icon: "image://theme/trash"
onAccepted: {
result.text = "User accepted"
result.text = qsTr("User accepted")
}
onCanceled: {
result.text = "User canceled"
result.text = qsTr("User canceled")
}
onSelected: {
standartButton.visible = true
inlineButton.visible = true
visible = false
}
}
Label {
......
......@@ -31,6 +31,7 @@ qml.files += \
qml.path = /usr/share/glacier-components/content
images.files = images/*.png
images.files += images/*.jpg
images.path = /usr/share/glacier-components/images
OTHER_FILES += $$qml.files
......
......@@ -24,7 +24,8 @@ QML_FILES += \
qml/GlacierRollerItem.qml \
qml/InverseMouseArea.qml \
qml/IconButton.qml \
qml/DatePicker.qml
qml/DatePicker.qml \
qml/dialogs/QueryDialog.qml
OTHER_FILES += qmldir \
$$QML_FILES
......@@ -59,7 +60,11 @@ qmlfiles.files = $$_PRO_FILE_PWD_/qml/*.qml
qmlfiles.files += $$_PRO_FILE_PWD_/qml/qmldir
qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
dialogs.files = $$_PRO_FILE_PWD_/qml/dialogs/*.qml
dialogs.files += $$_PRO_FILE_PWD_/qml/dialogs/qmldir
dialogs.path = $$[QT_INSTALL_QML]/Nemo/Dialogs
images.files = $$_PRO_FILE_PWD_/images
images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
INSTALLS += target qmlfiles images
INSTALLS += target qmlfiles images dialogs
import QtQuick 2.6
import QtQuick.Controls.Nemo 1.0
Item {
id: shell
anchors.fill: parent
signal accepted()
signal canceled()
signal selected()
property alias cancelText: cancel.text
property alias acceptText: accept.text
property alias headingText: heading.text
property alias subLabelText: subLabel.text
property string icon: ""
property bool inline: true
Rectangle {
anchors.fill: parent
id: shadow
width: parent.width
height: inline ? (parent.height-cancel.height)/3 : parent.height-cancel.height
opacity: 0.65
color: Theme.backgroundColor
anchors.bottom: cancel.top
}
Image{
id: icon
source: shell.icon
width: Theme.itemHeightMedium
height: width
anchors{
top: shell.top
topMargin: Theme.itemSpacingHuge
horizontalCenter: shell.horizontalCenter
}
visible: shell.icon != "" && !inline
fillMode: Image.PreserveAspectCrop
}
Label {
width: parent.width*0.8
id: heading
anchors.centerIn: parent
width: parent.width*0.95
anchors{
centerIn: inline ? shadow : parent
}
horizontalAlignment: Text.AlignHCenter
font.weight: Theme.fontWeightLarge
font.pixelSize: inline ? Theme.fontSizeTiny : Theme.fontSizeSmall
wrapMode: Text.Wrap
}
Label {
id:subLabel
width: parent.width*0.8
width: parent.width*0.95
wrapMode: Text.Wrap
font.weight: Theme.fontWeightMedium
font.pixelSize: inline ? Theme.fontSizeTiny : Theme.fontSizeSmall
horizontalAlignment: Text.AlignHCenter
anchors {
top:heading.bottom
topMargin: Theme.itemSpacingLarge
topMargin: inline ? Theme.itemSpacingSmall : Theme.itemSpacingLarge
horizontalCenter: shell.horizontalCenter
}
}
......@@ -48,7 +74,7 @@ Item {
}
onClicked: {
shell.canceled()
shell.destroy()
shell.selected()
}
}
Button {
......@@ -62,7 +88,7 @@ Item {
}
onClicked: {
shell.accepted()
shell.destroy()
shell.selected()
}
}
}
QueryDialog 1.0 QueryDialog.qml
......@@ -2,4 +2,4 @@ TEMPLATE = subdirs
SUBDIRS += controls
SUBDIRS += styles
SUBDIRS += models
\ No newline at end of file
SUBDIRS += models
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