initial epub support

This commit is contained in:
Agel committed 2026-03-19 23:27:01 +01:00
1 parent 53d6d541a7
commit f328e7dab0
9 files changed
+878 -5

No files matched your search

+50 -2
View File
@@ -1,4 +1,5 @@
import QtQuick
import QtQuick.Controls
import Asteria
Rectangle {
@@ -12,9 +13,33 @@ Rectangle {
anchors.top: parent.top
}
Text {
// Prev chapter button
Button {
id: prevBtn
anchors.verticalCenter: parent.verticalCenter
x: parent.width * 0.5
x: parent.width * 0.5 - chapterText.implicitWidth / 2 - width - 4
visible: bookController.hasBook && readingModel.hasChapters
enabled: readingModel.currentChapter > 0
flat: true
padding: 0
implicitWidth: 20
implicitHeight: 20
contentItem: Text {
text: "\ue5cb"
font.family: "Material Icons Outlined"
font.pixelSize: 16
color: prevBtn.enabled ? Theme.dimText : Theme.actionDisabled
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Item {}
onClicked: readingModel.previousChapter()
}
Text {
id: chapterText
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
text: bookController.hasBook && readingModel.hasChapters
? "Chapter " + (readingModel.currentChapter + 1) + " / " + readingModel.totalChapters
: ""
@@ -23,6 +48,29 @@ Rectangle {
color: Theme.dimText
}
// Next chapter button
Button {
id: nextBtn
anchors.verticalCenter: parent.verticalCenter
x: parent.width * 0.5 + chapterText.implicitWidth / 2 + 4
visible: bookController.hasBook && readingModel.hasChapters
enabled: readingModel.currentChapter < readingModel.totalChapters - 1
flat: true
padding: 0
implicitWidth: 20
implicitHeight: 20
contentItem: Text {
text: "\ue5cc"
font.family: "Material Icons Outlined"
font.pixelSize: 16
color: nextBtn.enabled ? Theme.dimText : Theme.actionDisabled
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Item {}
onClicked: readingModel.nextChapter()
}
Text {
anchors.right: parent.right
anchors.rightMargin: 16
+5
View File
@@ -3,6 +3,11 @@ import QtQuick.Controls
import Asteria
Rectangle {
focus: true
Keys.onLeftPressed: readingModel.previousChapter()
Keys.onRightPressed: readingModel.nextChapter()
gradient: Gradient {
GradientStop { position: 0.0; color: Theme.gradientTop }
GradientStop { position: 1.0; color: Theme.gradientBottom }
+69
View File
@@ -49,6 +49,7 @@ Rectangle {
}
Column {
id: navColumn
y: Theme.headerHeight
width: Theme.sidebarWidth
@@ -96,4 +97,72 @@ Rectangle {
onClicked: sidebar.navigateTo("settings")
}
}
// TOC section — shown when the current book has a table of contents
Item {
visible: bookController.hasBook && bookController.toc.length > 0
anchors.top: navColumn.bottom
anchors.bottom: parent.bottom
width: parent.width
Rectangle {
id: tocDivider
width: parent.width
height: 1
color: Theme.divider
}
Text {
id: tocLabel
anchors.top: tocDivider.bottom
anchors.topMargin: 8
anchors.left: parent.left
anchors.leftMargin: 16
text: "Contents"
font.pixelSize: 10
font.bold: true
color: Theme.dimText
font.letterSpacing: 1
}
ListView {
anchors.top: tocLabel.bottom
anchors.topMargin: 4
anchors.bottom: parent.bottom
width: parent.width
clip: true
model: bookController.toc
delegate: Rectangle {
width: ListView.view.width
height: tocEntryText.implicitHeight + 10
color: readingModel.currentChapter === modelData.chapterIndex
? Qt.rgba(1, 1, 1, 0.05)
: "transparent"
Text {
id: tocEntryText
anchors.verticalCenter: parent.verticalCenter
x: 16 + modelData.depth * 12
width: parent.width - x - 8
text: modelData.title
font.pixelSize: 13
color: readingModel.currentChapter === modelData.chapterIndex
? Theme.sidebarButtonText
: Theme.uiText
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
MouseArea {
anchors.fill: parent
onClicked: {
readingModel.goToChapter(modelData.chapterIndex)
sidebar.navigateTo("reader")
sidebar.closeDrawer()
}
}
}
}
}
}