diff --git a/part.cpp b/part.cpp index 8606bc156..6da299ecf 100644 --- a/part.cpp +++ b/part.cpp @@ -94,7 +94,7 @@ static QAction* actionForExportFormat( const Okular::ExportFormat& format, QObje Part::Part(QWidget *parentWidget, QObject *parent, -const QStringList & /*args*/ ) +const QStringList &args ) : KParts::ReadOnlyPart(parent), m_showMenuBarAction(0), m_showFullScreenAction(0), m_actionsSearched(false), m_searchStarted(false), m_cliPresentation(false) @@ -292,13 +292,9 @@ m_searchStarted(false), m_cliPresentation(false) ac->addAction("last_page",m_lastPage); m_lastPage->setWhatsThis( i18n( "Moves to the last page of the document" ) ); - m_historyBack = KStandardAction::back( this, SLOT( slotHistoryBack() ), ac ); - ac->addAction("history_back",m_historyBack); - m_historyBack->setWhatsThis( i18n( "Go to the place you were before" ) ); - - m_historyNext = KStandardAction::forward( this, SLOT( slotHistoryNext() ), ac); - ac->addAction("history_forward",m_historyNext); - m_historyNext->setWhatsThis( i18n( "Go to the place you were after" ) ); + // we do not want back and next in history in the dummy mode + m_historyBack = 0; + m_historyNext = 0; m_addBookmark = KStandardAction::addBookmark( this, SLOT( slotAddBookmark() ), ac ); m_addBookmarkText = m_addBookmark->text(); @@ -445,10 +441,9 @@ m_searchStarted(false), m_cliPresentation(false) // updateViewActions(); - // By default we start with a clean UI so that for example print preview - // does not get all the stuff embedded m_dummyMode = true; m_leftPanel->hide(); + if (!args.contains("Print/Preview")) unsetDummyMode(); } @@ -960,8 +955,8 @@ void Part::updateViewActions() m_prevPage->setEnabled( !atBegin ); m_lastPage->setEnabled( !atEnd ); m_nextPage->setEnabled( !atEnd ); - m_historyBack->setEnabled( !m_document->historyAtBegin() ); - m_historyNext->setEnabled( !m_document->historyAtEnd() ); + if (m_historyBack) m_historyBack->setEnabled( !m_document->historyAtBegin() ); + if (m_historyNext) m_historyNext->setEnabled( !m_document->historyAtEnd() ); m_reload->setEnabled( true ); } else @@ -971,8 +966,8 @@ void Part::updateViewActions() m_lastPage->setEnabled( false ); m_prevPage->setEnabled( false ); m_nextPage->setEnabled( false ); - m_historyBack->setEnabled( false ); - m_historyNext->setEnabled( false ); + if (m_historyBack) m_historyBack->setEnabled( false ); + if (m_historyNext) m_historyNext->setEnabled( false ); m_reload->setEnabled( false ); } updateBookmarksActions(); @@ -1610,6 +1605,15 @@ void Part::unsetDummyMode() m_leftPanel->setVisible( Okular::Settings::showLeftPanel() ); + // add back and next in history + m_historyBack = KStandardAction::back( this, SLOT( slotHistoryBack() ), actionCollection() ); + actionCollection()->addAction("history_back",m_historyBack); + m_historyBack->setWhatsThis( i18n( "Go to the place you were before" ) ); + + m_historyNext = KStandardAction::forward( this, SLOT( slotHistoryNext() ), actionCollection()); + actionCollection()->addAction("history_forward",m_historyNext); + m_historyNext->setWhatsThis( i18n( "Go to the place you were after" ) ); + // apply configuration (both internal settings and GUI configured items) QList splitterSizes = Okular::Settings::splitterSizes(); if ( !splitterSizes.count() ) @@ -1626,6 +1630,9 @@ void Part::unsetDummyMode() // attach the actions of the children widgets too m_formsMessage->setActionButton( m_pageView->toggleFormsAction() ); + + // ensure history actions are in the correct state + updateViewActions(); } diff --git a/part.h b/part.h index d379fccc0..2b58242a1 100644 --- a/part.h +++ b/part.h @@ -164,13 +164,14 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi void slotFileDirty( const QString& ); void slotDoFileDirty(); void psTransformEnded(int, QProcess::ExitStatus); - void unsetDummyMode(); private: void doPrint( KPrinter& printer ); bool handleCompressed(KUrl & url, const QString &path, const KMimeType::Ptr mimetype); void rebuildBookmarkMenu( bool unplugActions = true ); void updateAboutBackendAction(); + void unsetDummyMode(); + KTemporaryFile *m_tempfile; // the document diff --git a/shell/shell.cpp b/shell/shell.cpp index 888e3e1de..281778a92 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -71,9 +71,6 @@ void Shell::init() m_part = (KParts::ReadOnlyPart*) factory->createPart(this, this); if (m_part) { - // we don't want the dummy mode - QMetaObject::invokeMethod(m_part, "unsetDummyMode"); - // then, setup our actions setupActions(); // tell the KParts::MainWindow that this is indeed the main widget