Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit f431e98b authored by Michel Ludwig's avatar Michel Ludwig

Change the action states according to whether a document is shown or not

parent 627d29bc
......@@ -50,6 +50,12 @@ class OKULAR_EXPORT ViewerInterface
* reference in the currently displayed document.
*/
void openSourceReference(const QString& absFileName, int line, int column);
/**
* The signal 'viewerMenuStateChange' is emitted whenever the state of the menu
* 'menu_okular_part_viewer' defined in 'part-viewermode.rc' has changed.
*/
void viewerMenuStateChange(bool enabled);
};
}
......
......@@ -488,11 +488,8 @@ m_cliPresentation(false), m_embedMode(detectEmbedMode(parentWidget, parent, args
// ensure history actions are in the correct state
updateViewActions();
if( m_embedMode == ViewerWidgetMode ) {
m_bottomBar->setVisible(false);
Okular::Settings::setViewMode(Okular::Settings::EnumViewMode::Single);
Okular::Settings::setViewContinuous(true);
}
// also update the state of the actions in the page view
m_pageView->updateActionState( false, false, false );
if ( m_embedMode == NativeShellMode )
m_sidebar->setAutoFillBackground( false );
......@@ -1530,6 +1527,17 @@ void Part::updateViewActions()
if (m_copy) m_copy->setEnabled( false );
if (m_selectAll) m_selectAll->setEnabled( false );
}
if ( factory() )
{
QWidget *menu = factory()->container("menu_okular_part_viewer", this);
if( menu )
{
menu->setEnabled( opened );
}
}
emit(viewerMenuStateChange( opened ));
updateBookmarksActions();
}
......
......@@ -128,6 +128,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
signals:
void enablePrintAction(bool enable);
void openSourceReference(const QString& absFileName, int line, int column);
void viewerMenuStateChange(bool enabled);
protected:
// reimplemented from KParts::ReadOnlyPart
......
......@@ -873,6 +873,16 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
QString(),
PageViewMessage::Info, 4000 );
updateActionState( haspages, documentChanged, hasformwidgets );
qDeleteAll( d->m_annowindows );
d->m_annowindows.clear();
selectionClear();
}
void PageView::updateActionState( bool haspages, bool documentChanged, bool hasformwidgets )
{
if ( d->aPageSizes )
{ // may be null if dummy mode is on
bool pageSizes = d->document->supportsPageSizes();
......@@ -888,6 +898,36 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
d->aPageSizes->setItems( items );
}
}
if ( d->aTrimMargins )
d->aTrimMargins->setEnabled( haspages );
if ( d->aViewMode )
d->aViewMode->setEnabled( haspages );
if ( d->aViewContinuous )
d->aViewContinuous->setEnabled( haspages );
if ( d->aZoomFitWidth )
d->aZoomFitWidth->setEnabled( haspages );
if ( d->aZoomFitPage )
d->aZoomFitPage->setEnabled( haspages );
if ( d->aZoomFitText )
d->aZoomFitText->setEnabled( haspages );
if ( d->aZoom )
{
d->aZoom->selectableActionGroup()->setEnabled( haspages );
d->aZoom->setEnabled( haspages );
}
if ( d->aZoomIn )
d->aZoomIn->setEnabled( haspages );
if ( d->aZoomOut )
d->aZoomOut->setEnabled( haspages );
if ( d->mouseModeActionGroup )
d->mouseModeActionGroup->setEnabled( haspages );
if ( d->aRotateClockwise )
d->aRotateClockwise->setEnabled( haspages );
if ( d->aRotateCounterClockwise )
......@@ -919,10 +959,6 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
d->aSpeakDoc->setEnabled( enablettsactions );
d->aSpeakPage->setEnabled( enablettsactions );
}
qDeleteAll( d->m_annowindows );
d->m_annowindows.clear();
selectionClear();
}
void PageView::notifyViewportChanged( bool smoothMove )
......@@ -3240,6 +3276,8 @@ void PageView::updateZoomText()
else if ( d->zoomMode == ZoomFitText )
selIdx = 2;
d->aZoom->setCurrentItem( selIdx );
d->aZoom->setEnabled(d->items.size() > 0);
d->aZoom->selectableActionGroup()->setEnabled( d->items.size() > 0 );
}
void PageView::updateCursor( const QPoint &p )
......@@ -3843,6 +3881,9 @@ void PageView::slotConfigureWebShortcuts()
void PageView::slotZoom()
{
if ( !d->aZoom->selectableActionGroup()->isEnabled() )
return;
setFocus();
updateZoom( ZoomFixed );
}
......
......@@ -64,6 +64,7 @@ Q_OBJECT
void setupBaseActions( KActionCollection * collection );
void setupViewerActions( KActionCollection * collection );
void setupActions( KActionCollection * collection );
void updateActionState( bool docHasPages, bool docChanged, bool docHasFormWidgets );
// misc methods (from RMB menu/children)
bool canFitPageWidth() const;
......
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