From 2ef56438b62cdfd562caea3c84b44f8ad9a291c6 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Fri, 31 Jan 2014 16:18:56 +0100 Subject: [PATCH] Migrate to using gpodder-ui-qml common glue code --- dev_symlinks.sh | 1 + gpodder-ui-qml | 2 +- qml/EpisodesPage.qml | 4 +-- qml/FreshEpisodes.qml | 4 +-- qml/Main.qml | 48 ++++----------------------- qml/PodcastsPage.qml | 6 ++-- qml/util.js | 44 ------------------------ rpm/harbour-org.gpodder.sailfish.spec | 1 + 8 files changed, 15 insertions(+), 95 deletions(-) delete mode 100644 qml/util.js diff --git a/dev_symlinks.sh b/dev_symlinks.sh index 6f64d8d..6eece8a 100644 --- a/dev_symlinks.sh +++ b/dev_symlinks.sh @@ -6,3 +6,4 @@ ln -sf gpodder-core/src/gpodder . ln -sf gpodder-core/src/jsonconfig.py . ln -sf podcastparser/podcastparser.py . ln -sf gpodder-ui-qml/main.py . +ln -sf ../gpodder-ui-qml/common qml diff --git a/gpodder-ui-qml b/gpodder-ui-qml index d267582..c1f8db5 160000 --- a/gpodder-ui-qml +++ b/gpodder-ui-qml @@ -1 +1 @@ -Subproject commit d267582aa0b16cae1ead227b141b0e707e702a67 +Subproject commit c1f8db5500b117d0d704e782bad62cd54579d9fd diff --git a/qml/EpisodesPage.qml b/qml/EpisodesPage.qml index b457511..305f42d 100644 --- a/qml/EpisodesPage.qml +++ b/qml/EpisodesPage.qml @@ -22,7 +22,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import io.thp.pyotherside 1.0 -import 'util.js' as Util +import 'common/util.js' as Util import 'constants.js' as Constants Page { @@ -43,7 +43,7 @@ Page { } Connections { - target: pgst + target: py onDownloadProgress: { Util.updateModelWith(episodeListModel, 'id', episode_id, {'progress': progress}); diff --git a/qml/FreshEpisodes.qml b/qml/FreshEpisodes.qml index 40e1f63..5552004 100644 --- a/qml/FreshEpisodes.qml +++ b/qml/FreshEpisodes.qml @@ -21,7 +21,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 -import 'util.js' as Util +import 'common/util.js' as Util Page { id: freshEpisodes @@ -74,7 +74,7 @@ Page { onClicked: py.call('main.download_episode', [id]); Connections { - target: pgst + target: py onDownloaded: { if (id == episode_id) { freshEpisodesListModel.remove(index); diff --git a/qml/Main.qml b/qml/Main.qml index 5eaf21f..9e6454b 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -20,7 +20,8 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 -import io.thp.pyotherside 1.0 + +import 'common' PodcastsPage { id: pgst @@ -40,11 +41,9 @@ PodcastsPage { children[index-1].opacity = x / width; } - signal downloading(int episode_id) - signal downloadProgress(int episode_id, real progress) - signal downloaded(int episode_id) - signal deleted(int episode_id) - signal isNewChanged(int episode_id, bool is_new) + GPodderCore { + id: py + } function loadPage(filename, properties) { var component = Qt.createComponent(filename); @@ -59,41 +58,6 @@ PodcastsPage { } } - Python { - id: py - - Component.onCompleted: { - addImportPath('.'); - - setHandler('hello', function (version, copyright) { - console.log('gPodder version ' + version + ' starting up'); - console.log('Copyright: ' + copyright); - }); - - setHandler('downloading', pgst.downloading); - setHandler('download-progress', pgst.downloadProgress); - setHandler('downloaded', pgst.downloaded); - setHandler('deleted', pgst.deleted); - setHandler('is-new-changed', pgst.isNewChanged); - - var path = Qt.resolvedUrl('..').substr('file://'.length); - addImportPath(path); - - // Load the Python side of things - importModule('main', function() { - pgst.ready = true; - }); - } - - onReceived: { - console.log('unhandled message: ' + data); - } - - onError: { - console.log('Python failure: ' + traceback); - } - } - Player { id: player } @@ -101,7 +65,7 @@ PodcastsPage { BusyIndicator { size: BusyIndicatorSize.Large anchors.centerIn: parent - visible: !pgst.ready + visible: !py.ready running: visible } } diff --git a/qml/PodcastsPage.qml b/qml/PodcastsPage.qml index 36b72c5..6aa10d4 100644 --- a/qml/PodcastsPage.qml +++ b/qml/PodcastsPage.qml @@ -21,16 +21,14 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 -import 'util.js' as Util +import 'common/util.js' as Util Page { id: podcastsPage function reload() { - pgst.ready = false; py.call('main.load_podcasts', [], function (podcasts) { Util.updateModelFrom(podcastListModel, podcasts); - pgst.ready = true; }); } @@ -107,7 +105,7 @@ Page { } ViewPlaceholder { - enabled: podcastListModel.count == 0 && pgst.ready + enabled: podcastListModel.count == 0 && py.ready text: 'No subscriptions' } } diff --git a/qml/util.js b/qml/util.js deleted file mode 100644 index 2fb45d6..0000000 --- a/qml/util.js +++ /dev/null @@ -1,44 +0,0 @@ - -/** - * - * gPodder QML UI Reference Implementation - * Copyright (c) 2013, Thomas Perl - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -function updateModelFrom(model, data) { - for (var i=0; i data.length) { - model.remove(model.count-1); - } -} - -function updateModelWith(model, key, value, update) { - for (var row=0; row