385 lines
14 KiB
QML
385 lines
14 KiB
QML
/*
|
|
* Copyright 2012-2018 Morgan McMillian <gilag@monkeystew.com>
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import bb.cascades 1.0
|
|
import bb.system 1.0
|
|
|
|
Sheet {
|
|
id: editSheet
|
|
signal saveTask(string text)
|
|
signal modifySetting(string setting, variant value)
|
|
property alias text: taskText.text
|
|
property alias textfield: taskText
|
|
property alias title: addBar.title
|
|
property alias pri: priority.selectedValue
|
|
property alias labels: labels
|
|
property bool displayed: false
|
|
property bool datenew
|
|
property bool newtask
|
|
property bool taskitem
|
|
Page {
|
|
id: addPage
|
|
titleBar: TitleBar {
|
|
id: addBar
|
|
title: "Add"
|
|
dismissAction: ActionItem {
|
|
title: "Cancel"
|
|
onTriggered: {
|
|
editSheet.close()
|
|
taskText.text = ""
|
|
priority.resetSelectedOption()
|
|
}
|
|
}
|
|
acceptAction: ActionItem {
|
|
title: "Save"
|
|
onTriggered: {
|
|
editSheet.close()
|
|
editSheet.saveTask(taskText.text)
|
|
priority.resetSelectedOption()
|
|
}
|
|
}
|
|
}
|
|
Container {
|
|
layout: StackLayout {
|
|
}
|
|
Container {
|
|
leftPadding: 10.0
|
|
rightPadding: 10.0
|
|
topPadding: 10.0
|
|
bottomPadding: 10.0
|
|
TextArea {
|
|
id: taskText
|
|
preferredHeight: 720.0
|
|
}
|
|
Container {
|
|
id: toolbar
|
|
layout: StackLayout {
|
|
orientation: LayoutOrientation.LeftToRight
|
|
}
|
|
// background: Color.create("#262626")
|
|
// preferredWidth: 768.0
|
|
Container {
|
|
leftPadding: 25.0
|
|
rightPadding: 25.0
|
|
minHeight: 81.0
|
|
ImageButton {
|
|
defaultImageSource: "asset:///ArrowCircleAlt.png"
|
|
onClicked: {
|
|
taskText.preferredHeight = 200.0
|
|
priority.visible = true
|
|
priority.expanded = true
|
|
toolbar.visible = false
|
|
}
|
|
}
|
|
}
|
|
Container {
|
|
leftPadding: 25.0
|
|
rightPadding: 25.0
|
|
minHeight: 81.0
|
|
ImageButton {
|
|
defaultImageSource: "asset:///PriceTag.png"
|
|
onClicked: {
|
|
taskText.preferredHeight = 200.0
|
|
labels.visible = true
|
|
labels.expanded = true
|
|
toolbar.visible = false
|
|
}
|
|
}
|
|
}
|
|
Container {
|
|
leftPadding: 25.0
|
|
rightPadding: 25.0
|
|
minHeight: 81.0
|
|
ImageButton {
|
|
defaultImageSource: "asset:///Appointment.png"
|
|
onClicked: {
|
|
taskText.preferredHeight = 200.0
|
|
duedate.visible = true
|
|
duebtn.visible = true
|
|
duedate.expanded = true
|
|
toolbar.visible = false
|
|
}
|
|
}
|
|
}
|
|
Container {
|
|
visible: newtask
|
|
leftPadding: 25.0
|
|
rightPadding: 25.0
|
|
minHeight: 81.0
|
|
ImageToggleButton {
|
|
imageSourceDefault: "asset:///Watch.png"
|
|
imageSourceChecked: "asset:///Watch_a.png"
|
|
checked: datenew
|
|
onCheckedChanged: {
|
|
if (checked) {
|
|
modifySetting("datenew", true)
|
|
createToggleToast.body = "Date new tasks enabled"
|
|
} else {
|
|
modifySetting("datenew", false)
|
|
createToggleToast.body = "Date new tasks disabled"
|
|
}
|
|
displayed ? createToggleToast.show() : displayed = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
DropDown {
|
|
id: priority
|
|
title: "Priority"
|
|
visible: false
|
|
preferredWidth: 720.0
|
|
onSelectedIndexChanged: {
|
|
//console.log("priority set to : " + selectedValue);
|
|
if (selectedValue == "-") {
|
|
taskText.text = taskText.text.replace(/\([A-Z]\)\s/, "");
|
|
} else {
|
|
if (taskText.text.match(/\([A-Z]\)/)) {
|
|
taskText.text = taskText.text.replace(/\([A-Z]\)/, "(" +
|
|
selectedValue + ")");
|
|
} else {
|
|
taskText.text = "(" + selectedValue + ") " + taskText.text;
|
|
}
|
|
}
|
|
priority.visible = false
|
|
toolbar.visible = true
|
|
taskText.preferredHeight = 720.0
|
|
taskText.requestFocus()
|
|
}
|
|
onExpandedChanged: {
|
|
if (expanded === false) {
|
|
priority.visible = false
|
|
toolbar.visible = true
|
|
taskText.preferredHeight = 720.0
|
|
taskText.requestFocus()
|
|
}
|
|
}
|
|
Option {
|
|
text: "-"
|
|
value: "-"
|
|
}
|
|
Option {
|
|
text: "A"
|
|
value: "A"
|
|
selected: editSheet.pri == "A"
|
|
}
|
|
Option {
|
|
text: "B"
|
|
value: "B"
|
|
selected: editSheet.pri == "B"
|
|
}
|
|
Option {
|
|
text: "C"
|
|
value: "C"
|
|
selected: editSheet.pri == "C"
|
|
}
|
|
Option {
|
|
text: "D"
|
|
value: "D"
|
|
selected: editSheet.pri == "D"
|
|
}
|
|
Option {
|
|
text: "E"
|
|
value: "E"
|
|
selected: editSheet.pri == "E"
|
|
}
|
|
Option {
|
|
text: "F"
|
|
value: "F"
|
|
selected: editSheet.pri == "F"
|
|
}
|
|
Option {
|
|
text: "G"
|
|
value: "G"
|
|
selected: editSheet.pri == "G"
|
|
}
|
|
Option {
|
|
text: "H"
|
|
value: "H"
|
|
selected: editSheet.pri == "H"
|
|
}
|
|
Option {
|
|
text: "I"
|
|
value: "I"
|
|
selected: editSheet.pri == "I"
|
|
}
|
|
Option {
|
|
text: "J"
|
|
value: "J"
|
|
selected: editSheet.pri == "J"
|
|
}
|
|
Option {
|
|
text: "K"
|
|
value: "K"
|
|
selected: editSheet.pri == "K"
|
|
}
|
|
Option {
|
|
text: "L"
|
|
value: "L"
|
|
selected: editSheet.pri == "L"
|
|
}
|
|
Option {
|
|
text: "M"
|
|
value: "M"
|
|
selected: editSheet.pri == "M"
|
|
}
|
|
Option {
|
|
text: "N"
|
|
value: "N"
|
|
selected: editSheet.pri == "N"
|
|
}
|
|
Option {
|
|
text: "O"
|
|
value: "O"
|
|
selected: editSheet.pri == "O"
|
|
}
|
|
Option {
|
|
text: "P"
|
|
value: "P"
|
|
selected: editSheet.pri == "P"
|
|
}
|
|
Option {
|
|
text: "Q"
|
|
value: "Q"
|
|
selected: editSheet.pri == "Q"
|
|
}
|
|
Option {
|
|
text: "R"
|
|
value: "R"
|
|
selected: editSheet.pri == "R"
|
|
}
|
|
Option {
|
|
text: "S"
|
|
value: "S"
|
|
selected: editSheet.pri == "S"
|
|
}
|
|
Option {
|
|
text: "T"
|
|
value: "T"
|
|
selected: editSheet.pri == "T"
|
|
}
|
|
Option {
|
|
text: "U"
|
|
value: "U"
|
|
selected: editSheet.pri == "U"
|
|
}
|
|
Option {
|
|
text: "V"
|
|
value: "V"
|
|
selected: editSheet.pri == "V"
|
|
}
|
|
Option {
|
|
text: "W"
|
|
value: "W"
|
|
selected: editSheet.pri == "W"
|
|
}
|
|
Option {
|
|
text: "X"
|
|
value: "X"
|
|
selected: editSheet.pri == "X"
|
|
}
|
|
Option {
|
|
text: "Y"
|
|
value: "Y"
|
|
selected: editSheet.pri == "Y"
|
|
}
|
|
Option {
|
|
text: "Z"
|
|
value: "Z"
|
|
selected: editSheet.pri == "Z"
|
|
}
|
|
}
|
|
DropDown {
|
|
id: labels
|
|
title: "Project or Context"
|
|
visible: false
|
|
preferredWidth: 720.0
|
|
onSelectedIndexChanged: {
|
|
if (selectedValue != undefined) {
|
|
taskText.text = taskText.text + selectedValue + " "
|
|
}
|
|
labels.visible = false
|
|
toolbar.visible = true
|
|
taskText.preferredHeight = 720.0
|
|
taskText.requestFocus()
|
|
}
|
|
onExpandedChanged: {
|
|
if (expanded === false) {
|
|
labels.visible = false
|
|
toolbar.visible = true
|
|
taskText.preferredHeight = 720.0
|
|
taskText.requestFocus()
|
|
}
|
|
}
|
|
}
|
|
DateTimePicker {
|
|
id: duedate
|
|
title: "Due date"
|
|
visible: false
|
|
preferredWidth: 720.0
|
|
}
|
|
Container {
|
|
id: duebtn
|
|
visible: false
|
|
layout: StackLayout {
|
|
orientation: LayoutOrientation.LeftToRight
|
|
}
|
|
Button {
|
|
text: "Nevermind"
|
|
onClicked: {
|
|
duedate.visible = false
|
|
duebtn.visible = false
|
|
toolbar.visible = true
|
|
taskText.preferredHeight = 720.0
|
|
taskText.requestFocus()
|
|
}
|
|
preferredWidth: 350.0
|
|
}
|
|
Button {
|
|
text: "Add date"
|
|
onClicked: {
|
|
if (taskitem) {
|
|
taskText.text = taskText.text +
|
|
"due:" + taskItem.ListItem.view.dataModel.formatDate(duedate.value) + " "
|
|
} else {
|
|
taskText.text = taskText.text +
|
|
"due:" + taskModel.formatDate(duedate.value) + " "
|
|
}
|
|
// taskText.text = taskText.text +
|
|
// "due:" + taskModel.formatDate(duedate.value) + " "
|
|
duedate.visible = false
|
|
duebtn.visible = false
|
|
toolbar.visible = true
|
|
taskText.preferredHeight = 720.0
|
|
taskText.requestFocus()
|
|
}
|
|
preferredWidth: 350.0
|
|
}
|
|
}
|
|
// Divider {
|
|
// }
|
|
}
|
|
}
|
|
onCreationCompleted: {
|
|
// TODO this
|
|
}
|
|
attachedObjects: [
|
|
SystemToast {
|
|
id: createToggleToast
|
|
}
|
|
]
|
|
}
|
|
}
|