mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-12 20:51:17 +00:00
go to exact bookmark point if possible
This commit is contained in:
parent
6de4500fd1
commit
6041b31e43
|
@ -22,4 +22,7 @@ import QtQuick 1.1
|
|||
|
||||
ThumbnailsBase {
|
||||
model: documentItem.bookmarkedPages
|
||||
onPageClicked: {
|
||||
pageArea.delegate.pageItem.goToBookmark(pageArea.delegate.pageItem.bookmarks[0])
|
||||
}
|
||||
}
|
|
@ -45,6 +45,7 @@ MouseEventListener {
|
|||
property bool pageSwitchEnabled: false
|
||||
property alias document: mainPage.document
|
||||
property alias pageNumber: mainPage.pageNumber
|
||||
property Item pageItem: mainPage
|
||||
|
||||
property string label: model["label"]
|
||||
|
||||
|
|
|
@ -25,9 +25,11 @@ import org.kde.plasma.extras 0.1 as PlasmaExtras
|
|||
import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
|
||||
|
||||
PlasmaComponents.Page {
|
||||
id: root
|
||||
property alias contentY: resultsGrid.contentY
|
||||
property alias contentHeight: resultsGrid.contentHeight
|
||||
property alias model: resultsGrid.model
|
||||
signal pageClicked(int pageNumber)
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
|
@ -88,6 +90,7 @@ PlasmaComponents.Page {
|
|||
documentItem.currentPage = modelData
|
||||
|
||||
resourceBrowser.open = false
|
||||
root.pageClicked(modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ PageItem::PageItem(QDeclarativeItem *parent)
|
|||
m_observerId = PAGEVIEW_ID;
|
||||
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
||||
|
||||
m_viewPort.rePos.enabled = true;
|
||||
|
||||
m_redrawTimer = new QTimer(this);
|
||||
m_redrawTimer->setInterval(REDRAW_TIMEOUT);
|
||||
m_redrawTimer->setSingleShot(true);
|
||||
|
@ -189,7 +191,7 @@ void PageItem::setBookmarked(bool bookmarked)
|
|||
}
|
||||
|
||||
if (bookmarked) {
|
||||
m_documentItem.data()->document()->bookmarkManager()->addBookmark(m_viewPort.pageNumber);
|
||||
m_documentItem.data()->document()->bookmarkManager()->addBookmark(m_viewPort);
|
||||
} else {
|
||||
m_documentItem.data()->document()->bookmarkManager()->removeBookmark(m_viewPort.pageNumber);
|
||||
}
|
||||
|
@ -239,6 +241,29 @@ void PageItem::setBookmarkAtPos(qreal x, qreal y)
|
|||
viewPort.rePos.normalizedY = y;
|
||||
|
||||
m_documentItem.data()->document()->bookmarkManager()->addBookmark(viewPort);
|
||||
|
||||
if (!m_bookmarked) {
|
||||
m_bookmarked = true;
|
||||
emit bookmarkedChanged();
|
||||
}
|
||||
|
||||
emit bookmarksChanged();
|
||||
}
|
||||
|
||||
void PageItem::removeBookmarkAtPos(qreal x, qreal y)
|
||||
{
|
||||
Okular::DocumentViewport viewPort(m_viewPort);
|
||||
viewPort.rePos.enabled = true;
|
||||
viewPort.rePos.normalizedX = x;
|
||||
viewPort.rePos.normalizedY = y;
|
||||
|
||||
m_documentItem.data()->document()->bookmarkManager()->addBookmark(viewPort);
|
||||
|
||||
if (m_bookmarked && m_documentItem.data()->document()->bookmarkManager()->bookmarks(m_viewPort.pageNumber).count() == 0) {
|
||||
m_bookmarked = false;
|
||||
emit bookmarkedChanged();
|
||||
}
|
||||
|
||||
emit bookmarksChanged();
|
||||
}
|
||||
|
||||
|
@ -344,7 +369,7 @@ void PageItem::contentXChanged()
|
|||
return;
|
||||
}
|
||||
|
||||
m_viewPort.rePos.normalizedX = m_flickable.data()->property("contentX").toReal();
|
||||
m_viewPort.rePos.normalizedX = m_flickable.data()->property("contentX").toReal() / (width() - m_flickable.data()->width());
|
||||
}
|
||||
|
||||
void PageItem::contentYChanged()
|
||||
|
@ -353,7 +378,7 @@ void PageItem::contentYChanged()
|
|||
return;
|
||||
}
|
||||
|
||||
m_viewPort.rePos.normalizedY = m_flickable.data()->property("contentY").toReal();
|
||||
m_viewPort.rePos.normalizedY = m_flickable.data()->property("contentY").toReal() / (height() - m_flickable.data()->height());
|
||||
}
|
||||
|
||||
void PageItem::setIsThumbnail(bool thumbnail)
|
||||
|
|
|
@ -124,6 +124,11 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void setBookmarkAtPos(qreal x, qreal y);
|
||||
|
||||
/**
|
||||
* Remove a bookmark ar a given position of the current page (if present)
|
||||
*/
|
||||
Q_INVOKABLE void removeBookmarkAtPos(qreal x, qreal y);
|
||||
|
||||
/**
|
||||
* Remove a bookmark at a given position, if any
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue