Lettore: margini configurabili (Settings.readerMargin + Slider nelle impostazioni, iniettati nello stile del capitolo) + controlli in PushUpMenu (un solo trascinamento in alto)
This commit is contained in:
+59
-80
@@ -27,10 +27,7 @@ Page {
|
||||
}
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: toolbar.top
|
||||
anchors.fill: parent
|
||||
contentHeight: parent.height
|
||||
|
||||
// il PullDownMenu va DENTRO una vista Silica, non a livello di Page
|
||||
@@ -45,6 +42,59 @@ Page {
|
||||
}
|
||||
}
|
||||
|
||||
// controlli del lettore: un solo trascinamento in alto li apre
|
||||
PushUpMenu {
|
||||
id: readerMenu
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
text: (book.chapterCount > 0)
|
||||
? (page.currentChapter + 1) + "/" + book.chapterCount
|
||||
+ " · " + book.chapterTitle(page.currentChapter)
|
||||
+ " · " + Math.round(page.overallProgress() * 100) + "%"
|
||||
: "…"
|
||||
truncationMode: TruncationMode.Elide
|
||||
color: Theme.primaryColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: Theme.paddingSmall
|
||||
IconButton {
|
||||
icon.source: "image://theme/icon-m-left"
|
||||
enabled: page.currentChapter > 0
|
||||
onClicked: gotoChapter(page.currentChapter - 1)
|
||||
}
|
||||
Button {
|
||||
text: "A−"
|
||||
width: Theme.itemSizeSmall
|
||||
height: Theme.itemSizeMedium
|
||||
onClicked: page.changeFontScale(-0.15)
|
||||
}
|
||||
Button {
|
||||
text: "A+"
|
||||
width: Theme.itemSizeSmall
|
||||
height: Theme.itemSizeMedium
|
||||
onClicked: page.changeFontScale(0.15)
|
||||
}
|
||||
IconButton {
|
||||
icon.source: "image://theme/icon-m-right"
|
||||
enabled: page.currentChapter < book.chapterCount - 1
|
||||
onClicked: gotoChapter(page.currentChapter + 1)
|
||||
}
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
width: parent.width
|
||||
value: page.overallProgress()
|
||||
minimumValue: 0
|
||||
maximumValue: 1
|
||||
}
|
||||
}
|
||||
|
||||
WebView {
|
||||
id: web
|
||||
anchors.fill: parent
|
||||
@@ -98,79 +148,7 @@ Page {
|
||||
visible: page.errorMessage.length > 0
|
||||
}
|
||||
|
||||
// ---- barra di controllo ----
|
||||
Rectangle {
|
||||
id: toolbar
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
height: Theme.itemSizeMedium
|
||||
color: Theme.rgba(Theme.primaryColor, 0.08)
|
||||
|
||||
IconButton {
|
||||
id: prevBtn
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon.source: "image://theme/icon-m-left"
|
||||
enabled: page.currentChapter > 0
|
||||
onClicked: gotoChapter(page.currentChapter - 1)
|
||||
}
|
||||
|
||||
Button {
|
||||
id: fontMinus
|
||||
anchors.left: prevBtn.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Theme.itemSizeSmall
|
||||
height: Theme.itemSizeMedium
|
||||
text: "A−"
|
||||
onClicked: page.changeFontScale(-0.15)
|
||||
}
|
||||
|
||||
Button {
|
||||
id: fontPlus
|
||||
anchors.left: fontMinus.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Theme.itemSizeSmall
|
||||
height: Theme.itemSizeMedium
|
||||
text: "A+"
|
||||
onClicked: page.changeFontScale(0.15)
|
||||
}
|
||||
|
||||
Label {
|
||||
id: chapterLabel
|
||||
anchors.left: fontPlus.right
|
||||
anchors.right: nextBtn.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: (book.chapterCount > 0)
|
||||
? (page.currentChapter + 1) + "/" + book.chapterCount
|
||||
+ " · " + book.chapterTitle(page.currentChapter)
|
||||
+ " · " + Math.round(page.overallProgress() * 100) + "%"
|
||||
: "…"
|
||||
truncationMode: TruncationMode.Elide
|
||||
color: Theme.primaryColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
}
|
||||
|
||||
IconButton {
|
||||
id: nextBtn
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
icon.source: "image://theme/icon-m-right"
|
||||
enabled: page.currentChapter < book.chapterCount - 1
|
||||
onClicked: gotoChapter(page.currentChapter + 1)
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
height: 6
|
||||
value: page.overallProgress()
|
||||
minimumValue: 0
|
||||
maximumValue: 1
|
||||
}
|
||||
}
|
||||
// ---- controlli spostati nel PushUpMenu (trascina in alto) ----
|
||||
|
||||
// ---- timer di tracciamento ----
|
||||
Timer {
|
||||
@@ -242,10 +220,11 @@ Page {
|
||||
return Math.round(16 * page.fontScale * 100) / 100
|
||||
}
|
||||
|
||||
// carica il capitolo corrente via loadHtml: lo stile di reflow (font-size)
|
||||
// è iniettato nell'HTML dal parser, quindi niente JS post-load
|
||||
// carica il capitolo corrente via loadHtml: lo stile di reflow (font-size
|
||||
// e margini) è iniettato nell'HTML dal parser, quindi niente JS post-load
|
||||
function loadChapter() {
|
||||
var html = book.chapterHtml(page.currentChapter, page.fontPx())
|
||||
var html = book.chapterHtml(page.currentChapter, page.fontPx(),
|
||||
appSettings.readerMargin)
|
||||
if (html.length === 0) {
|
||||
page.errorMessage = "Capitolo non leggibile"
|
||||
page.ready = true
|
||||
|
||||
Reference in New Issue
Block a user