mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 10:25:36 +00:00
Change the action states according to whether a document is shown or not
This commit is contained in:
parent
627d29bca2
commit
f431e98bb8
|
@ -50,6 +50,12 @@ class OKULAR_EXPORT ViewerInterface
|
||||||
* reference in the currently displayed document.
|
* reference in the currently displayed document.
|
||||||
*/
|
*/
|
||||||
void openSourceReference(const QString& absFileName, int line, int column);
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
18
part.cpp
18
part.cpp
|
@ -488,11 +488,8 @@ m_cliPresentation(false), m_embedMode(detectEmbedMode(parentWidget, parent, args
|
||||||
// ensure history actions are in the correct state
|
// ensure history actions are in the correct state
|
||||||
updateViewActions();
|
updateViewActions();
|
||||||
|
|
||||||
if( m_embedMode == ViewerWidgetMode ) {
|
// also update the state of the actions in the page view
|
||||||
m_bottomBar->setVisible(false);
|
m_pageView->updateActionState( false, false, false );
|
||||||
Okular::Settings::setViewMode(Okular::Settings::EnumViewMode::Single);
|
|
||||||
Okular::Settings::setViewContinuous(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_embedMode == NativeShellMode )
|
if ( m_embedMode == NativeShellMode )
|
||||||
m_sidebar->setAutoFillBackground( false );
|
m_sidebar->setAutoFillBackground( false );
|
||||||
|
@ -1530,6 +1527,17 @@ void Part::updateViewActions()
|
||||||
if (m_copy) m_copy->setEnabled( false );
|
if (m_copy) m_copy->setEnabled( false );
|
||||||
if (m_selectAll) m_selectAll->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();
|
updateBookmarksActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
part.h
1
part.h
|
@ -128,6 +128,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
|
||||||
signals:
|
signals:
|
||||||
void enablePrintAction(bool enable);
|
void enablePrintAction(bool enable);
|
||||||
void openSourceReference(const QString& absFileName, int line, int column);
|
void openSourceReference(const QString& absFileName, int line, int column);
|
||||||
|
void viewerMenuStateChange(bool enabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// reimplemented from KParts::ReadOnlyPart
|
// reimplemented from KParts::ReadOnlyPart
|
||||||
|
|
|
@ -873,6 +873,16 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
|
||||||
QString(),
|
QString(),
|
||||||
PageViewMessage::Info, 4000 );
|
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 )
|
if ( d->aPageSizes )
|
||||||
{ // may be null if dummy mode is on
|
{ // may be null if dummy mode is on
|
||||||
bool pageSizes = d->document->supportsPageSizes();
|
bool pageSizes = d->document->supportsPageSizes();
|
||||||
|
@ -888,6 +898,36 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
|
||||||
d->aPageSizes->setItems( items );
|
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 )
|
if ( d->aRotateClockwise )
|
||||||
d->aRotateClockwise->setEnabled( haspages );
|
d->aRotateClockwise->setEnabled( haspages );
|
||||||
if ( d->aRotateCounterClockwise )
|
if ( d->aRotateCounterClockwise )
|
||||||
|
@ -919,10 +959,6 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
|
||||||
d->aSpeakDoc->setEnabled( enablettsactions );
|
d->aSpeakDoc->setEnabled( enablettsactions );
|
||||||
d->aSpeakPage->setEnabled( enablettsactions );
|
d->aSpeakPage->setEnabled( enablettsactions );
|
||||||
}
|
}
|
||||||
qDeleteAll( d->m_annowindows );
|
|
||||||
d->m_annowindows.clear();
|
|
||||||
|
|
||||||
selectionClear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageView::notifyViewportChanged( bool smoothMove )
|
void PageView::notifyViewportChanged( bool smoothMove )
|
||||||
|
@ -3240,6 +3276,8 @@ void PageView::updateZoomText()
|
||||||
else if ( d->zoomMode == ZoomFitText )
|
else if ( d->zoomMode == ZoomFitText )
|
||||||
selIdx = 2;
|
selIdx = 2;
|
||||||
d->aZoom->setCurrentItem( selIdx );
|
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 )
|
void PageView::updateCursor( const QPoint &p )
|
||||||
|
@ -3843,6 +3881,9 @@ void PageView::slotConfigureWebShortcuts()
|
||||||
|
|
||||||
void PageView::slotZoom()
|
void PageView::slotZoom()
|
||||||
{
|
{
|
||||||
|
if ( !d->aZoom->selectableActionGroup()->isEnabled() )
|
||||||
|
return;
|
||||||
|
|
||||||
setFocus();
|
setFocus();
|
||||||
updateZoom( ZoomFixed );
|
updateZoom( ZoomFixed );
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ Q_OBJECT
|
||||||
void setupBaseActions( KActionCollection * collection );
|
void setupBaseActions( KActionCollection * collection );
|
||||||
void setupViewerActions( KActionCollection * collection );
|
void setupViewerActions( KActionCollection * collection );
|
||||||
void setupActions( KActionCollection * collection );
|
void setupActions( KActionCollection * collection );
|
||||||
|
void updateActionState( bool docHasPages, bool docChanged, bool docHasFormWidgets );
|
||||||
|
|
||||||
// misc methods (from RMB menu/children)
|
// misc methods (from RMB menu/children)
|
||||||
bool canFitPageWidth() const;
|
bool canFitPageWidth() const;
|
||||||
|
|
Loading…
Reference in a new issue