Commit 0102218d authored by Aleksi Suomalainen's avatar Aleksi Suomalainen Committed by GitHub

Merge pull request #61 from neochapay/5.3.3

5.3.3
parents c2c387f1 3480e53a
......@@ -49,6 +49,39 @@ Page {
fillMode: Image.PreserveAspectCrop
}
ListModel {
id: animalsModel
ListElement { name: "Ant"; }
ListElement { name: "Flea"; }
ListElement { name: "Parrot"; }
ListElement { name: "Guinea pig"; }
ListElement { name: "Rat"; }
ListElement { name: "Butterfly"; }
ListElement { name: "Dog"; }
ListElement { name: "Cat"; }
ListElement { name: "Pony"; }
ListElement { name: "Koala"; }
ListElement { name: "Horse"; }
ListElement { name: "Tiger"; }
ListElement { name: "Giraffe"; }
ListElement { name: "Elephant"; }
ListElement { name: "Whale"; }
}
function hideButton(){
standartButton.visible = false
inlineButton.visible = false
simpleButton.visible = false
selectionButton.visible = false
}
function showButton(){
standartButton.visible = true
inlineButton.visible = true
simpleButton.visible = true
selectionButton.visible = true
}
Button {
id: standartButton
anchors{
......@@ -56,12 +89,11 @@ Page {
margins: 20
horizontalCenter: parent.horizontalCenter
}
text: qsTr("Standart dialog")
text: qsTr("Standart query dialog")
onClicked: {
deleteDialog.inline = false
deleteDialog.visible = true
standartButton.visible = false
inlineButton.visible = false
deleteDialog.open()
hideButton();
}
}
......@@ -72,15 +104,72 @@ Page {
margins: 20
horizontalCenter: parent.horizontalCenter
}
text: qsTr("Inline dialog")
text: qsTr("Inline query dialog")
onClicked: {
deleteDialog.inline = true
deleteDialog.visible = true
standartButton.visible = false
inlineButton.visible = false
deleteDialog.open()
hideButton();
}
}
Button {
id: simpleButton
anchors{
top: inlineButton.bottom
margins: 20
horizontalCenter: parent.horizontalCenter
}
text: qsTr("Simple dialog")
onClicked: {
hideButton();
simpleDialog.open();
}
}
Button {
id: selectionButton
anchors{
top: inlineButton.bottom
margins: 20
horizontalCenter: parent.horizontalCenter
}
text: qsTr("Selection dialog")
onClicked: {
hideButton();
selectionDialog.open();
}
}
Dialog{
id: simpleDialog
acceptText: qsTr("Ok")
headingText: qsTr("Simple dialog")
subLabelText: qsTr("Simple diaolg is open")
inline: false
icon: "image://theme/exclamation-triangle"
onAccepted: {
showButton();
simpleDialog.close();
}
}
SelectionDialog{
id: selectionDialog
visible: false
cancelText: qsTr("Cancel")
acceptText: qsTr("Ok")
headingText: qsTr("Select you favorite animal?")
subLabelText: qsTr("")
model: animalsModel
onSelectedIndexChanged: selectionDialog.close()
}
QueryDialog {
id: deleteDialog
visible: false
......@@ -99,11 +188,11 @@ Page {
result.text = qsTr("User canceled")
}
onSelected: {
standartButton.visible = true
inlineButton.visible = true
visible = false
showButton();
deleteDialog.close()
}
}
Label {
id: result
anchors.centerIn: parent
......
......@@ -20,6 +20,7 @@
import QtQuick 2.6
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 QtQuick.Layouts 1.0
Page {
......
/****************************************************************************************
**
** Copyright (C) 2018 Chupligin Sergey <neochapay@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/
import QtQuick 2.6
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
Page {
id: root
headerTools: HeaderToolsLayout {
showBackButton: true;
title: qsTr("Time Picker")
}
Column {
spacing: Theme.itemSpacingLarge*2
width: parent.width
TimePicker{
width: parent.width-Theme.itemSpacingLarge*2
readOnly: false
}
}
}
......@@ -85,6 +85,10 @@ ApplicationWindow {
title: "DatePicker"
page: "content/DatePickerPage.qml"
}
ListElement {
title: "TimePicker"
page: "content/TimePickerPage.qml"
}
ListElement {
title: "Tabs"
page: "content/TabBarPage.qml"
......@@ -118,8 +122,8 @@ ApplicationWindow {
page: "content/ButtonRowPage.qml"
}
ListElement {
title: "Query Dialog"
page: "content/QueryDialogPage.qml"
title: "Dialogs"
page: "content/DialogsPage.qml"
}
ListElement {
title: "Icons"
......
......@@ -27,6 +27,7 @@ qml.files += \
content/SelectRollerPage.qml \
content/IconPage.qml \
content/DatePickerPage.qml \
content/TimePickerPage.qml \
content/NotificationsPage.qml
qml.path = /usr/share/glacier-components/qml/content
......@@ -44,3 +45,6 @@ INSTALLS += desktop target qml mainqml images
SOURCES += \
src/main.cpp
DISTFILES += \
content/TimePickerPage.qml
......@@ -14,7 +14,6 @@ QML_FILES += \
qml/Label.qml \
qml/Checkbox.qml\
qml/ButtonRow.qml \
qml/QueryDialog.qml \
qml/Header.qml \
qml/HeaderToolsLayout.qml \
qml/Slider.qml\
......@@ -25,9 +24,12 @@ QML_FILES += \
qml/InverseMouseArea.qml \
qml/IconButton.qml \
qml/DatePicker.qml \
qml/TimePicker.qml \
qml/ScrollDecorator.qml \
qml/dialogs/QueryDialog.qml \
qml/TextField.qml
qml/TextField.qml \
qml/dialogs/SelectionDialog.qml \
qml/dialogs/Dialog.qml
OTHER_FILES += qmldir \
$$QML_FILES
......
import QtQuick 2.6
Item {
id: shell
anchors.fill: parent
signal accepted()
signal canceled()
property alias cancelText: cancel.text
property alias acceptText: accept.text
property alias headingText: heading.text
property alias subLabelText: subLabel.text
Rectangle {
anchors.fill: parent
opacity: 0.65
color: Theme.backgroundColor
}
Label {
width: parent.width*0.8
id: heading
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
font.weight: Theme.fontWeightLarge
wrapMode: Text.Wrap
}
Label {
id:subLabel
width: parent.width*0.8
wrapMode: Text.Wrap
font.weight: Theme.fontWeightMedium
horizontalAlignment: Text.AlignHCenter
anchors {
top:heading.bottom
topMargin: Theme.itemSpacingLarge
horizontalCenter: shell.horizontalCenter
}
}
Button {
id: cancel
width: parent.width / 2
height: Theme.itemHeightLarge
anchors {
left: parent.left
bottom: parent.bottom
}
onClicked: {
shell.canceled()
shell.destroy()
}
}
Button {
id: accept
width: parent.width / 2
height: Theme.itemHeightLarge
primary: true
anchors {
left: cancel.right
bottom: parent.bottom
}
onClicked: {
shell.accepted()
shell.destroy()
}
}
}
/****************************************************************************************
**
** Copyright (C) 2018 Chupligin Sergey <neochapay@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/
import QtQuick 2.6
import QtQuick.Controls.Nemo 1.0
Item{
id: timePicker
width: 400
height: width
property date currentTime: new Date()
property int hours: currentTime.getHours()
property int minutes: currentTime.getHours()
property bool readOnly: true
Rectangle{
anchors.fill: parent
color: Theme.backgroundColor
}
Canvas {
id: canvas
anchors.fill: parent
onPaint: {
var context = getContext("2d");
var centerX = canvas.width / 2
var centerY = canvas.height / 2
var hour_radius = canvas.width/2*0.8 - 1.5*Theme.itemHeightExtraSmall/4 - Theme.itemHeightExtraSmall/5/2
var hour_end_angle = getHourAngle()
var minute_radius = canvas.width/2*0.8
var minute_end_angle = getMinuteAngle()
context.clearRect(0, 0, canvas.width, canvas.height)
/*Draw hours */
context.beginPath()
context.arc(centerX, centerY, hour_radius, -0.5*Math.PI, hour_end_angle, false)
context.lineWidth = Theme.itemHeightExtraSmall/2
context.strokeStyle = Theme.accentColor
context.globalAlpha = 1
context.stroke();
/*Draw subhours if time AM*/
if(timePicker.hours > 12)
{
context.beginPath()
context.arc(centerX, centerY, hour_radius, 0, 2 * Math.PI, false)
context.lineWidth = Theme.itemHeightExtraSmall/2
context.strokeStyle = Theme.accentColor
context.globalAlpha = 0.5
context.stroke()
}
/*Draw minute*/
context.beginPath();
context.arc(centerX, centerY, minute_radius, -0.5*Math.PI, minute_end_angle, false)
context.lineWidth = Theme.itemHeightExtraSmall/5
context.strokeStyle = Theme.accentColor
context.globalAlpha = 0.5
context.stroke()
}
}
Label{
id: hourLabel
text: timePicker.hours
font.pixelSize: Theme.itemHeightExtraSmall/2
font.bold: true
x: canvas.width/2-hourLabel.contentWidth-Theme.itemHeightExtraSmall/10
y: canvas.height/2-(canvas.width/2*0.8 - 1.5*Theme.itemHeightExtraSmall/4 - Theme.itemHeightExtraSmall/5/2) - Theme.itemHeightExtraSmall/4
}
Label{
id: minuteLabel
text: timePicker.minutes
font.pixelSize: Theme.itemHeightExtraSmall/5
x: canvas.width/2-minuteLabel.contentWidth-Theme.itemHeightExtraSmall/10
y: canvas.width/2-canvas.width/2*0.8-Theme.itemHeightExtraSmall/5/2
}
MouseArea{
anchors.fill: parent
onPressed: {
if(readOnly)
{
return;
}
var minute_rad_max = canvas.width/2*0.8+Theme.itemHeightExtraSmall/10;
var minute_rad_min = canvas.width/2*0.8-Theme.itemHeightExtraSmall/10;
var hour_rad_max = canvas.width/2*0.8 - 1.5*Theme.itemHeightExtraSmall/4 - Theme.itemHeightExtraSmall/5/2 + Theme.itemHeightExtraSmall/2
var hour_rad_min = canvas.width/2*0.8 - 1.5*Theme.itemHeightExtraSmall/4 - Theme.itemHeightExtraSmall/5/2 - Theme.itemHeightExtraSmall/2
var clickRad = Math.sqrt(Math.pow((mouseX-canvas.width/2),2)+Math.pow((mouseY-canvas.width/2),2))
/*If inside min circle*/
if(clickRad <= minute_rad_max && clickRad >= hour_rad_min)
{
var ang = getAngle(mouseX,mouseY)
if(clickRad>=minute_rad_min)
{
var cur_min = Math.round(60*ang/360)
timePicker.minutes = Math.round(60*ang/360)
}
else if(clickRad <= hour_rad_max && clickRad >= hour_rad_min)
{
if(timePicker.hours >= 12)
{
timePicker.hours = Math.round(12*ang/360)+12
}
else
{
timePicker.hours = Math.round(12*ang/360)
}
}
}
}
}
Component.onCompleted: {
if(hours > 23 || hours < 0)
{
console.warn("[TimePicker] Uncorrect hours value")
hours = 0
}
if(minutes > 59 || minutes < 0)
{
console.warn("[TimePicker] Uncorrect minutes value")
minutes = 0
}
}
onMinutesChanged: {
canvas.requestPaint()
}
onHoursChanged: {
if(timePicker.hours == 24)
{
timePicker.hours = 0
}
canvas.requestPaint()
}
function getHourAngle()
{
var hour = timePicker.hours
if(hour > 12)
{
hour = hour-12
}
return 2*Math.PI/12*hour-0.5*Math.PI
}
function getMinuteAngle()
{
var minute = timePicker.minutes
return 2*Math.PI/60*minute-0.5*Math.PI
}
function getAngle(x,y)
{
var a = (Math.atan((y - canvas.width/2)/(x - canvas.width/2)) * 180) / Math.PI + 90
if (x < canvas.width/2)
{
a += 180
}
return a
}
}
import QtQuick 2.6
import QtQuick.Controls.Nemo 1.0
Item {
id: shell
anchors.fill: parent
signal accepted()
property alias acceptText: accept.text
property alias headingText: heading.text
property alias subLabelText: subLabel.text
property real bgOpacity: 1;
property string icon: ""
property bool inline: true
function open(){
shell.visible = true
}
function close(){
shell.visible = false
}
visible: false
Rectangle {
id: shadow
width: parent.width
height: inline ? (parent.height-accept.height)/3 : parent.height-accept.height
opacity: shell.bgOpacity
color: Theme.backgroundColor
anchors.bottom: accept.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 {
id: heading
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.95
wrapMode: Text.Wrap
font.weight: Theme.fontWeightMedium
font.pixelSize: inline ? Theme.fontSizeTiny : Theme.fontSizeSmall
horizontalAlignment: Text.AlignHCenter
anchors {
top:heading.bottom
topMargin: inline ? Theme.itemSpacingSmall : Theme.itemSpacingLarge
horizontalCenter: shell.horizontalCenter
}
}
Button {
id: accept
width: parent.width
height: Theme.itemHeightLarge
primary: true
anchors {
left: parent.left
bottom: parent.bottom
}
onClicked: {
shell.accepted()
close();
}
}
}
......@@ -12,14 +12,24 @@ Item {
property alias headingText: heading.text
property alias subLabelText: subLabel.text
property real bgOpacity: 1;
property string icon: ""
property bool inline: true
function open(){
shell.visible = true
}
function close(){
shell.visible = false
}
Rectangle {
id: shadow
width: parent.width
height: inline ? (parent.height-cancel.height)/3 : parent.height-cancel.height
opacity: 0.65
opacity: shell.bgOpacity
color: Theme.backgroundColor
anchors.bottom: cancel.top
}
......@@ -75,6 +85,7 @@ Item {
onClicked: {
shell.canceled()
shell.selected()
close()
}
}
Button {
......@@ -89,6 +100,7 @@ Item {
onClicked: {
shell.accepted()
shell.selected()
close();
}
}
}
import QtQuick 2.6
import QtQuick.Controls.Nemo 1.0
Item {
id: shell
anchors.fill: parent
signal accepted()
signal canceled()
property alias cancelText: cancel.text
property alias acceptText: accept.text
property alias headingText: heading.text
property alias subLabelText: subLabel.text
property real bgOpacity: 1;
property alias model: selectionListView.model
property int selectedIndex: -1
property Component delegate: ListViewItemWithActions{
label: name
showNext: false
iconVisible: false
onClicked: {
shell.selectedIndex = index
}
}
function open(){
shell.visible = true
}
function close(){
shell.visible = false
}
Rectangle {
id: shadow
width: parent.width
height: parent.height-cancel.height
opacity: shell.bgOpacity
color: Theme.backgroundColor
anchors.bottom: cancel.top
}
Label {
id: heading
width: parent.width*0.95
height: Theme.itemHeightLarge
anchors{
top: parent.top
}
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.weight: Theme.fontWeightLarge
font.pixelSize: Theme.fontSizeSmall
wrapMode: Text.Wrap
}
Label {
id:subLabel
width: parent.width*0.95
wrapMode: Text.Wrap
font.weight: Theme.fontWeightMedium
font.pixelSize: Theme.fontSizeSmall
horizontalAlignment: Text.AlignHCenter
anchors {
top:heading.bottom
topMargin: Theme.itemSpacingLarge
horizontalCenter: shell.horizontalCenter
}
}
ListView{
id: selectionListView
width: parent.width
height: (subLabel.text != "") ? parent.height-heading.height-subLabel.height-cancel.height-Theme.itemSpacingLarge
: parent.height-heading.height-cancel.height-Theme.itemSpacingLarge
delegate: shell.delegate
anchors.top: subLabel.bottom
ScrollDecorator{
flickable: selectionListView
}
}
Button {
id: cancel
width: parent.width / 2
height: Theme.itemHeightLarge
anchors {
left: parent.left
bottom: parent.bottom
}
onClicked: {
shell.canceled()
close()
}
}
Button {
id: accept
width: parent.width / 2
height: Theme.itemHeightLarge
primary: true
anchors {
left: cancel.right
bottom: parent.bottom
}
onClicked: {
shell.accepted()
close();
}
}
}
QueryDialog 1.0 QueryDialog.qml
Dialog 1.0 Dialog.qml
SelectionDialog 1.0 SelectionDialog.qml
......@@ -26,6 +26,7 @@ GlacierRollerItem 1.0 GlacierRollerItem.qml
InverseMouseArea 1.0 InverseMouseArea.qml
IconButton 1.0 IconButton.qml
DatePicker 1.0 DatePicker.qml
TimePicker 1.0 TimePicker.qml
ScrollDecorator 1.0 ScrollDecorator.qml
TextField 1.0 TextField.qml
......
/*
* Copyright (C) 2013 Andrea Bernabei <and.bernabei@gmail.com>
* Copyright (C) 2018 Chupligin Sergey <neochapay@gmail.com>
*
* This library 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 of the License, or (at your option) any later version.
*
* This library 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 library; see the file COPYING.LIB. 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.Styles 1.4
import QtQuick.Controls.Nemo 1.0
TextAreaStyle{
id: nemoStyle
textColor: Theme.textColor
selectionColor: Theme.accentColor
selectedTextColor: Theme.textColor
backgroundColor: Theme.backgroundColor
}
......@@ -20,4 +20,5 @@ SpinBoxStyle 1.0 SpinBoxStyle.qml
TabViewStyle 1.0 TabViewStyle.qml
TableViewStyle 1.0 TableViewStyle.qml
TextFieldStyle 1.0 TextFieldStyle.qml
TextAreaStyle 1.0 TextAreaStyle.qml
IconButtonStyle 1.0 IconButtonStyle.qml
......@@ -25,6 +25,7 @@ QML_FILES = \
qml/TableViewStyle.qml \
qml/TabViewStyle.qml \
qml/TextFieldStyle.qml \
qml/TextAreaStyle.qml \
qml/ToolBarStyle.qml \
qml/ToolButtonStyle.qml \
qml/IconButtonStyle.qml
......
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