diff --git a/conf/dlggeneral.cpp b/conf/dlggeneral.cpp index d8c436c4f..ad389f392 100644 --- a/conf/dlggeneral.cpp +++ b/conf/dlggeneral.cpp @@ -27,6 +27,7 @@ DlgGeneral::DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode ) m_dlg->kcfg_DisplayDocumentTitle->setVisible( false ); m_dlg->kcfg_WatchFile->setVisible( false ); } + m_dlg->kcfg_ShellOpenFileInTabs->setVisible( embedMode == Okular::NativeShellMode ); } DlgGeneral::~DlgGeneral() diff --git a/conf/dlggeneralbase.ui b/conf/dlggeneralbase.ui old mode 100644 new mode 100755 index b70af8aeb..1cf6ea955 --- a/conf/dlggeneralbase.ui +++ b/conf/dlggeneralbase.ui @@ -187,6 +187,13 @@ 0 + + + + Open new files in &tabs + + + diff --git a/conf/okular.kcfg b/conf/okular.kcfg index deabd07bb..f954c9acf 100644 --- a/conf/okular.kcfg +++ b/conf/okular.kcfg @@ -79,6 +79,9 @@ + + false + true diff --git a/interfaces/viewerinterface.h b/interfaces/viewerinterface.h index 8ecaabb0f..c3de2e9bb 100644 --- a/interfaces/viewerinterface.h +++ b/interfaces/viewerinterface.h @@ -64,6 +64,10 @@ class ViewerInterface */ virtual void setWatchFileModeEnabled(bool b) = 0; + /** + * Should the shell that supports tabs pen new files in tabs? + */ + virtual bool openNewFilesInTabs() const = 0; // SIGNALS /** diff --git a/part.cpp b/part.cpp index 637862975..283e91a73 100644 --- a/part.cpp +++ b/part.cpp @@ -942,6 +942,11 @@ void Part::setShowSourceLocationsGraphically(bool show) m_pageView->setShowSourceLocationsGraphically(show); } +bool Part::openNewFilesInTabs() const +{ + return Okular::Settings::self()->shellOpenFileInTabs(); +} + void Part::slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled) { emit openSourceReference( absFileName, line, col ); diff --git a/part.h b/part.h index b1bed54e7..6df835bc7 100644 --- a/part.h +++ b/part.h @@ -132,6 +132,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc void setWatchFileModeEnabled(bool enable); bool areSourceLocationsShownGraphically() const; void setShowSourceLocationsGraphically(bool show); + bool openNewFilesInTabs() const; public slots: // dbus Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page); diff --git a/shell/shell.cpp b/shell/shell.cpp index 5df99fd73..822615351 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -52,6 +52,7 @@ // local includes #include "kdocumentviewer.h" +#include "../interfaces/viewerinterface.h" #include "shellutils.h" static const char *shouldShowMenuBarComingFromFullScreen = "shouldShowMenuBarComingFromFullScreen"; @@ -174,7 +175,8 @@ void Shell::openUrl( const KUrl & url ) const int activeTab = m_tabWidget->currentIndex(); if ( activeTab < m_tabs.size() ) { - if( !m_tabs[activeTab].part->url().isEmpty() ) + KParts::ReadWritePart* const activePart = m_tabs[activeTab].part; + if( !activePart->url().isEmpty() ) { if( m_unique ) { @@ -182,7 +184,7 @@ void Shell::openUrl( const KUrl & url ) } else { - if( m_openInTab->isChecked() ) + if( dynamic_cast(activePart)->openNewFilesInTabs() ) { openNewTab( url ); setActiveTab( m_tabs.size()-1 ); @@ -197,16 +199,15 @@ void Shell::openUrl( const KUrl & url ) } else { - KParts::ReadWritePart* const emptyPart = m_tabs[activeTab].part; m_tabWidget->setTabText( activeTab, url.fileName() ); if ( m_args ){ - KDocumentViewer* const doc = qobject_cast(emptyPart); + KDocumentViewer* const doc = qobject_cast(activePart); if ( doc && m_args->isSet( "presentation" ) ) doc->startPresentation(); if ( m_args->isSet( "print" ) ) - QMetaObject::invokeMethod( emptyPart, "enableStartWithPrint" ); + QMetaObject::invokeMethod( activePart, "enableStartWithPrint" ); } - bool openOk = emptyPart->openUrl( url ); + bool openOk = activePart->openUrl( url ); const bool isstdin = url.fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" ); if ( !isstdin ) { @@ -246,8 +247,6 @@ void Shell::readSettings() m_menuBarWasShown = group.readEntry( shouldShowMenuBarComingFromFullScreen, true ); m_toolBarWasShown = group.readEntry( shouldShowToolBarComingFromFullScreen, true ); } - - m_openInTab->setChecked( group.readEntry("OpenInTab", true) ); } void Shell::writeSettings() @@ -260,7 +259,6 @@ void Shell::writeSettings() group.writeEntry( shouldShowMenuBarComingFromFullScreen, m_menuBarWasShown ); group.writeEntry( shouldShowToolBarComingFromFullScreen, m_toolBarWasShown ); } - group.writeEntry( "OpenInTab", m_openInTab->isChecked() ); KGlobal::config()->sync(); } @@ -294,9 +292,6 @@ void Shell::setupActions() m_prevTabAction->setShortcut( KStandardShortcut::tabPrev() ); m_prevTabAction->setEnabled( false ); connect( m_prevTabAction, SIGNAL(triggered()), this, SLOT(activatePrevTab()) ); - - m_openInTab = actionCollection()->add("open_in_tab"); - m_openInTab->setText( i18n("Open Documents in New Tab") ); } void Shell::saveProperties(KConfigGroup &group) diff --git a/shell/shell.rc b/shell/shell.rc index 26114d857..93fbc4175 100644 --- a/shell/shell.rc +++ b/shell/shell.rc @@ -1,5 +1,5 @@ - + @@ -12,7 +12,6 @@ -