mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
correctly restore the last viewed page
This commit is contained in:
parent
ac88ed2832
commit
c8d078b1fd
|
@ -47,11 +47,13 @@ PlasmaComponents.Page {
|
|||
pageArea.oldDelegate.visible = true
|
||||
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber + 1
|
||||
resultsGrid.currentIndex = pageArea.oldDelegate.pageNumber
|
||||
documentItem.currentPage = pageArea.oldDelegate.pageNumber
|
||||
|
||||
pageArea.oldDelegate.visible = !(pageArea.delegate.pageNumber == documentItem.pageCount-1)
|
||||
} else if (pageArea.delegate.delta < 0) {
|
||||
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber - 1
|
||||
resultsGrid.currentIndex = pageArea.oldDelegate.pageNumber
|
||||
documentItem.currentPage = pageArea.oldDelegate.pageNumber
|
||||
|
||||
pageArea.oldDelegate.visible = pageArea.delegate.pageNumber != 0
|
||||
}
|
||||
|
@ -87,6 +89,7 @@ PlasmaComponents.Page {
|
|||
id: delegate1
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
pageNumber: documentItem.currentPage
|
||||
}
|
||||
SequentialAnimation {
|
||||
id: switchAnimation
|
||||
|
@ -142,6 +145,7 @@ PlasmaComponents.Page {
|
|||
model: documentItem.matchingPages
|
||||
cellWidth: theme.defaultFont.mSize.width * 14
|
||||
cellHeight: theme.defaultFont.mSize.height * 12
|
||||
currentIndex: documentItem.currentPage
|
||||
|
||||
delegate: Item {
|
||||
width: resultsGrid.cellWidth
|
||||
|
@ -181,6 +185,7 @@ PlasmaComponents.Page {
|
|||
onClicked: {
|
||||
resultsGrid.currentIndex = index
|
||||
pageArea.delegate.pageNumber = index
|
||||
documentItem.currentPage = index
|
||||
browserFrame.open = false
|
||||
|
||||
browserFrameSlideAnimation.to = resourceBrowser.width
|
||||
|
|
|
@ -41,7 +41,7 @@ DocumentItem::~DocumentItem()
|
|||
void DocumentItem::setPath(const QString &path)
|
||||
{
|
||||
//TODO: remote urls
|
||||
m_document->openDocument(path, KUrl(), KMimeType::findByUrl(KUrl(path)));
|
||||
m_document->openDocument(path, KUrl(path), KMimeType::findByUrl(KUrl(path)));
|
||||
|
||||
m_matchingPages.clear();
|
||||
for (uint i = 0; i < m_document->pages(); ++i) {
|
||||
|
@ -58,6 +58,17 @@ QString DocumentItem::path() const
|
|||
return m_document->currentDocument().prettyUrl();
|
||||
}
|
||||
|
||||
void DocumentItem::setCurrentPage(int page)
|
||||
{
|
||||
m_document->setViewportPage(page);
|
||||
emit currentPageChanged();
|
||||
}
|
||||
|
||||
int DocumentItem::currentPage() const
|
||||
{
|
||||
return m_document->currentPage();
|
||||
}
|
||||
|
||||
bool DocumentItem::isOpened() const
|
||||
{
|
||||
return m_document->isOpened();
|
||||
|
|
|
@ -38,6 +38,7 @@ class DocumentItem : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
||||
Q_PROPERTY(int currentPage READ currentPage WRITE setCurrentPage NOTIFY currentPageChanged)
|
||||
Q_PROPERTY(bool opened READ isOpened NOTIFY openedChanged)
|
||||
Q_PROPERTY(int pageCount READ pageCount NOTIFY pageCountChanged)
|
||||
Q_PROPERTY(bool searchInProgress READ isSearchInProgress NOTIFY searchInProgressChanged)
|
||||
|
@ -51,6 +52,9 @@ public:
|
|||
void setPath(const QString &path);
|
||||
QString path() const;
|
||||
|
||||
void setCurrentPage(int page);
|
||||
int currentPage() const;
|
||||
|
||||
bool isOpened() const;
|
||||
|
||||
int pageCount() const;
|
||||
|
@ -73,6 +77,7 @@ Q_SIGNALS:
|
|||
void openedChanged();
|
||||
void searchInProgressChanged();
|
||||
void matchingPagesChanged();
|
||||
void currentPageChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void searchFinished(int id, Okular::Document::SearchStatus endStatus);
|
||||
|
|
Loading…
Reference in a new issue