summaryrefslogtreecommitdiffstats
path: root/ui/qml/components
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qml/components')
-rw-r--r--ui/qml/components/Colors.qml54
-rw-r--r--ui/qml/components/Fonts.qml33
-rw-r--r--ui/qml/components/JSONListModel.qml91
-rw-r--r--ui/qml/components/JSONQuery.qml51
-rw-r--r--ui/qml/components/Settings.qml93
5 files changed, 322 insertions, 0 deletions
diff --git a/ui/qml/components/Colors.qml b/ui/qml/components/Colors.qml
new file mode 100644
index 0000000..2b6397b
--- /dev/null
+++ b/ui/qml/components/Colors.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt demos.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.5
+
+QtObject {
+ id: colors
+
+ readonly property color background1: "#3b7c74"
+ readonly property color background2: "#104a58"
+ readonly property color background3: "#04304d"
+ readonly property color background4: "#041f3a"
+ readonly property color background5: "#021124"
+
+ readonly property color gray1: Qt.rgba(0.0, 0.0, 0.0, 0.4)
+ readonly property color gray2: Qt.rgba(0.0, 0.0, 0.0, 0.8)
+ readonly property color gray3: "#999999"
+ readonly property color gray4: "#555555"
+
+ readonly property color green1: "#41cd52"
+ readonly property color green2: "#dcfcbd"
+
+ readonly property color yellow1: "#ffef26"
+
+ readonly property color white1: "#ffffff"
+ readonly property color white2: Qt.rgba(1.0, 1.0, 1.0, 0.8)
+ readonly property color white3: Qt.rgba(1.0, 1.0, 1.0, 0.5)
+ readonly property color white4: Qt.rgba(1.0, 1.0, 1.0, 0.06)
+
+ readonly property color black: "#000000"
+ readonly property color transparent: Qt.rgba(0.0, 0.0, 0.0, 0.0)
+}
diff --git a/ui/qml/components/Fonts.qml b/ui/qml/components/Fonts.qml
new file mode 100644
index 0000000..d4db9a5
--- /dev/null
+++ b/ui/qml/components/Fonts.qml
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt demos.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.5
+
+QtObject {
+ id: fonts
+
+ readonly property string titillium: "Titillium Web"
+ readonly property string fontAwesome: "FontAwesome"
+}
diff --git a/ui/qml/components/JSONListModel.qml b/ui/qml/components/JSONListModel.qml
new file mode 100644
index 0000000..154c4ca
--- /dev/null
+++ b/ui/qml/components/JSONListModel.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt demos.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import "../scripts/XMLHttpRequestCache.js" as XMLHttpRequestCache
+
+ListModel {
+ id: jsonListModel
+
+ property string source: ""
+ property bool working: false
+ property string arrayPropertyName: ""
+ property bool cached: true
+ property int cacheUpdateInterval: 1000 * 60 * 10 // 10 minutes
+
+ onSourceChanged: {
+ function processResponse(responseText) {
+ var items = JSON.parse(responseText)[arrayPropertyName]
+
+ if (items) {
+ var i = 0
+ var count = items.length
+ for (; i < count; i++) {
+ var item = items[i]
+ if (typeof item === "object") {
+ jsonListModel.append(item)
+ }
+ }
+ }
+
+ working = false
+ }
+
+ working = true
+
+ jsonListModel.clear()
+
+ var usingCacheData = false
+
+ if (cached) {
+ var cacheData = XMLHttpRequestCache.cache[source]
+
+ if (cacheData) {
+ if (new Date().getTime() - cacheData.timestamp < cacheUpdateInterval) {
+ usingCacheData = true
+ processResponse(cacheData.response)
+ }
+ }
+ }
+
+ if (!usingCacheData) {
+ var xhr = new XMLHttpRequest
+ xhr.open("GET", source)
+
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.DONE) {
+ XMLHttpRequestCache.cache[source] = {
+ timestamp: new Date().getTime(),
+ response: xhr.responseText
+ }
+
+ processResponse(xhr.responseText)
+ }
+ }
+
+ xhr.send()
+ }
+ }
+}
diff --git a/ui/qml/components/JSONQuery.qml b/ui/qml/components/JSONQuery.qml
new file mode 100644
index 0000000..ac54af5
--- /dev/null
+++ b/ui/qml/components/JSONQuery.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt demos.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+QtObject {
+ id: jsonQuery
+
+ property var source
+ property var result
+
+ onSourceChanged: {
+ var xhr = new XMLHttpRequest
+ xhr.open("GET", source)
+
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.DONE) {
+ if (xhr.status === 200) {
+ result = JSON.parse(xhr.responseText)
+ } else {
+ result = "Network error, status code: %1".arg(xhr.status)
+ }
+
+ }
+ }
+
+ xhr.send()
+ }
+}
diff --git a/ui/qml/components/Settings.qml b/ui/qml/components/Settings.qml
new file mode 100644
index 0000000..32ba5bd
--- /dev/null
+++ b/ui/qml/components/Settings.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt demos.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import "../scripts/datamodels.js" as DataModels
+import "../scripts/3rdparty/YoutubeClientV3.js" as YoutubeClient
+
+QtObject {
+ id: settings
+
+ property string youTubeKey: ""
+ property string tmdbKey: ""
+
+ readonly property int minimumVolume: 0
+ readonly property int maximumVolume: 5
+ property int volume: 5
+
+ readonly property var requiredKeys: ["YouTube", "TMDb"]
+ property var missingKeys: []
+
+ signal initialized()
+
+ onYouTubeKeyChanged: {
+ YoutubeClient.youTubeDataKey = youTubeKey
+ }
+
+ onTmdbKeyChanged: {
+ DataModels.apiKey = tmdbKey
+ }
+
+ Component.onCompleted: {
+ if (requiredKeys.length > 0) {
+ keyLoader.loadKey(0)
+ } else {
+ initialized()
+ }
+ }
+
+ property Loader keyLoader: Loader {
+ property int currentKeyIndex
+
+ function loadKey(index) {
+ currentKeyIndex = index
+ source = Qt.resolvedUrl("qrc:/secrets/%1.qml".arg(requiredKeys[index]))
+ }
+
+ onStatusChanged: {
+ if (status === Loader.Ready) {
+ switch (currentKeyIndex) {
+ case 0:
+ settings.youTubeKey = item.key
+ break
+ case 1:
+ settings.tmdbKey = item.key
+ break
+ }
+ } else if (status === Loader.Error) {
+ settings.missingKeys.push(settings.requiredKeys[currentKeyIndex])
+ }
+
+ if (status === Loader.Ready ||
+ status === Loader.Error) {
+ if (currentKeyIndex < settings.requiredKeys.length - 1) {
+ loadKey(currentKeyIndex + 1)
+ } else {
+ settings.initialized()
+ }
+ }
+ }
+ }
+}