Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / filebrowse / pages / SettingsPage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import "functions.js" as Functions
4 import "../components"
5
6 Page {
7     id: page
8     allowedOrientations: Orientation.All
9
10     SilicaFlickable {
11         id: flickable
12         anchors.fill: parent
13         contentHeight: column.height
14         VerticalScrollDecorator { flickable: flickable }
15
16         Column {
17             id: column
18             anchors.left: parent.left
19             anchors.right: parent.right
20             anchors.leftMargin: Theme.paddingLarge
21             anchors.rightMargin: Theme.paddingLarge
22
23             PageHeader { title: qsTr("Settings") }
24
25             TextSwitch {
26                 id: showDirsFirst
27                 text: qsTr("Show folders first")
28             }
29             TextSwitch {
30                 id: showHiddenFiles
31                 text: qsTr("Show hidden files")
32             }
33
34             Spacer { height: 40 }
35
36             Label {
37                 text: qsTr("About File Browser")
38                 anchors.left: parent.left
39                 anchors.right: parent.right
40                 anchors.rightMargin: Theme.paddingLarge
41                 horizontalAlignment: Text.AlignRight
42                 color: Theme.highlightColor
43             }
44             Spacer { height: 20 }
45             Row {
46                 anchors.left: parent.left
47                 anchors.right: parent.right
48                 anchors.leftMargin: Theme.paddingLarge
49                 anchors.rightMargin: Theme.paddingLarge
50                 Label {
51                     id: version
52                     text: qsTr("Version")+" "
53                     font.pixelSize: Theme.fontSizeExtraSmall
54                     color: Theme.secondaryColor
55                 }
56                 Label {
57                     text: "1.4.1" // Version number must be changed manually!
58                     font.pixelSize: Theme.fontSizeExtraSmall
59                     color: Theme.highlightColor
60                 }
61             }
62             Spacer { height: 20 }
63             Label {
64                 anchors.left: parent.left
65                 anchors.right: parent.right
66                 anchors.leftMargin: Theme.paddingLarge
67                 anchors.rightMargin: Theme.paddingLarge
68                 text: "File Browser is free and unencumbered software released "+
69                       "into the public domain.\nRead full text >>"
70                 wrapMode: Text.Wrap
71                 font.pixelSize: Theme.fontSizeExtraSmall
72                 color: Theme.primaryColor
73
74                 MouseArea {
75                     anchors.fill: parent
76                     onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
77                 }
78             }
79
80             Spacer { height: 20 }
81             Label {
82                 anchors.left: parent.left
83                 anchors.right: parent.right
84                 anchors.leftMargin: Theme.paddingLarge
85                 anchors.rightMargin: Theme.paddingLarge
86                 text: qsTr("The source code is available at\nhttps://github.com/karip/harbour-file-browser")
87                 wrapMode: Text.Wrap
88                 font.pixelSize: Theme.fontSizeTiny
89                 color: Theme.secondaryColor
90             }
91         }
92     }
93
94     onStatusChanged: {
95         // update cover
96         if (status === PageStatus.Activating)
97             coverPlaceholder.text = qsTr("Settings");
98
99         // read settings
100         if (status === PageStatus.Activating) {
101             showDirsFirst.checked = (engine.readSetting("show-dirs-first") === "true");
102             showHiddenFiles.checked = (engine.readSetting("show-hidden-files") === "true");
103         }
104
105         // write settings
106         if (status === PageStatus.Deactivating) {
107             engine.writeSetting("show-dirs-first", showDirsFirst.checked.toString());
108             engine.writeSetting("show-hidden-files", showHiddenFiles.checked.toString());
109         }
110     }
111 }
112
113