Merge remote-tracking branch 'origin/Applications/17.04'

This commit is contained in:
Albert Astals Cid 2017-03-23 01:24:47 +01:00
commit 8b1c423d1a
4 changed files with 32 additions and 2 deletions

View file

@ -398,6 +398,7 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW
// [left toolbox: Table of Contents] | []
m_toc = new TOC( 0, m_document );
connect( m_toc.data(), &TOC::hasTOC, this, &Part::enableTOC );
connect( m_toc.data(), &TOC::rightClick, this, &Part::slotShowTOCMenu );
m_sidebar->addItem( m_toc, QIcon::fromTheme(QApplication::isLeftToRight() ? QStringLiteral("format-justify-left") : QStringLiteral("format-justify-right")), i18n("Contents") );
enableTOC( false );
@ -2479,8 +2480,17 @@ void Part::slotPrintPreview()
}
}
void Part::slotShowTOCMenu(const Okular::DocumentViewport &vp, const QPoint &point, const QString &title)
{
showMenu(m_document->page(vp.pageNumber), point, title, vp);
}
void Part::slotShowMenu(const Okular::Page *page, const QPoint &point)
{
showMenu(page, point);
}
void Part::showMenu(const Okular::Page *page, const QPoint &point, const QString &bookmarkTitle, const Okular::DocumentViewport &vp)
{
if ( m_embedMode == PrintPreviewMode )
return;
@ -2548,8 +2558,10 @@ void Part::slotShowMenu(const Okular::Page *page, const QPoint &point)
{
if (res == addBookmark)
{
if (currentPage)
if ( currentPage && bookmarkTitle.isEmpty() )
m_document->bookmarkManager()->addBookmark( m_document->viewport() );
else if ( !bookmarkTitle.isEmpty() )
m_document->bookmarkManager()->addBookmark( m_document->currentDocument(), vp, bookmarkTitle );
else
m_document->bookmarkManager()->addBookmark( page->number() );
}
@ -2569,7 +2581,6 @@ void Part::slotShowMenu(const Okular::Page *page, const QPoint &point)
delete popup;
}
void Part::slotShowProperties()
{
PropertiesDialog *d = new PropertiesDialog(widget(), m_document);

2
part.h
View file

@ -199,6 +199,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
void slotGetNewStuff();
void slotNewConfig();
void slotShowMenu(const Okular::Page *page, const QPoint &point);
void slotShowTOCMenu(const Okular::DocumentViewport &vp, const QPoint &point, const QString title);
void slotShowProperties();
void slotShowEmbeddedFiles();
void slotShowLeftPanel();
@ -240,6 +241,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
private:
bool aboutToShowContextMenu(QMenu *menu, QAction *action, QMenu *contextMenu);
void showMenu(const Okular::Page *page, const QPoint &point, const QString &bookmarkTitle = QString(), const Okular::DocumentViewport &vp = DocumentViewport());
bool eventFilter(QObject * watched, QEvent * event) override;
Document::OpenResult doOpenFile(const QMimeType &mime, const QString &fileNameToOpen, bool *isCompressedFile);

View file

@ -14,6 +14,7 @@
#include <qheaderview.h>
#include <qlayout.h>
#include <qtreeview.h>
#include <QContextMenuEvent>
#include <klineedit.h>
@ -175,4 +176,15 @@ void TOC::saveSearchOptions()
Okular::Settings::self()->save();
}
void TOC::contextMenuEvent(QContextMenuEvent* e)
{
QModelIndex index = m_treeView->currentIndex();
if (!index.isValid())
return;
Okular::DocumentViewport viewport = m_model->viewportForIndex(index);
emit rightClick(viewport, e->globalPos(), m_model->data(index).toString());
}
#include "moc_toc.cpp"

View file

@ -12,6 +12,7 @@
#include <qwidget.h>
#include "core/observer.h"
#include "core/document.h"
#include <QModelIndex>
#include "okularpart_export.h"
@ -48,11 +49,15 @@ Q_OBJECT
Q_SIGNALS:
void hasTOC(bool has);
void rightClick( const Okular::DocumentViewport &, const QPoint &, const QString & );
private Q_SLOTS:
void slotExecuted( const QModelIndex & );
void saveSearchOptions();
protected:
void contextMenuEvent( QContextMenuEvent * e ) override;
private:
QVector<QModelIndex> expandedNodes( const QModelIndex & parent=QModelIndex() ) const;