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