Major changes
[quicknewsreader] / qml / QuickNewsReader / content / view / SourceConfigDialog.qml
1 import QtQuick 1.0
2 import "../modelitf"
3
4 Rectangle {
5     id: configDialog
6     anchors.fill: parent
7     color: "#00000000"
8     visible: false
9     state: "hidden"
10
11     property SourceModel configModel;
12
13     //property SourceModel model;
14     //property SourceConfigComponentView viewComponent;
15
16     states: [
17         State {
18             name: "showSourceConfig"
19
20             // In this state, we bring the configuration UI of the source
21             PropertyChanges { target: configDialog; color: "#80000000" }
22             PropertyChanges { target: sourceConfigLoader; opacity: 1 }
23             PropertyChanges { target: sourceConfigLoader; source: configModel.settingsComponent }
24             PropertyChanges { target: configTitle; text: configModel.name + " Settings"}
25
26             AnchorChanges { target: quitApplyConfigButton; anchors.left: undefined; anchors.right: configDialog.right }
27             AnchorChanges { target: quitCancelConfigButton; anchors.right: undefined; anchors.left: configDialog.left }
28         }
29     ]
30
31     transitions: [
32         Transition {
33             from: "hidden"
34             to: "showSourceConfig"
35
36             SequentialAnimation {
37                 // Show the dialog
38                 PropertyAction { target: configDialog; property: "visible"; value: true }
39                 // Bring the UI elements
40                 ParallelAnimation {
41                     AnchorAnimation { duration: 500 }
42                     ColorAnimation { duration: 400 }
43                 }
44             }
45         },
46         Transition {
47             from: "showSourceConfig"
48             to: "hidden"
49
50             SequentialAnimation {
51                 // Move out the UI elements
52                 ParallelAnimation {
53                     AnchorAnimation { duration: 500 }
54                     ColorAnimation { duration: 400 }
55                 }
56                 // Hide the dialog
57                 PropertyAction { target: configDialog; property: "visible"; value: false }
58             }
59         }
60     ]
61
62     Background {
63         anchors.top: parent.top
64         anchors.left: parent.left
65         anchors.right: parent.right
66         anchors.bottom: quitApplyConfigButton.top
67     }
68
69     Text {
70         id: configTitle
71         color: "white"
72         anchors.top: parent.top
73         anchors.left: parent.left
74         anchors.right: parent.right
75         horizontalAlignment: Text.AlignHCenter
76         font.pixelSize: 24
77         font.bold: true
78     }
79
80     Loader {
81         id: sourceConfigLoader
82         opacity: 0
83         anchors.top: configTitle.bottom
84         anchors.left: parent.left
85         anchors.right: parent.right
86         anchors.bottom: quitApplyConfigButton.top
87
88         Behavior on opacity {
89             NumberAnimation { duration: 1000; easing.type: Easing.InOutQuad }
90         }
91
92         onLoaded: {
93             // fill the UI with information from the model
94             configModel.loadConfiguration(sourceConfigLoader.item)
95         }
96     }
97
98     FancyButton {
99         id: quitApplyConfigButton
100         icon: "../images/apply.png"
101         anchors.bottom: parent.bottom
102         anchors.left: parent.right
103
104         onClicked: {
105             // ask the model to store the configuration
106             configModel.storeConfiguration(sourceConfigLoader.item)
107
108             // Store the configuration of this source, and disappear
109             configDialog.state = "hidden"
110         }
111     }
112
113     FancyButton {
114         id: quitCancelConfigButton
115         icon: "../images/cancel.png"
116         anchors.bottom: parent.bottom
117         anchors.right: parent.left
118
119         onClicked: {
120             // Store the configuration of this source, and disappear
121             configDialog.state = "hidden"
122         }
123     }
124
125 }