pineapple-comic-reader/ComicOverviewPage.qml

76 lines
2.3 KiB
QML
Raw Normal View History

2024-11-09 15:05:14 +08:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import net.blumia.pineapple.comic.reader
import net.blumia.pineapple.comic.reader.comicitem
Control {
id: root
anchors.fill: parent
padding: 5
property var curComicIndex: AppController.currentComicModelIndex()
property bool startReading: AppController.selectedComicOpened
readonly property int comicPageCount: dataByRole(ComicItem.PageCountRole)
2024-11-09 15:05:14 +08:00
function dataByRole(role) {
return AppController.comicsModel.data(curComicIndex, role)
}
contentItem: ColumnLayout {
enabled: !root.startReading
2024-11-09 15:05:14 +08:00
Image {
Layout.fillWidth: true
Layout.maximumHeight: Math.min(root.width / 2, root.height / 2)
fillMode: Image.PreserveAspectFit
source: AppController.coverImageSource(dataByRole(ComicItem.HashRole))
// sourceSize.width: root.width / 3
// sourceSize.height: root.width / 2
}
Label {
Layout.preferredWidth: root.width - 10
text: dataByRole(Qt.DisplayRole)
wrapMode: Text.Wrap
}
Label {
Layout.preferredWidth: root.width - 10
text: "Added: " + new Date(Number(`${dataByRole(ComicItem.AddedTimeRole)}000`)).toLocaleString(Qt.locale())
wrapMode: Text.Wrap
}
Label {
Layout.preferredWidth: root.width - 10
text: `${comicPageCount} pages`
2024-11-09 15:05:14 +08:00
wrapMode: Text.Wrap
}
Label {
Layout.preferredWidth: root.width - 10
text: `Last read at ${dataByRole(ComicItem.CurrentPageRole)} page`
wrapMode: Text.Wrap
}
Button {
Layout.fillWidth: true
text: "Read"
enabled: root.comicPageCount > 0
2024-11-09 15:05:14 +08:00
onClicked: function() {
AppController.openComic()
}
}
Button {
Layout.fillWidth: true
text: "Back"
onClicked: function() {
AppController.selectedComicId = ""
}
}
Item {
Layout.fillHeight: true
}
}
ComicViewer {
parent: Overlay.overlay
2024-11-09 15:05:14 +08:00
visible: root.startReading
pageCount: dataByRole(ComicItem.PageCountRole)
}
}