Readability integration - first draft
[quicknewsreader] / qml / QuickNewsReader / content / view / SourceConfigDialog.qml
1 /***
2 ** Copyright (C) 2012 Christophe CHAPUIS <chris.chapuis _at_ gmail _dot_ com>
3 **
4 ** This package is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This package is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ** GNU General Public License for more details.
13 **
14 ** You should have received a copy of the GNU General Public License
15 ** along with this package; if not, write to the Free Software
16 ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17 **
18 ***/
19 import QtQuick 1.0
20 import "../modelitf"
21
22 Rectangle {
23     id: configDialog
24     anchors.fill: parent
25     color: "#00000000"
26     visible: false
27     state: "hidden"
28
29     property SourceModel configModel;
30
31     //property SourceModel model;
32     //property SourceConfigComponentView viewComponent;
33
34     states: [
35         State {
36             name: "showSourceConfig"
37
38             // In this state, we bring the configuration UI of the source
39             PropertyChanges { target: configDialog; color: "#80000000" }
40             PropertyChanges { target: sourceConfigLoader; opacity: 1 }
41             PropertyChanges { target: sourceConfigLoader; source: configModel.settingsComponent }
42             PropertyChanges { target: configTitle; text: configModel.name + " Settings"}
43
44             AnchorChanges { target: quitApplyConfigButton; anchors.left: undefined; anchors.right: configDialog.right }
45             AnchorChanges { target: quitCancelConfigButton; anchors.right: undefined; anchors.left: configDialog.left }
46         }
47     ]
48
49     transitions: [
50         Transition {
51             from: "hidden"
52             to: "showSourceConfig"
53
54             SequentialAnimation {
55                 // Show the dialog
56                 PropertyAction { target: configDialog; property: "visible"; value: true }
57                 // Bring the UI elements
58                 ParallelAnimation {
59                     AnchorAnimation { duration: 500 }
60                     ColorAnimation { duration: 400 }
61                 }
62             }
63         },
64         Transition {
65             from: "showSourceConfig"
66             to: "hidden"
67
68             SequentialAnimation {
69                 // Move out the UI elements
70                 ParallelAnimation {
71                     AnchorAnimation { duration: 500 }
72                     ColorAnimation { duration: 400 }
73                 }
74                 // Hide the dialog
75                 PropertyAction { target: configDialog; property: "visible"; value: false }
76             }
77         }
78     ]
79
80     Background {
81         anchors.top: parent.top
82         anchors.left: parent.left
83         anchors.right: parent.right
84         anchors.bottom: quitApplyConfigButton.top
85     }
86
87     Text {
88         id: configTitle
89         color: "white"
90         anchors.top: parent.top
91         anchors.left: parent.left
92         anchors.right: parent.right
93         horizontalAlignment: Text.AlignHCenter
94         font.pixelSize: 24
95         font.bold: true
96     }
97
98     Loader {
99         id: sourceConfigLoader
100         opacity: 0
101         anchors.top: configTitle.bottom
102         anchors.left: parent.left
103         anchors.right: parent.right
104         anchors.bottom: quitApplyConfigButton.top
105
106         Behavior on opacity {
107             NumberAnimation { duration: 1000; easing.type: Easing.InOutQuad }
108         }
109
110         onLoaded: {
111             // fill the UI with information from the model
112             configModel.loadConfiguration(sourceConfigLoader.item)
113         }
114     }
115
116     FancyButton {
117         id: quitApplyConfigButton
118         icon: "../images/apply.png"
119         anchors.bottom: parent.bottom
120         anchors.left: parent.right
121
122         onClicked: {
123             // ask the model to store the configuration
124             configModel.storeConfiguration(sourceConfigLoader.item)
125
126             // Store the configuration of this source, and disappear
127             configDialog.state = "hidden"
128         }
129     }
130
131     FancyButton {
132         id: quitCancelConfigButton
133         icon: "../images/cancel.png"
134         anchors.bottom: parent.bottom
135         anchors.right: parent.left
136
137         onClicked: {
138             // Store the configuration of this source, and disappear
139             configDialog.state = "hidden"
140         }
141     }
142
143 }