diff --git a/part.h b/part.h --- a/part.h +++ b/part.h @@ -237,6 +237,7 @@ void enableTOC(bool enable); void slotRebuildBookmarkMenu(); void enableLayers( bool enable ); + void slotShowSignatures(); public Q_SLOTS: bool saveFile() override; @@ -311,6 +312,7 @@ KMessageWidget * m_topMessage; KMessageWidget * m_formsMessage; KMessageWidget * m_infoMessage; + KMessageWidget * m_signatureMessage; QPointer m_thumbnailList; QPointer m_pageView; QPointer m_toc; @@ -376,6 +378,7 @@ KToggleAction* m_showMenuBarAction; KToggleAction* m_showLeftPanel; KToggleAction* m_showBottomBar; + KToggleAction* m_showSignaturePanel; KToggleFullScreenAction* m_showFullScreenAction; QAction *m_aboutBackend; QAction *m_reload; diff --git a/part.cpp b/part.cpp --- a/part.cpp +++ b/part.cpp @@ -1,4 +1,4 @@ -/*************************************************************************** +/*************************************************************************** * Copyright (C) 2002 by Wilco Greven * * Copyright (C) 2002 by Chris Cheney * * Copyright (C) 2002 by Malcolm Hunter * @@ -511,6 +511,11 @@ m_infoTimer = new QTimer(); m_infoTimer->setSingleShot( true ); connect( m_infoTimer, &QTimer::timeout, m_infoMessage, &KMessageWidget::animatedHide ); + m_signatureMessage = new KMessageWidget( rightContainer ); + m_signatureMessage->setVisible( false ); + m_signatureMessage->setWordWrap( true ); + m_signatureMessage->setMessageType( KMessageWidget::Information ); + rightLayout->addWidget( m_signatureMessage ); m_pageView = new PageView( rightContainer, m_document ); QMetaObject::invokeMethod( m_pageView, "setFocus", Qt::QueuedConnection ); //usability setting // m_splitter->setFocusProxy(m_pageView); @@ -759,6 +764,7 @@ m_showLeftPanel = nullptr; m_showBottomBar = nullptr; + m_showSignaturePanel = nullptr; m_showProperties = ac->addAction(QStringLiteral("properties")); m_showProperties->setText(i18n("&Properties")); @@ -856,6 +862,13 @@ m_showBottomBar->setChecked( Okular::Settings::showBottomBar() ); slotShowBottomBar(); + m_showSignaturePanel = ac->add(QStringLiteral("show_signatures")); + m_showSignaturePanel->setText(i18n("Show &Signatures")); + m_showSignaturePanel->setChecked( m_sidebar->isSidebarVisible() && m_sidebar->currentItem()->inherits("SignaturePanel") ); + connect( m_showSignaturePanel, &QAction::triggered, this, &Part::slotShowSignatures ); + connect( m_panel, &SignaturePanel::signaturePanelVisible, m_showSignaturePanel, &KToggleAction::setChecked ); + slotShowSignatures(); + m_showEmbeddedFiles = ac->addAction(QStringLiteral("embedded_files")); m_showEmbeddedFiles->setText(i18n("&Embedded Files")); m_showEmbeddedFiles->setIcon( QIcon::fromTheme( QStringLiteral("mail-attachment") ) ); @@ -1563,17 +1576,24 @@ m_formsMessage->setMessageType( KMessageWidget::Information ); m_formsMessage->setVisible( true ); } - else if ( ok && m_document->metaData( QStringLiteral("IsDigitallySigned") ).toBool() && m_embedMode == PrintPreviewMode ) - { - m_formsMessage->setText( i18n( "All editing and interactive features for this document are disabled. Please save a copy and reopen to edit this document." ) ); - m_formsMessage->setMessageType( KMessageWidget::Information ); - m_formsMessage->setVisible( true ); - } else { m_formsMessage->setVisible( false ); } + if ( ok && m_document->metaData( QStringLiteral("IsDigitallySigned") ).toBool() ) + { + if ( m_embedMode == PrintPreviewMode ) + { + m_signatureMessage->setText( i18n( "All editing and interactive features for this document are disabled. Please save a copy and reopen to edit this document." ) ); + } + else + { + m_signatureMessage->setText( i18n( "This document is digitally signed." ) ); + } + m_signatureMessage->setVisible( true ); + } + if ( m_showPresentation ) m_showPresentation->setEnabled( ok ); if ( ok ) { @@ -1854,6 +1874,7 @@ m_migrationMessage->setVisible( false ); m_topMessage->setVisible( false ); m_formsMessage->setVisible( false ); + m_signatureMessage->setVisible( false ); } #ifdef OKULAR_KEEP_FILE_OPEN m_keeper->close(); @@ -1912,6 +1933,23 @@ m_bottomBar->setVisible( showBottom ); } +void Part::slotShowSignatures() +{ + bool showSignaturePanel = m_showSignaturePanel->isChecked(); + bool signaturePanelVisible = m_panel->isVisible(); + if ( showSignaturePanel ) + { + if ( !m_sidebar->isSidebarVisible() ) + m_sidebar->setSidebarVisibility( true ); + if ( !signaturePanelVisible ) + m_sidebar->setCurrentItem( m_panel ); + } + else + { + m_sidebar->setCollapsed( signaturePanelVisible ); + } +} + void Part::slotFileDirty( const QString& path ) { // The beauty of this is that each start cancels the previous one. @@ -2044,7 +2082,7 @@ } else if ( !oneShot ) { - // start watching the file again (since we dropped it on close) + // start watching the file again (since we dropped it on close) setFileToWatch( localFilePath() ); m_dirtyHandler->start( 750 ); } @@ -3400,6 +3438,8 @@ // attach the actions of the children widgets too m_formsMessage->addAction( m_pageView->toggleFormsAction() ); + m_signatureMessage->addAction( m_showSignaturePanel ); + // ensure history actions are in the correct state updateViewActions(); } diff --git a/ui/signaturepanel.h b/ui/signaturepanel.h --- a/ui/signaturepanel.h +++ b/ui/signaturepanel.h @@ -35,9 +35,14 @@ // inherited from DocumentObserver void notifySetup( const QVector &pages, int setupFlags ) override; + // inherited from QWidget + bool event( QEvent *event ) override; void setPageView( PageView *pv ); + Q_SIGNALS: + void signaturePanelVisible( bool visible ); + private Q_SLOTS: void activated( const QModelIndex& ); void slotShowContextMenu(); diff --git a/ui/signaturepanel.cpp b/ui/signaturepanel.cpp --- a/ui/signaturepanel.cpp +++ b/ui/signaturepanel.cpp @@ -136,6 +136,14 @@ } } +bool SignaturePanel::event( QEvent *e ) +{ + if ( e->type() == QEvent::Show || e->type() == QEvent::Hide ) + emit signaturePanelVisible( isVisible() ); + + return QWidget::event( e ); +} + SignaturePanel::~SignaturePanel() { Q_D( SignaturePanel );