Commit 5d10ae58 authored by Pino Toscano's avatar Pino Toscano

Pass the action collection directly in the ctor of the presentation widget, so...

Pass the action collection directly in the ctor of the presentation widget, so we can use its actions there too.

As result, move the creation of the drawing actions in the main kpart and just plug them, so their shortcut can be configured.
BUG: 175545

svn path=/trunk/KDE/kdegraphics/okular/; revision=890504
parent 1d91c234
......@@ -539,6 +539,14 @@ m_cliPresentation(false), m_generatorGuiClient(0), m_keeper( 0 )
blackscreenAction->setShortcut( QKeySequence( Qt::Key_B ) );
blackscreenAction->setIcon( KIcon( "view-presentation" ) );
KToggleAction *drawingAction = new KToggleAction( i18n( "Toggle Drawing Mode" ), ac );
ac->addAction( "presentation_drawing_mode", drawingAction );
drawingAction->setIcon( KIcon( "draw-freehand" ) );
KAction *eraseDrawingAction = new KAction( i18n( "Erase Drawings" ), ac );
ac->addAction( "presentation_erase_drawings", eraseDrawingAction );
eraseDrawingAction->setIcon( KIcon( "draw-eraser" ) );
// document watcher and reloader
m_watcher = new KDirWatch( this );
connect( m_watcher, SIGNAL( dirty( const QString& ) ), this, SLOT( slotFileDirty( const QString& ) ) );
......@@ -1691,8 +1699,7 @@ void Part::slotShowPresentation()
{
if ( !m_presentationWidget )
{
m_presentationWidget = new PresentationWidget( widget(), m_document );
m_presentationWidget->setupActions( actionCollection() );
m_presentationWidget = new PresentationWidget( widget(), m_document, actionCollection() );
}
}
......@@ -1709,7 +1716,7 @@ void Part::slotTogglePresentation()
if ( m_document->isOpened() )
{
if ( !m_presentationWidget )
m_presentationWidget = new PresentationWidget( widget(), m_document );
m_presentationWidget = new PresentationWidget( widget(), m_document, actionCollection() );
else delete (PresentationWidget*) m_presentationWidget;
}
}
......
......@@ -124,7 +124,7 @@ class PresentationToolBar : public QToolBar
};
PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc )
PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc, KActionCollection * collection )
: QWidget( 0 /* must be null, to have an independent widget */, Qt::FramelessWindowHint ),
m_pressedLink( 0 ), m_handCursor( false ), m_drawingEngine( 0 ), m_screenSaverCookie( -1 ),
m_document( doc ), m_frameIndex( -1 ), m_topBar( 0 ), m_pagesEdit( 0 ), m_searchBar( 0 ),
......@@ -165,11 +165,14 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
connect( m_pagesEdit, SIGNAL( returnPressed() ), this, SLOT( slotPageChanged() ) );
m_topBar->addAction( KIcon( layoutDirection() == Qt::RightToLeft ? "go-previous" : "go-next" ), i18n( "Next Page" ), this, SLOT( slotNextPage() ) );
m_topBar->addSeparator();
QAction * drawingAct = m_topBar->addAction( KIcon( "draw-freehand" ), i18n( "Toggle Drawing Mode" ) );
drawingAct->setCheckable( true );
connect( drawingAct, SIGNAL( toggled( bool ) ), this, SLOT( togglePencilMode( bool ) ) );
QAction * eraseDrawingAct = m_topBar->addAction( KIcon( "draw-eraser" ), i18n( "Erase Drawings" ) );
connect( eraseDrawingAct, SIGNAL( triggered() ), this, SLOT( clearDrawings() ) );
QAction *drawingAct = collection->action( "presentation_drawing_mode" );
connect( drawingAct, SIGNAL( toggled( bool ) ), SLOT( togglePencilMode( bool ) ) );
m_topBar->addAction( drawingAct );
addAction( drawingAct );
QAction *eraseDrawingAct = collection->action( "presentation_erase_drawings" );
connect( eraseDrawingAct, SIGNAL( triggered() ), SLOT( clearDrawings() ) );
m_topBar->addAction( eraseDrawingAct );
addAction( eraseDrawingAct );
QDesktopWidget *desktop = QApplication::desktop();
if ( desktop->numScreens() > 1 )
{
......@@ -221,6 +224,8 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
setCursor( QCursor( Qt::BlankCursor ) );
}
setupActions( collection );
// inhibit the screen saver
inhibitScreenSaver();
......
......@@ -42,7 +42,7 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
{
Q_OBJECT
public:
PresentationWidget( QWidget * parent, Okular::Document * doc );
PresentationWidget( QWidget * parent, Okular::Document * doc, KActionCollection * collection );
~PresentationWidget();
// inherited from DocumentObserver
......@@ -52,9 +52,6 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
void notifyPageChanged( int pageNumber, int changedFlags );
bool canUnloadPixmap( int pageNumber ) const;
// create actions that interact with this widget
void setupActions( KActionCollection * collection );
public slots:
void slotFind();
......@@ -88,6 +85,8 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
void setScreen( int );
void inhibitScreenSaver();
void allowScreenSaver();
// create actions that interact with this widget
void setupActions( KActionCollection * collection );
// cache stuff
int m_width;
......
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