diff --git a/mobile/app/app.qrc b/mobile/app/app.qrc
index 66b5a495e..d2bf294f2 100644
--- a/mobile/app/app.qrc
+++ b/mobile/app/app.qrc
@@ -1,13 +1,12 @@
package/contents/ui/Bookmarks.qml
-package/contents/ui/Documents.qml
package/contents/ui/main.qml
package/contents/ui/MainView.qml
package/contents/ui/OkularDrawer.qml
package/contents/ui/TableOfContents.qml
package/contents/ui/Thumbnails.qml
package/contents/ui/ThumbnailsBase.qml
package/contents/ui/TreeDelegate.qml
diff --git a/mobile/app/package/contents/ui/Documents.qml b/mobile/app/package/contents/ui/Documents.qml
deleted file mode 100644
index 93af15fbc..000000000
--- a/mobile/app/package/contents/ui/Documents.qml
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2015 Marco Martin
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2,
- * or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-import QtQuick 2.1
-import QtQuick.Dialogs 1.3
-import QtQuick.Controls 1.3
-import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0 as QQC2
-import org.kde.kirigami 2.0 as Kirigami
-import org.kde.okular 2.0 as Okular
-import Qt.labs.folderlistmodel 2.1
-import Qt.labs.platform 1.0
-
-Item {
- id: root
- anchors.fill: parent
-
- property Item view: filesView
- property alias contentY: filesView.contentY
- property alias contentHeight: filesView.contentHeight
- property alias model: filesView.model
-
- Item {
- id: toolBarContent
- width: root.width
- height: searchField.height + Kirigami.Units.gridUnit
- QQC2.TextField {
- id: searchField
- anchors.centerIn: parent
- focus: true
- }
- }
-
- ColumnLayout {
- z: 2
- visible: filesView.count == 0
- anchors {
- fill: parent
- margins: Kirigami.Units.gridUnit
- }
- Kirigami.Label {
- text: i18n("No Documents found. To start to read, put some files in the Documents folder of your device.")
- wrapMode: Text.WordWrap
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
-
- ScrollView {
- anchors {
- top: toolBarContent.bottom
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- }
- ListView {
- id: filesView
- anchors.fill: parent
-
- header: Kirigami.Label {
- Layout.fillWidth: true
- text: folderModel.folder
- }
-
- model: FolderListModel {
- id: folderModel
- folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
- nameFilters: Okular.Okular.nameFilters
- showDotAndDotDot: true
- showDirs: false
- }
-
- delegate: Kirigami.BasicListItem {
- label: model.fileName
- visible: model.fileName.indexOf(searchField.text) !== -1
- height: visible ? implicitHeight : 0
- onClicked: {
- if (fileIsDir) {
- ListView.view.model.folder = fileURL
- return;
- }
-
- documentItem.url = model.fileURL;
- globalDrawer.close();
- applicationWindow().controlsVisible = false;
- }
- }
- }
- }
-}
diff --git a/mobile/app/package/contents/ui/Thumbnails.qml b/mobile/app/package/contents/ui/Thumbnails.qml
index 58cd91134..5f33334ca 100644
--- a/mobile/app/package/contents/ui/Thumbnails.qml
+++ b/mobile/app/package/contents/ui/Thumbnails.qml
@@ -1,53 +1,53 @@
/*
* Copyright 2012 Marco Martin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Controls 2.0
import org.kde.kirigami 2.0 as Kirigami
ThumbnailsBase {
id: root
model: documentItem.matchingPages
ToolBar {
id: toolBarContent
width: root.width
height: searchField.height
TextField {
id: searchField
- enabled: documentItem ? documentItem.supportsSearch : false
+ enabled: documentItem ? documentItem.supportsSearching : false
anchors.centerIn: parent
onTextChanged: {
if (text.length > 2) {
documentItem.searchText(text);
} else {
documentItem.resetSearch();
}
}
}
Kirigami.Label {
anchors {
left: searchField.right
verticalCenter: searchField.verticalCenter
}
visible: documentItem.matchingPages.length == 0
text: i18n("No results found.")
}
}
}
diff --git a/mobile/app/package/contents/ui/main.qml b/mobile/app/package/contents/ui/main.qml
index 66bea0fdb..443a192be 100644
--- a/mobile/app/package/contents/ui/main.qml
+++ b/mobile/app/package/contents/ui/main.qml
@@ -1,72 +1,81 @@
/*
* Copyright 2012 Marco Martin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
-import QtQuick.Controls 1.3
+import QtQuick.Dialogs 1.3 as QQD
import org.kde.okular 2.0 as Okular
import org.kde.kirigami 2.0 as Kirigami
Kirigami.AbstractApplicationWindow {
id: fileBrowserRoot
visible: true
- /*TODO: port ResourceInstance
- PlasmaExtras.ResourceInstance {
- id: resourceInstance
- uri: documentItem.path
- }*/
-
header: null
- globalDrawer: Kirigami.OverlayDrawer {
- edge: Qt.LeftEdge
- contentItem: Documents {
- implicitWidth: Kirigami.Units.gridUnit * 20
+ globalDrawer: Kirigami.GlobalDrawer {
+ title: i18n("Okular")
+ titleIcon: "okular"
+
+ QQD.FileDialog {
+ id: fileDialog
+ nameFilters: Okular.Okular.nameFilters
+ folder: "file://" + userPaths.documents
+ onAccepted: {
+ documentItem.url = fileDialog.fileUrl
+ }
}
+
+ actions: [
+ Kirigami.Action {
+ text: i18n("Open...")
+ icon.name: "document-open"
+ onTriggered: {
+ fileDialog.open()
+ }
+ }
+ ]
}
- contextDrawer: OkularDrawer {
- drawerOpen: false
- }
+ contextDrawer: OkularDrawer {}
title: documentItem.windowTitleForDocument
Okular.DocumentItem {
id: documentItem
onUrlChanged: { currentPage = 0 }
onWindowTitleForDocumentChanged: {
}
}
MainView {
id: pageArea
anchors.fill: parent
document: documentItem
}
//FIXME: this is due to global vars being binded after the parse is done, do the 2 steps parsing
Timer {
interval: 100
running: true
onTriggered: {
if (uri) {
documentItem.url = uri
} else {
globalDrawer.open();
}
}
}
}
diff --git a/mobile/components/documentitem.cpp b/mobile/components/documentitem.cpp
index 5a74f089b..e674d0015 100644
--- a/mobile/components/documentitem.cpp
+++ b/mobile/components/documentitem.cpp
@@ -1,268 +1,269 @@
/*
* Copyright 2012 by Marco Martin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "documentitem.h"
#include
#include
#include
#include
#include
#include "ui/tocmodel.h"
DocumentItem::DocumentItem(QObject *parent)
: QObject(parent),
m_thumbnailObserver(nullptr),
m_pageviewObserver(nullptr),
m_searchInProgress(false)
{
qmlRegisterUncreatableType("org.kde.okular", 1, 0, "TOCModel", QStringLiteral("Do not create objects of this type."));
Okular::Settings::instance(QStringLiteral("okularproviderrc"));
m_document = new Okular::Document(nullptr);
m_tocModel = new TOCModel(m_document, this);
connect(m_document, &Okular::Document::searchFinished,
this, &DocumentItem::searchFinished);
connect(m_document->bookmarkManager(), &Okular::BookmarkManager::bookmarksChanged,
this, &DocumentItem::bookmarkedPagesChanged);
connect(m_document->bookmarkManager(), &Okular::BookmarkManager::bookmarksChanged,
this, &DocumentItem::bookmarksChanged);
}
DocumentItem::~DocumentItem()
{
delete m_document;
}
void DocumentItem::setUrl(const QUrl & url)
{
+ m_document->closeDocument();
//TODO: password
QMimeDatabase db;
const QString path = url.isLocalFile() ? url.toLocalFile() : QLatin1String("-");
m_document->openDocument(path, url, db.mimeTypeForUrl(url));
m_tocModel->clear();
m_tocModel->fill(m_document->documentSynopsis());
m_tocModel->setCurrentViewport(m_document->viewport());
m_matchingPages.clear();
for (uint i = 0; i < m_document->pages(); ++i) {
m_matchingPages << (int)i;
}
emit matchingPagesChanged();
emit urlChanged();
emit pageCountChanged();
emit openedChanged();
emit supportsSearchingChanged();
emit windowTitleForDocumentChanged();
emit bookmarkedPagesChanged();
}
QString DocumentItem::windowTitleForDocument() const
{
// If 'DocumentTitle' should be used, check if the document has one. If
// either case is false, use the file name.
QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ?
m_document->currentDocument().toDisplayString(QUrl::PreferLocalFile) : m_document->currentDocument().fileName();
if (Okular::Settings::displayDocumentTitle()) {
const QString docTitle = m_document->metaData( QStringLiteral("DocumentTitle") ).toString();
if (!docTitle.isEmpty() && !docTitle.trimmed().isEmpty()) {
title = docTitle;
}
}
return title;
}
QUrl DocumentItem::url() const
{
return m_document->currentDocument();
}
void DocumentItem::setCurrentPage(int page)
{
m_document->setViewportPage(page);
m_tocModel->setCurrentViewport(m_document->viewport());
emit currentPageChanged();
}
int DocumentItem::currentPage() const
{
return m_document->currentPage();
}
bool DocumentItem::isOpened() const
{
return m_document->isOpened();
}
int DocumentItem::pageCount() const
{
return m_document->pages();
}
QVariantList DocumentItem::matchingPages() const
{
return m_matchingPages;
}
TOCModel *DocumentItem::tableOfContents() const
{
return m_tocModel;
}
QVariantList DocumentItem::bookmarkedPages() const
{
QList list;
QSet pages;
foreach (const KBookmark &bookmark, m_document->bookmarkManager()->bookmarks()) {
Okular::DocumentViewport viewport(bookmark.url().fragment());
pages << viewport.pageNumber;
}
list = pages.toList();
qSort(list);
QVariantList variantList;
foreach (const int page, list) {
variantList << page;
}
return variantList;
}
QStringList DocumentItem::bookmarks() const
{
QStringList list;
foreach(const KBookmark &bookmark, m_document->bookmarkManager()->bookmarks()) {
list << bookmark.url().toString();
}
return list;
}
bool DocumentItem::supportsSearching() const
{
return m_document->supportsSearching();
}
bool DocumentItem::isSearchInProgress() const
{
return m_searchInProgress;
}
void DocumentItem::searchText(const QString &text)
{
if (text.isEmpty()) {
resetSearch();
return;
}
m_document->cancelSearch();
m_document->resetSearch(PAGEVIEW_SEARCH_ID);
m_document->searchText(PAGEVIEW_SEARCH_ID, text, 1, Qt::CaseInsensitive,
Okular::Document::AllDocument, true, QColor(100,100,200,40));
if (!m_searchInProgress) {
m_searchInProgress = true;
emit searchInProgressChanged();
}
}
void DocumentItem::resetSearch()
{
m_document->resetSearch(PAGEVIEW_SEARCH_ID);
m_matchingPages.clear();
for (uint i = 0; i < m_document->pages(); ++i) {
m_matchingPages << (int)i;
}
if (m_searchInProgress) {
m_searchInProgress = false;
emit searchInProgressChanged();
}
emit matchingPagesChanged();
}
Okular::Document *DocumentItem::document()
{
return m_document;
}
Observer *DocumentItem::thumbnailObserver()
{
if (!m_thumbnailObserver)
m_thumbnailObserver = new Observer(this);
return m_thumbnailObserver;
}
Observer *DocumentItem::pageviewObserver()
{
if (!m_pageviewObserver) {
m_pageviewObserver = new Observer(this);
}
return m_pageviewObserver;
}
void DocumentItem::searchFinished(int id, Okular::Document::SearchStatus endStatus)
{
Q_UNUSED(endStatus)
if (id != PAGEVIEW_SEARCH_ID) {
return;
}
m_matchingPages.clear();
for (uint i = 0; i < m_document->pages(); ++i) {
if (m_document->page(i)->hasHighlights(id)) {
m_matchingPages << (int)i;
}
}
if (m_searchInProgress) {
m_searchInProgress = false;
emit searchInProgressChanged();
}
emit matchingPagesChanged();
}
//Observer
Observer::Observer(DocumentItem *parent)
: QObject(parent),
m_document(parent)
{
parent->document()->addObserver(this);
}
Observer::~Observer()
{
}
void Observer::notifyPageChanged(int page, int flags)
{
emit pageChanged(page, flags);
}