Migrate to using gpodder-ui-qml common glue code
This commit is contained in:
parent
c4253df569
commit
2ef56438b6
8 changed files with 15 additions and 95 deletions
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d267582aa0b16cae1ead227b141b0e707e702a67
|
||||
Subproject commit c1f8db5500b117d0d704e782bad62cd54579d9fd
|
|
@ -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});
|
||||
|
|
|
@ -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);
|
||||
|
|
48
qml/Main.qml
48
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
}
|
||||
|
|
44
qml/util.js
44
qml/util.js
|
@ -1,44 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* gPodder QML UI Reference Implementation
|
||||
* Copyright (c) 2013, Thomas Perl <m@thp.io>
|
||||
*
|
||||
* 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; i++) {
|
||||
if (model.count < i) {
|
||||
model.append(data[i]);
|
||||
} else {
|
||||
model.set(i, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
while (model.count > data.length) {
|
||||
model.remove(model.count-1);
|
||||
}
|
||||
}
|
||||
|
||||
function updateModelWith(model, key, value, update) {
|
||||
for (var row=0; row<model.count; row++) {
|
||||
var current = model.get(row);
|
||||
if (current[key] == value) {
|
||||
for (var key in update) {
|
||||
model.setProperty(row, key, update[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ cp -rpv gpodder-core/src/* $TARGET/
|
|||
cp -rpv podcastparser/podcastparser.py $TARGET/
|
||||
cp -rpv gpodder-ui-qml/main.py $TARGET/
|
||||
cp -rpv qml $TARGET/
|
||||
cp -rpv gpodder-ui-qml/common $TARGET/qml/
|
||||
cp -rpv %{name}.qml $TARGET/
|
||||
|
||||
TARGET=%{buildroot}/%{_datadir}/applications
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue