Commit d29099b3 authored by Michel Ludwig's avatar Michel Ludwig

Only activate a subset of the available features when the part is launched in viewer mode.

In viewer mode the part will now use a different XML GUI file (part-viewermode.rc).
Also, some actions won't be created, e.g. those used for exporting stuff, for
launching presentation mode, or for selecting parts of the document. The captions
of the configuration dialogs also contain the word 'viewer' then.
parent 1a5f2be0
......@@ -197,7 +197,7 @@ install(TARGETS okularpart DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( FILES okular_part.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES part.rc DESTINATION ${DATA_INSTALL_DIR}/okular )
install( FILES part.rc part-viewermode.rc DESTINATION ${DATA_INSTALL_DIR}/okular )
########### cmake files #################
......
......@@ -15,11 +15,18 @@
#include "ui_dlggeneralbase.h"
DlgGeneral::DlgGeneral( QWidget * parent )
DlgGeneral::DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode )
: QWidget( parent )
{
m_dlg = new Ui_DlgGeneralBase();
m_dlg->setupUi( this );
if( embedMode == Okular::ViewerWidgetMode )
{
m_dlg->kcfg_SyncThumbnailsViewport->setVisible( false );
m_dlg->kcfg_DisplayDocumentTitle->setVisible( false );
m_dlg->kcfg_WatchFile->setVisible( false );
}
}
DlgGeneral::~DlgGeneral()
......
......@@ -12,12 +12,14 @@
#include <qwidget.h>
#include "core/global.h"
class Ui_DlgGeneralBase;
class DlgGeneral : public QWidget
{
public:
DlgGeneral( QWidget * parent = 0 );
DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode );
virtual ~DlgGeneral();
protected:
......
......@@ -21,15 +21,15 @@
#include "dlgeditor.h"
#include "dlgdebug.h"
PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skeleton )
PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skeleton, Okular::EmbedMode embedMode )
: KConfigDialog( parent, "preferences", skeleton )
{
m_general = new DlgGeneral( this );
m_general = new DlgGeneral( this, embedMode );
m_performance = new DlgPerformance( this );
m_accessibility = new DlgAccessibility( this );
m_presentation = new DlgPresentation( this );
m_identity = new DlgIdentity( this );
m_editor = new DlgEditor( this );
m_presentation = NULL;
m_identity = NULL;
m_editor = NULL;
#ifdef OKULAR_DEBUG_CONFIGPAGE
m_debug = new DlgDebug( this );
#endif
......@@ -37,11 +37,21 @@ PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skelet
addPage( m_general, i18n("General"), "okular", i18n("General Options") );
addPage( m_accessibility, i18n("Accessibility"), "preferences-desktop-accessibility", i18n("Accessibility Reading Aids") );
addPage( m_performance, i18n("Performance"), "preferences-system-performance", i18n("Performance Tuning") );
addPage( m_presentation, i18n("Presentation"), "view-presentation",
i18n("Options for Presentation Mode") );
addPage( m_identity, i18n("Identity"), "preferences-desktop-personal",
i18n("Identity Settings") );
addPage( m_editor, i18n("Editor"), "accessories-text-editor", i18n("Editor Options") );
if( embedMode == Okular::ViewerWidgetMode )
{
setCaption( i18n("Configure Viewer") );
}
else
{
m_presentation = new DlgPresentation( this );
m_identity = new DlgIdentity( this );
m_editor = new DlgEditor( this );
addPage( m_presentation, i18n("Presentation"), "view-presentation",
i18n("Options for Presentation Mode") );
addPage( m_identity, i18n("Identity"), "preferences-desktop-personal",
i18n("Identity Settings") );
addPage( m_editor, i18n("Editor"), "accessories-text-editor", i18n("Editor Options") );
}
#ifdef OKULAR_DEBUG_CONFIGPAGE
addPage( m_debug, "Debug", "system-run", "Debug options" );
#endif
......
......@@ -12,6 +12,7 @@
#include <kconfigdialog.h>
#include "settings.h"
#include "core/global.h"
class QWidget;
class KConfigSkeleton;
......@@ -28,7 +29,7 @@ class PreferencesDialog : public KConfigDialog
{
public:
PreferencesDialog( QWidget * parent, KConfigSkeleton * config );
PreferencesDialog( QWidget * parent, KConfigSkeleton * config, Okular::EmbedMode embedMode );
protected:
// void updateSettings(); // Called when OK/Apply is pressed.
......
......@@ -78,6 +78,15 @@ enum ScriptType
JavaScript = 0 ///< JavaScript code
};
enum EmbedMode
{
UnknownEmbedMode,
NativeShellMode, // embedded in the native Okular' shell
PrintPreviewMode, // embedded to show the print preview of a document
KHTMLPartMode, // embedded in KHTML
ViewerWidgetMode, // the part acts as a widget that can display all kinds of documents
};
}
#endif
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="okular_part_viewermode" version="1">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="file_print_preview" group="okular_print_merge"/>
</Menu>
<Menu name="settings"><text>&amp;Settings</text>
<Action name="options_configure_generators" group="configure_merge"/>
<Action name="options_configure" group="configure_merge"/>
</Menu>
<Menu name="help"><text>&amp;Help</text>
<Action name="help_about_backend" group="about_merge"/>
</Menu>
</MenuBar>
<Menu name="menu_okular_part_viewer">
<Action name="mouse_drag" group="viewer_menu_merge"/>
<Action name="mouse_zoom" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Action name="view_zoom_in" group="viewer_menu_merge"/>
<Action name="view_zoom_out" group="viewer_menu_merge"/>
<Action name="view_fit_to_width" group="viewer_menu_merge"/>
<Action name="view_fit_to_page" group="viewer_menu_merge"/>
<Action name="zoom_fit_rect" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Action name="view_continuous" group="viewer_menu_merge"/>
<Action name="view_render_mode" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Menu name="view_orientation" group="viewer_menu_merge"><text>&amp;Orientation</text>
<Action name="view_orientation_rotate_ccw" group="viewer_menu_merge"/>
<Action name="view_orientation_rotate_cw" group="viewer_menu_merge"/>
<Action name="view_orientation_original" group="viewer_menu_merge"/>
</Menu>
<Action name="view_pagesizes" group="viewer_menu_merge"/>
<Action name="view_trim_margins" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Action name="go_previous" group="viewer_menu_merge"/>
<Action name="go_next" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Action name="first_page" group="viewer_menu_merge"/>
<Action name="last_page" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Action name="go_document_back" group="viewer_menu_merge"/>
<Action name="go_document_forward" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Action name="go_goto_page" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Menu name="okular_bookmarks" group="viewer_menu_merge"><text>&amp;Bookmarks</text>
<Action name="bookmark_add" group="viewer_menu_merge"/>
<Action name="previous_bookmark" group="viewer_menu_merge"/>
<Action name="next_bookmark" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<ActionList name="bookmarks_currentdocument" group="viewer_menu_merge"/>
</Menu>
<Separator group="viewer_menu_merge"/>
<Action name="edit_find" group="viewer_menu_merge"/>
<Action name="edit_find_next" group="viewer_menu_merge"/>
<Action name="edit_find_prev" group="viewer_menu_merge"/>
</Menu>
<ToolBar name="OkularViewerToolBar"><text>Viewer Toolbar</text>
<Action name="zoom_to" />
<Action name="view_zoom_out"/>
<Action name="view_zoom_in"/>
<Separator/>
<Action name="mouse_drag"/>
<Action name="mouse_zoom"/>
<Action name="mouse_selecttools"/>
</ToolBar>
</kpartgui>
This diff is collapsed.
......@@ -80,15 +80,6 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
Q_INTERFACES(Okular::ViewerInterface)
public:
enum EmbedMode
{
UnknownEmbedMode,
NativeShellMode, // embedded in the native Okular' shell
PrintPreviewMode, // embedded to show the print preview of a document
KHTMLPartMode, // embedded in KHTML
ViewerWidgetMode, // the part acts as a widget that can display all kinds of documents
};
// Default constructor
/**
* If one element of 'args' contains one of the strings "Print/Preview" or "ViewerWidget",
......@@ -195,6 +186,9 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
void psTransformEnded(int, QProcess::ExitStatus);
private:
void setupViewerActions();
void setupActions();
void setupPrint( QPrinter &printer );
void doPrint( QPrinter &printer );
bool handleCompressed( QString &destpath, const QString &path, const QString &compressedMimetype );
......
......@@ -197,6 +197,7 @@ public:
KAction * aSpeakPage;
KAction * aSpeakStop;
KActionCollection * actionCollection;
QActionGroup * mouseModeActionGroup;
int setting_viewCols;
......@@ -305,6 +306,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->actionCollection = 0;
d->aPageSizes=0;
d->setting_viewCols = Okular::Settings::viewColumns();
d->mouseModeActionGroup = 0;
d->showMoveDestinationGraphically = false;
switch( Okular::Settings::zoomMode() )
......@@ -402,10 +404,13 @@ void PageView::setupBaseActions( KActionCollection * ac )
d->aZoomOut = KStandardAction::zoomOut( this, SLOT(slotZoomOut()), ac );
}
void PageView::setupActions( KActionCollection * ac )
void PageView::setupViewerActions( KActionCollection * ac )
{
d->actionCollection = ac;
d->aZoomIn->setShortcut( QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Plus) );
d->aZoomOut->setShortcut( QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Minus) );
// orientation menu actions
d->aRotateClockwise = new KAction( KIcon( "object-rotate-right" ), i18n( "Rotate &Right" ), this );
d->aRotateClockwise->setIconText( i18nc( "Rotate right", "Right" ) );
......@@ -482,16 +487,16 @@ do { \
connect( d->aViewContinuous, SIGNAL(toggled(bool)), SLOT(slotContinuousToggled(bool)) );
d->aViewContinuous->setChecked( Okular::Settings::viewContinuous() );
// Mouse-Mode actions
QActionGroup * actGroup = new QActionGroup( this );
actGroup->setExclusive( true );
// Mouse mode actions for viewer mode
d->mouseModeActionGroup = new QActionGroup( this );
d->mouseModeActionGroup->setExclusive( true );
d->aMouseNormal = new KAction( KIcon( "input-mouse" ), i18n( "&Browse Tool" ), this );
ac->addAction("mouse_drag", d->aMouseNormal );
connect( d->aMouseNormal, SIGNAL(triggered()), this, SLOT(slotSetMouseNormal()) );
d->aMouseNormal->setIconText( i18nc( "Browse Tool", "Browse" ) );
d->aMouseNormal->setCheckable( true );
d->aMouseNormal->setShortcut( Qt::CTRL + Qt::Key_1 );
d->aMouseNormal->setActionGroup( actGroup );
d->aMouseNormal->setActionGroup( d->mouseModeActionGroup );
d->aMouseNormal->setChecked( true );
KAction * mz = new KAction(KIcon( "page-zoom" ), i18n("&Zoom Tool"), this);
......@@ -500,15 +505,26 @@ do { \
mz->setIconText( i18nc( "Zoom Tool", "Zoom" ) );
mz->setCheckable( true );
mz->setShortcut( Qt::CTRL + Qt::Key_2 );
mz->setActionGroup( actGroup );
mz->setActionGroup( d->mouseModeActionGroup );
}
// WARNING: 'setupViewerActions' must have been called before this method
void PageView::setupActions( KActionCollection * ac )
{
d->actionCollection = ac;
d->aZoomIn->setShortcut( KStandardShortcut::zoomIn() );
d->aZoomOut->setShortcut( KStandardShortcut::zoomOut() );
// Mouse-Mode actions
d->aMouseSelect = new KAction(KIcon( "select-rectangular" ), i18n("&Selection Tool"), this);
ac->addAction("mouse_select", d->aMouseSelect );
connect( d->aMouseSelect, SIGNAL(triggered()), this, SLOT(slotSetMouseSelect()) );
d->aMouseSelect->setIconText( i18nc( "Select Tool", "Selection" ) );
d->aMouseSelect->setCheckable( true );
d->aMouseSelect->setShortcut( Qt::CTRL + Qt::Key_3 );
d->aMouseSelect->setActionGroup( actGroup );
d->aMouseSelect->setActionGroup( d->mouseModeActionGroup );
d->aMouseTextSelect = new KAction(KIcon( "draw-text" ), i18n("&Text Selection Tool"), this);
ac->addAction("mouse_textselect", d->aMouseTextSelect );
......@@ -516,7 +532,8 @@ do { \
d->aMouseTextSelect->setIconText( i18nc( "Text Selection Tool", "Text Selection" ) );
d->aMouseTextSelect->setCheckable( true );
d->aMouseTextSelect->setShortcut( Qt::CTRL + Qt::Key_4 );
d->aMouseTextSelect->setActionGroup( actGroup );
Q_ASSERT( d->mouseModeActionGroup );
d->aMouseTextSelect->setActionGroup( d->mouseModeActionGroup );
d->aMouseTableSelect = new KAction(KIcon( "select-table" ), i18n("T&able Selection Tool"), this);
ac->addAction("mouse_tableselect", d->aMouseTableSelect );
......@@ -524,7 +541,7 @@ do { \
d->aMouseTableSelect->setIconText( i18nc( "Table Selection Tool", "Table Selection" ) );
d->aMouseTableSelect->setCheckable( true );
d->aMouseTableSelect->setShortcut( Qt::CTRL + Qt::Key_5 );
d->aMouseTableSelect->setActionGroup( actGroup );
d->aMouseTableSelect->setActionGroup( d->mouseModeActionGroup );
d->aToggleAnnotator = new KToggleAction(KIcon( "draw-freehand" ), i18n("&Review"), this);
ac->addAction("mouse_toggle_annotate", d->aToggleAnnotator );
......@@ -3877,7 +3894,7 @@ void PageView::slotSetMouseNormal()
// hide the messageWindow
d->messageWindow->hide();
// reshow the annotator toolbar if hiding was forced
if ( d->aToggleAnnotator->isChecked() )
if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() )
slotToggleAnnotator( true );
// force an update of the cursor
updateCursor( contentAreaPosition() + viewport()->mapFromGlobal( QCursor::pos() ) );
......
......@@ -62,6 +62,7 @@ Q_OBJECT
// create actions that interact with this widget
void setupBaseActions( KActionCollection * collection );
void setupViewerActions( KActionCollection * collection );
void setupActions( KActionCollection * collection );
// misc methods (from RMB menu/children)
......
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