Warning, /maui/mauikit-documents/src/controls.5/poppler/PDFViewer.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.14
0002 import QtQuick.Controls 2.14
0003 import QtQuick.Layouts 1.12
0004 import QtQuick.Window 2.15
0005
0006 import org.mauikit.controls 1.3 as Maui
0007 import org.mauikit.documents 1.0 as Poppler
0008
0009 Maui.Page
0010 {
0011 id: control
0012
0013 property bool fitWidth: false
0014 property int currentPage : _listView.currentIndex
0015 property alias currentItem :_listView.currentItem
0016 property alias orientation : _listView.orientation
0017 property alias path : poppler.path
0018
0019 headBar.visible: false
0020 footBar.visible: !Maui.Handy.isMobile && poppler.pages > 1
0021 title: poppler.title
0022 padding: 0
0023
0024 Maui.InputDialog
0025 {
0026 id: _passwordDialog
0027
0028 title: i18n("Document Locked")
0029 message: i18n("Please enter your password to unlock and open the file.")
0030 textEntry.echoMode: TextInput.Password
0031 onFinished: poppler.unlock(text, text)
0032 }
0033
0034 footBar.middleContent: Maui.ToolActions
0035 {
0036 Layout.alignment: Qt.AlignCenter
0037 expanded: true
0038 autoExclusive: false
0039 checkable: false
0040
0041 Action
0042 {
0043 enabled: _listView.currentIndex > 0
0044 icon.name: _listView.orientation === ListView.Horizontal ? "go-previous" : "go-up"
0045 onTriggered:
0046 {
0047 if( _listView.currentIndex > 0)
0048 _listView.currentIndex = _listView.currentIndex - 1
0049 }
0050 }
0051
0052 Action
0053 {
0054 text: _listView.currentIndex + 1 +" / "+ poppler.pages
0055 }
0056
0057 Action
0058 {
0059 enabled: _listView.currentIndex +1 < poppler.pages
0060 icon.name: _listView.orientation === ListView.Horizontal ? "go-next" : "go-down"
0061 onTriggered:
0062 {
0063 if( _listView.currentIndex +1 < poppler.pages)
0064 _listView.currentIndex = _listView.currentIndex + 1
0065 }
0066 }
0067 }
0068
0069 Maui.ListBrowser
0070 {
0071 id: _listView
0072 anchors.fill: parent
0073 model: Poppler.Document
0074 {
0075 id: poppler
0076
0077 property bool isLoading: true
0078
0079 onPagesLoaded:
0080 {
0081 isLoading = false;
0082 }
0083
0084 onDocumentLocked: _passwordDialog.open()
0085 }
0086
0087 orientation: ListView.Vertical
0088 snapMode: ListView.SnapOneItem
0089 // cacheBuffer: control.fitWidth ? poppler.providersNumber * : height * poppler.providersNumber
0090
0091 flickable.onMovementEnded:
0092 {
0093 var index = indexAt(_listView.contentX, _listView.contentY)
0094 currentIndex = index
0095 }
0096
0097 delegate: Maui.ImageViewer
0098 {
0099 id: pageImg
0100 asynchronous: true
0101 width: ListView.view.width
0102 height: ListView.view.height
0103
0104 cache: false
0105 // source: "image://poppler" + (index % poppler.providersNumber) + "/page/" + _listView.currentPage;
0106 // source: "image://poppler" + (index % poppler.providersNumber) + "/page/" + index;
0107 source: "image://" + poppler.id + (index % poppler.providersNumber) + "/page/" + index
0108 // source: "image://poppler/page/" + _listView.currentPage;
0109 sourceSize.width: model.width
0110 sourceSize.height: model.height
0111 // sourceSize.height: 2000
0112 // imageWidth: 1000
0113 // imageHeight: 1000
0114 fillMode: Image.PreserveAspectFit
0115
0116 // onSourceChanged: console.log(source)
0117 }
0118 }
0119
0120 Maui.Holder
0121 {
0122 visible: !poppler.isValid
0123 anchors.fill: parent
0124 emoji: poppler.isLocked ? "qrc:/img_assets/assets/lock.svg" : "qrc:/img_assets/assets/alarm.svg"
0125 title: poppler.isLocked ? i18n("Locked") : i18n("Error")
0126 body: poppler.isLocked ? i18n("This document is password protected.") : i18n("There has been an error loading this document.")
0127
0128 actions: Action
0129 {
0130 enabled: poppler.isLocked
0131 text: i18n("UnLock")
0132 onTriggered: _passwordDialog.open()
0133 }
0134 }
0135
0136 function open(filePath)
0137 {
0138 poppler.path = filePath
0139 }
0140 }