/* * Copyright 2012-2018 Morgan McMillian * * 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.cascades.pickers 1.0 Page { id: settingsPage signal modifySetting(string setting, variant value) property bool datenew property bool windowsbreak property bool autoarchive property int sort property string path property string sync property string dboxpath titleBar: TitleBar { title: " Settings" } ScrollView { Container { layout: StackLayout {} Container { topPadding: 15.0 } Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill Container { verticalAlignment: VerticalAlignment.Center leftPadding: 30.0 Label { text: "Date new tasks" textStyle.fontWeight: FontWeight.Bold } } Container { rightPadding: 30.0 horizontalAlignment: HorizontalAlignment.Right ToggleButton { checked: datenew onCheckedChanged: { if (checked) { modifySetting("datenew", true) } else { modifySetting("datenew", false) } } } } } Divider {} Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill Container { leftPadding: 30.0 verticalAlignment: VerticalAlignment.Center Label { text: "Windows line breaks" textStyle.fontWeight: FontWeight.Bold } } Container { rightPadding: 30.0 horizontalAlignment: HorizontalAlignment.Right ToggleButton { checked: windowsbreak onCheckedChanged: { if (checked) { modifySetting("windowsbreak", true) } else { modifySetting("windowsbreak", false) } } } } } Divider {} Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill Container { leftPadding: 30.0 verticalAlignment: VerticalAlignment.Center Label { text: "Auto archive" textStyle.fontWeight: FontWeight.Bold } } Container { rightPadding: 30.0 horizontalAlignment: HorizontalAlignment.Right ToggleButton { checked: autoarchive onCheckedChanged: { if (checked) { modifySetting("autoarchive", true) } else { modifySetting("autoarchive", false) } } } } } Divider {} Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill Container { leftPadding: 30.0 rightPadding: 30.0 DropDown { title: "Sort by:" preferredWidth: 1440.0 onSelectedIndexChanged: { modifySetting("sort", selectedValue) } Option { text: "Priority" value: 0 selected: sort == 0 } Option { text: "Due date" value: 3 selected: sort == 3 } Option { text: "Line number" value: 1 selected: sort == 1 } Option { text: "Text A>Z" value: 2 selected: sort == 2 } } } } Divider {} Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill Container { leftPadding: 30.0 rightPadding: 30.0 DropDown { title: "File location:" preferredWidth: 1440.0 onSelectedIndexChanged: { modifySetting("path", selectedValue) } Option { text: "Local sandbox" value: "data/todo" selected: path == "data/todo" } Option { text: "Local shared" value: "shared/misc/todo" selected: path == "shared/misc/todo" } } } } Divider {} Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill Container { leftPadding: 30.0 rightPadding: 30.0 DropDown { title: "Storage:" preferredWidth: 1440.0 onSelectedIndexChanged: { if (sync != selectedValue) { modifySetting("sync", selectedValue) } } Option { text: "Local only" value: "local" selected: sync == "local" } } } } Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill Container { leftPadding: 30.0 rightPadding: 30.0 topPadding: 10.0 TextField { id: dboxPath hintText: "Dropbox location" text: dboxpath visible: sync == "dropbox" onTextChanged: { if (dboxPath.text.length > 0) { modifySetting("dbox_path", dboxPath.text) } } } } } Divider {} Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill leftPadding: 30.0 rightPadding: 30.0 Button { preferredWidth: 1440.0 text: "Export sandbox files" onClicked: { exportPicker.open() } } } Divider {} Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill leftPadding: 30.0 rightPadding: 30.0 Button { preferredWidth: 1440.0 text: "Purge local sandbox" onClicked: { taskModel.promptPurgeSandbox() } } } Divider {} } } attachedObjects: [ FilePicker { id: exportPicker title: "Export" mode: FilePicker.SaverMultiple type: FileType.Document viewMode: FilePickerViewMode.ListView defaultSaveFileNames: ["todo.txt","done.txt"] onFileSelected: { console.log("FileSelected signal received : " + selectedFiles); taskModel.exportFiles(selectedFiles) } } ] }