Add buttons to collapse and expand all elements

Summary:
Adds two buttons on the bottom right to expand and collapse all elements in annotations
BUG: 377024
T8553

With latest breeze-icons:
{F6687517}

Without it:

{F6687519}

{F6687518}

Reviewers: #okular, #vdg, ngraham

Subscribers: ndavis, aacid, ngraham, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D18358
This commit is contained in:
Joao Netto 2019-04-01 00:03:36 +02:00 committed by Albert Astals Cid
parent fe0c8ad7c9
commit b669398404
2 changed files with 22 additions and 0 deletions

View file

@ -146,6 +146,16 @@ Reviews::Reviews( QWidget * parent, Okular::Document * document )
connect(curPageOnlyAction, &QAction::toggled, this, &Reviews::slotCurrentPageOnly);
curPageOnlyAction->setChecked( Okular::Settings::currentPageOnly() );
// Adds space between left actions, so that the next two buttons are aligned to the right
QWidget * spacer = new QWidget();
spacer->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
toolBar->addWidget( spacer );
QAction * expandAll = toolBar->addAction( QIcon::fromTheme( QStringLiteral("expand-all") ), i18n( "Expand all elements" ) );
connect(expandAll, &QAction::triggered, this, &Reviews::slotExpandAll);
QAction * collapseAll = toolBar->addAction( QIcon::fromTheme( QStringLiteral("collapse-all") ), i18n( "Collapse all elements" ) );
connect(collapseAll, &QAction::triggered, this, &Reviews::slotCollapseAll);
connect(m_view, &TreeView::activated, this, &Reviews::activated);
m_view->setContextMenuPolicy( Qt::CustomContextMenu );
@ -201,6 +211,16 @@ void Reviews::slotCurrentPageOnly( bool on )
m_view->expandAll();
}
void Reviews::slotExpandAll()
{
m_view->expandAll();
}
void Reviews::slotCollapseAll()
{
m_view->collapseAll();
}
//END GUI Slots

View file

@ -49,6 +49,8 @@ class Reviews : public QWidget, public Okular::DocumentObserver
void slotPageEnabled( bool );
void slotAuthorEnabled( bool );
void slotCurrentPageOnly( bool );
void slotExpandAll();
void slotCollapseAll();
Q_SIGNALS:
void openAnnotationWindow( Okular::Annotation *annotation, int pageNumber );