2
* Copyright (C) 2015 Szymon Waliczek.
5
* Szymon Waliczek <majsterrr@gmail.com>
7
* This file is part of SocketWorld app for Ubuntu Touch
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; version 3.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
import Ubuntu.Components 1.2
25
//import Ubuntu.Components.ListItems 1.0 as ListItem
26
import Ubuntu.Components.Popups 1.0
28
//import "../components"
29
import "../backEnd/utils.js" as Utils
31
// EDIT LIST NAME DIALOG
33
id: editMainListDialog
36
title: i18n.tr("Edit") + " <b>" + main_shopping_list_MODEL.get(editListIndex).name
38
id: newListNameTextField
39
placeholderText: i18n.tr("eg. 'Weekend Shopping'")
40
inputMethodHints: Qt.ImhNoPredictiveText
41
text: main_shopping_list_MODEL.get(editListIndex).name
43
if(newListNameTextField.text.length > 0) {
44
if (main_shopping_list_MODEL.listNameValidator(text)) {
45
console.log("[LOG]: Editing list named: " + newListNameTextField.text )
46
main_shopping_list_MODEL.editListNameAndColor(editListIndex, newListNameTextField.text, colorPreview.backgroundColor.toString())
47
PopupUtils.close(dialogue)
49
if(text.toLowerCase() === main_shopping_list_MODEL.get(editListIndex).name.toLowerCase()) {
50
console.log("[LOG]: Editing list named: " + newListNameTextField.text )
51
main_shopping_list_MODEL.editListNameAndColor(editListIndex, newListNameTextField.text, colorPreview.backgroundColor.toString())
52
PopupUtils.close(dialogue)
60
Component.onCompleted: {
62
cursorPosition = text.length
67
text: i18n.tr('Name already exists')
69
opacity: (main_shopping_list_MODEL.listNameValidator(newListNameTextField.text)) || (main_shopping_list_MODEL.get(editListIndex).name === newListNameTextField.text) ? 0 : 1
71
UbuntuNumberAnimation {
82
text: i18n.tr('Color')
93
border.width: units.gu(0.1)
95
anchors.centerIn: parent
97
GradientStop { position: 1*(1/8); color: "#FFFFFF" }
98
GradientStop { position: 2*(1/8); color: "#000000" }
99
GradientStop { position: 3*(1/8); color: "#FF0000" }
100
GradientStop { position: 4*(1/8); color: "#FFFF00" }
101
GradientStop { position: 5*(1/8); color: "#00FF00" }
102
GradientStop { position: 6*(1/8); color: "#00FFFF" }
103
GradientStop { position: 7*(1/8); color: "#0000FF" }
104
GradientStop { position: 8*(1/8); color: "#FF00FF" }
108
height: parent.height+units.gu(1)
110
anchors.verticalCenter: parent.verticalCenter
111
backgroundColor: "#38a8ff"
114
// print('X: '+ 7 / colorPreview.width)
115
if(x <= 2*(colorPicker.width/1)) {
116
colorPreview.backgroundColor = "#FFFFFF"
117
} else if(x < 3*(colorPicker.width / 1)){
118
colorPreview.backgroundColor = "#000000"
119
} else if(x < 4*(colorPicker.width / 1)){
120
colorPreview.backgroundColor = "#FF0000"
121
} else if(x < 5*(colorPicker.width / 1)){
122
colorPreview.backgroundColor = "#FFFF00"
123
} else if(x < 6*(colorPicker.width / 1)){
124
colorPreview.backgroundColor = "#00FF00"
125
} else if(x < 7*(colorPicker.width / 1)){
126
colorPreview.backgroundColor = "#00FFFF"
127
} else if(x < 8*(colorPicker.width / 1)){
128
colorPreview.backgroundColor = "#0000FF"
129
} else if(x <= 9*(colorPicker.width / 1)){
130
colorPreview.backgroundColor = "#FF00FF"
134
// } else if (1*(1/9) < x && x < 2*(1/9)) {
135
// colorPreview.color = "#000000"
143
drag.maximumX: colorPicker.height - parent.width
147
colorPreview.opacity = 1
151
colorPreview.opacity = 0
159
backgroundColor: main_shopping_list_MODEL.get(editListIndex).def_color
161
anchors.bottom: parent.top;
162
anchors.bottomMargin: units.gu(2)
163
anchors.horizontalCenter: parent.horizontalCenter
164
Behavior on opacity {
165
UbuntuNumberAnimation {}
173
// anchors.fill: parent
174
// onPressed: forceActiveFocus()
195
width: parent.width / 2 - units.gu(1)
196
text: i18n.tr("Cancel")
197
color: UbuntuColors.red
198
onClicked: PopupUtils.close(dialogue)
203
width: parent.width / 2 - units.gu(1)
204
text: i18n.tr("Save")
205
enabled: (newListNameTextField.text !== "" && main_shopping_list_MODEL.listNameValidator(newListNameTextField.text)) || (main_shopping_list_MODEL.get(editListIndex).name === newListNameTextField.text) ? true : false
207
color: UbuntuColors.green
209
console.log("[LOG]: Editing list named: " + newListNameTextField.text )
210
main_shopping_list_MODEL.editListNameAndColor(editListIndex, newListNameTextField.text, colorPreview.backgroundColor.toString())
211
// Utils.addMainList(newListNameTextField.text, "#" + Math.random().toString(16).slice(2, 8))
212
PopupUtils.close(dialogue)