-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComicViewer.qml
101 lines (88 loc) · 2.55 KB
/
ComicViewer.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import net.blumia.pineapple.comic.reader
Pane {
id: root
required property int pageCount
property bool osdVisible: false
anchors.fill: parent
SwipeView {
id: view
anchors.fill: parent
onVisibleChanged: function() {
if (visible) {
forceActiveFocus()
}
}
Repeater {
model: root.pageCount
Loader {
active: root.visible && (SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem)
sourceComponent: Image {
anchors.fill: parent
fillMode: Image.PreserveAspectFit
source: AppController.comicImageSource(index)
onStatusChanged: function() {
if (status == Image.Error) {
reloadTimer.start()
}
}
Timer {
id: reloadTimer
interval: 500
onTriggered: {
console.log("reload")
let origSrc = parent.source
parent.source = ""
parent.source = origSrc
}
}
}
}
}
}
Pane {
visible: root.osdVisible
anchors.fill: parent
opacity: 0.65
}
ColumnLayout {
visible: root.osdVisible
enabled: root.osdVisible
anchors.fill: parent
Item {
Layout.fillWidth: true
Layout.fillHeight: true
TapHandler {
onTapped: function() {
root.osdVisible = !root.osdVisible
}
}
}
Button {
text: "Close Comic"
Layout.fillWidth: true
onClicked: function() {
root.osdVisible = false
AppController.closeComic()
}
}
}
PageIndicator {
id: indicator
visible: !root.osdVisible
count: view.count
currentIndex: view.currentIndex
anchors.top: view.top
anchors.horizontalCenter: parent.horizontalCenter
TapHandler {
onTapped: function() {
root.osdVisible = !root.osdVisible
}
}
}
Keys.onEscapePressed: function(event) {
root.osdVisible = !root.osdVisible
}
}