mirror of https://github.com/KDE/kasts.git
Optimize image loading (partially) and improve QueueDelegate
This commit is contained in:
parent
ddb64c5f42
commit
5efd4f85f8
|
@ -32,7 +32,7 @@ QVariant EntriesModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (role != 0)
|
if (role != 0)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
qDebug() << "fetching item" << index.row();
|
//qDebug() << "fetching item" << index.row();
|
||||||
return QVariant::fromValue(DataManager::instance().getEntry(m_feed, index.row()));
|
return QVariant::fromValue(DataManager::instance().getEntry(m_feed, index.row()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,49 +15,54 @@ import org.kde.alligator 1.0
|
||||||
Kirigami.SwipeListItem {
|
Kirigami.SwipeListItem {
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
Kirigami.Icon {
|
Image {
|
||||||
source: entry.image === "" ? "rss" : Fetcher.image(entry.image)
|
asynchronous: true
|
||||||
height: parent.height
|
source: entry.image === "" ? "rss" : "file://"+Fetcher.image(entry.image)
|
||||||
width: height
|
fillMode: Image.PreserveAspectFit
|
||||||
|
property int size: Kirigami.Units.iconSizes.medium
|
||||||
|
Layout.maximumHeight: size
|
||||||
|
Layout.maximumWidth: size
|
||||||
|
sourceSize.width: size
|
||||||
|
sourceSize.height: size
|
||||||
}
|
}
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
Controls.Label {
|
|
||||||
text: entry.title
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
Layout.alignment: Qt.AlignVCenter
|
||||||
font.weight: entry.read ? Font.Normal : Font.Bold
|
Controls.Label {
|
||||||
opacity: 1
|
text: entry.title
|
||||||
}
|
Layout.fillWidth: true
|
||||||
Loader {
|
elide: Text.ElideRight
|
||||||
sourceComponent: entry.enclosure && entry.enclosure.status === Enclosure.Downloading ? downloadProgress : subtitle
|
font.weight: entry.read ? Font.Normal : Font.Bold
|
||||||
Layout.fillWidth: true
|
opacity: 1
|
||||||
Component {
|
|
||||||
id: subtitle
|
|
||||||
Controls.Label {
|
|
||||||
text: entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (entry.authors.length === 0 ? "" : " " + i18nc("by <author(s)>", "by") + " " + entry.authors[0].name)
|
|
||||||
Layout.fillWidth: true
|
|
||||||
elide: Text.ElideRight
|
|
||||||
font: Kirigami.Theme.smallFont
|
|
||||||
opacity: entry.read ? 0.7 : 0.9
|
|
||||||
visible: !downloadProgress.visible
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Component {
|
Loader {
|
||||||
id: downloadProgress
|
sourceComponent: entry.enclosure && entry.enclosure.status === Enclosure.Downloading ? downloadProgress : subtitle
|
||||||
Controls.ProgressBar {
|
Layout.fillWidth: true
|
||||||
from: 0
|
Component {
|
||||||
to: 100
|
id: subtitle
|
||||||
value: entry.enclosure.downloadProgress
|
Controls.Label {
|
||||||
visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading
|
text: entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (entry.authors.length === 0 ? "" : " " + i18nc("by <author(s)>", "by") + " " + entry.authors[0].name)
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideRight
|
||||||
|
font: Kirigami.Theme.smallFont
|
||||||
|
opacity: entry.read ? 0.7 : 0.9
|
||||||
|
visible: !downloadProgress.visible
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: downloadProgress
|
||||||
|
Controls.ProgressBar {
|
||||||
|
from: 0
|
||||||
|
to: 100
|
||||||
|
value: entry.enclosure.downloadProgress
|
||||||
|
visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
entry.read = true
|
entry.read = true
|
||||||
|
|
|
@ -20,15 +20,15 @@ Kirigami.SwipeListItem {
|
||||||
contentItem: Kirigami.BasicListItem {
|
contentItem: Kirigami.BasicListItem {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
text: model.feed.name
|
text: feed.name
|
||||||
icon: model.feed.refreshing ? "view-refresh" : model.feed.image === "" ? "rss" : Fetcher.image(model.feed.image)
|
icon: feed.refreshing ? "view-refresh" : feed.image === "" ? "rss" : Fetcher.image(feed.image)
|
||||||
iconSize: Kirigami.Units.iconSizes.large
|
iconSize: Kirigami.Units.iconSizes.medium
|
||||||
subtitle: i18np("%1 unread entry", "%1 unread entries", model.feed.unreadEntryCount)
|
subtitle: i18np("%1 unread entry", "%1 unread entries", feed.unreadEntryCount)
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
lastFeed = model.feed.url
|
lastFeed = feed.url
|
||||||
|
|
||||||
pageStack.push("qrc:/EntryListPage.qml", {"feed": model.feed})
|
pageStack.push("qrc:/EntryListPage.qml", {"feed": feed})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ Kirigami.SwipeListItem {
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
icon.name: "delete"
|
icon.name: "delete"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if(pageStack.depth > 1 && model.feed.url === lastFeed)
|
if(pageStack.depth > 1 && feed.url === lastFeed)
|
||||||
while(pageStack.depth > 1)
|
while(pageStack.depth > 1)
|
||||||
pageStack.pop()
|
pageStack.pop()
|
||||||
feedsModel.removeFeed(index)
|
feedsModel.removeFeed(index)
|
||||||
|
|
|
@ -22,21 +22,33 @@ Kirigami.SwipeListItem {
|
||||||
listView: queueList
|
listView: queueList
|
||||||
onMoveRequested: DataManager.moveQueueItem(oldIndex, newIndex)
|
onMoveRequested: DataManager.moveQueueItem(oldIndex, newIndex)
|
||||||
}
|
}
|
||||||
Kirigami.Icon {
|
Image {
|
||||||
source: entry.image === "" ? "rss" : Fetcher.image(entry.image)
|
asynchronous: true
|
||||||
property int size: Kirigami.Units.iconSizes.medium
|
source: entry.image === "" ? "rss" : "file://"+Fetcher.image(entry.image)
|
||||||
Layout.minimumHeight: size
|
fillMode: Image.PreserveAspectFit
|
||||||
Layout.minimumWidth: size
|
property int size: Kirigami.Units.gridUnit * 3
|
||||||
|
sourceSize.width: size
|
||||||
|
sourceSize.height: size
|
||||||
|
Layout.maximumHeight: size
|
||||||
|
Layout.maximumWidth: size
|
||||||
|
Layout.rightMargin:Kirigami.Units.smallSpacing
|
||||||
}
|
}
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 0
|
spacing: Kirigami.Units.smallSpacing
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
Controls.Label {
|
||||||
|
text: entry.updated.toLocaleDateString(Qt.locale(), Locale.NarrowFormat) + (entry.enclosure ? " · " + Math.floor(entry.enclosure.size/(1024*1024)) + "MB" : "")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideRight
|
||||||
|
font: Kirigami.Theme.smallFont
|
||||||
|
opacity: 0.7
|
||||||
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: entry.title
|
text: entry.title
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font.weight: entry.read ? Font.Normal : Font.Bold
|
font.weight: Font.Normal
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}
|
}
|
||||||
Loader {
|
Loader {
|
||||||
|
@ -45,11 +57,11 @@ Kirigami.SwipeListItem {
|
||||||
Component {
|
Component {
|
||||||
id: subtitle
|
id: subtitle
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
text: entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (entry.authors.length === 0 ? "" : " " + i18nc("by <author(s)>", "by") + " " + entry.authors[0].name)
|
text: (Math.floor(entry.enclosure.duration/3600) < 10 ? "0" : "") + Math.floor(entry.enclosure.duration/3600) + ":" + (Math.floor(entry.enclosure.duration/60) % 60 < 10 ? "0" : "") + Math.floor(entry.enclosure.duration/60) % 60 + ":" + (Math.floor(entry.enclosure.duration) % 60 < 10 ? "0" : "") + Math.floor(entry.enclosure.duration) % 60
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font: Kirigami.Theme.smallFont
|
font: Kirigami.Theme.smallFont
|
||||||
opacity: entry.read ? 0.7 : 0.9
|
opacity: 0.7
|
||||||
visible: !downloadProgress.visible
|
visible: !downloadProgress.visible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,9 +89,10 @@ Kirigami.SwipeListItem {
|
||||||
iconName: "media-playback-start"
|
iconName: "media-playback-start"
|
||||||
text: "Play"
|
text: "Play"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
audio.entry = entry
|
audio.entry = entry
|
||||||
audio.play()
|
audio.play()
|
||||||
}
|
}
|
||||||
|
visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloaded
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
text: i18n("Download")
|
text: i18n("Download")
|
||||||
|
|
Loading…
Reference in New Issue