Commit 8eca2793 authored by Pino Toscano's avatar Pino Toscano

Add an Add/Remove Bookmark to add/remove a bookmark for the current page.

svn path=/trunk/KDE/kdegraphics/okular/; revision=660097
parent f8662cfa
......@@ -295,10 +295,12 @@ m_searchStarted(false), m_cliPresentation(false)
ac->addAction("history_forward",m_historyNext);
m_historyNext->setWhatsThis( i18n( "Go to the place you were after" ) );
m_addBookmark = KStandardAction::addBookmark( this, SLOT( slotAddBookmark() ), ac );
m_addBookmarkText = m_addBookmark->text();
m_prevBookmark = ac->addAction("previous_bookmark");
m_prevBookmark->setText(i18n( "Previous Bookmark" ));
m_prevBookmark->setIcon(KIcon( "find-previous" ));
m_prevBookmark->setWhatsThis( i18n( "Go to the previous bookmarked page" ) );
connect( m_prevBookmark, SIGNAL( triggered() ), this, SLOT( slotPreviousBookmark() ) );
......@@ -558,12 +560,14 @@ void Part::notifyViewportChanged( bool /*smoothMove*/ )
}
}
void Part::notifyPageChanged( int /*page*/, int flags )
void Part::notifyPageChanged( int page, int flags )
{
if ( !(flags & Okular::DocumentObserver::Bookmark ) )
return;
rebuildBookmarkMenu();
if ( page == m_document->viewport().pageNumber )
updateBookmarksActions();
}
......@@ -939,6 +943,30 @@ void Part::updateViewActions()
m_historyBack->setEnabled( false );
m_historyNext->setEnabled( false );
}
updateBookmarksActions();
}
void Part::updateBookmarksActions()
{
bool opened = m_document->pages() > 0;
if ( opened )
{
m_addBookmark->setEnabled( true );
if ( m_document->isBookmarked( m_document->currentPage() ) )
{
m_addBookmark->setText( i18n( "Remove Bookmark" ) );
}
else
{
m_addBookmark->setText( m_addBookmarkText );
}
}
else
{
m_addBookmark->setEnabled( false );
m_addBookmark->setText( m_addBookmarkText );
}
}
......@@ -1048,6 +1076,20 @@ void Part::slotHistoryNext()
}
void Part::slotAddBookmark()
{
uint current = m_document->currentPage();
if ( m_document->isBookmarked( current ) )
{
m_document->removeBookmark( current );
}
else
{
m_document->addBookmark( current );
}
}
void Part::slotPreviousBookmark()
{
uint current = m_document->currentPage();
......
......@@ -123,6 +123,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
void slotGoToPage();
void slotHistoryBack();
void slotHistoryNext();
void slotAddBookmark();
void slotPreviousBookmark();
void slotNextBookmark();
void slotFindNext();
......@@ -148,6 +149,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
void saveSplitterSize();
// can be connected to widget elements
void updateViewActions();
void updateBookmarksActions();
void enableTOC(bool enable);
public slots:
......@@ -207,6 +209,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
QAction *m_lastPage;
QAction *m_historyBack;
QAction *m_historyNext;
QAction *m_addBookmark;
QAction *m_prevBookmark;
QAction *m_nextBookmark;
QAction *m_copy;
......@@ -232,6 +235,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
QList<Okular::ExportFormat> m_exportFormats;
QList<QAction*> m_bookmarkActions;
bool m_cliPresentation;
QString m_addBookmarkText;
private slots:
void slotGeneratorPreferences();
......
......@@ -51,6 +51,7 @@
<Action name="goto_page"/>
</Menu>
<Menu name="okular_bookmarks"><text>&amp;Bookmarks</text>
<Action name="bookmark_add"/>
<Action name="previous_bookmark"/>
<Action name="next_bookmark" />
<Separator/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment