Fix and first attempt to use Readability
[quicknewsreader] / qml / QuickNewsReader / content / view / SourceConfigDialog.qml
index 72e53b3..22fa932 100644 (file)
@@ -1,3 +1,21 @@
+/***
+** Copyright (C) 2012 Christophe CHAPUIS <chris.chapuis _at_ gmail _dot_ com>
+**
+** This package is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this package; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+**
+***/
 import QtQuick 1.0
 import "../modelitf"
 
@@ -8,7 +26,7 @@ Rectangle {
     visible: false
     state: "hidden"
 
-    property string configViewComponent
+    property SourceModel configModel;
 
     //property SourceModel model;
     //property SourceConfigComponentView viewComponent;
@@ -18,9 +36,10 @@ Rectangle {
             name: "showSourceConfig"
 
             // In this state, we bring the configuration UI of the source
-            PropertyChanges { target: configDialog; color: "#d0000000" }
+            PropertyChanges { target: configDialog; color: "#80000000" }
             PropertyChanges { target: sourceConfigLoader; opacity: 1 }
-            PropertyChanges { target: sourceConfigLoader; source: configViewComponent }
+            PropertyChanges { target: sourceConfigLoader; source: configModel.settingsComponent }
+            PropertyChanges { target: configTitle; text: configModel.name + " Settings"}
 
             AnchorChanges { target: quitApplyConfigButton; anchors.left: undefined; anchors.right: configDialog.right }
             AnchorChanges { target: quitCancelConfigButton; anchors.right: undefined; anchors.left: configDialog.left }
@@ -58,10 +77,28 @@ Rectangle {
         }
     ]
 
+    Background {
+        anchors.top: parent.top
+        anchors.left: parent.left
+        anchors.right: parent.right
+        anchors.bottom: quitApplyConfigButton.top
+    }
+
+    Text {
+        id: configTitle
+        color: "white"
+        anchors.top: parent.top
+        anchors.left: parent.left
+        anchors.right: parent.right
+        horizontalAlignment: Text.AlignHCenter
+        font.pixelSize: 24
+        font.bold: true
+    }
+
     Loader {
         id: sourceConfigLoader
         opacity: 0
-        anchors.top: parent.top
+        anchors.top: configTitle.bottom
         anchors.left: parent.left
         anchors.right: parent.right
         anchors.bottom: quitApplyConfigButton.top
@@ -69,6 +106,11 @@ Rectangle {
         Behavior on opacity {
             NumberAnimation { duration: 1000; easing.type: Easing.InOutQuad }
         }
+
+        onLoaded: {
+            // fill the UI with information from the model
+            configModel.loadConfiguration(sourceConfigLoader.item)
+        }
     }
 
     FancyButton {
@@ -78,6 +120,9 @@ Rectangle {
         anchors.left: parent.right
 
         onClicked: {
+            // ask the model to store the configuration
+            configModel.storeConfiguration(sourceConfigLoader.item)
+
             // Store the configuration of this source, and disappear
             configDialog.state = "hidden"
         }