The part starts in dummy mode (very few ui) by default

Can be deactivated using unsetDummyMode(), that is the first thing the okular shell does
that's useful because for example for print preview you don't want to embed all the okular ui to do the preview, you just want to see the ps

svn path=/trunk/KDE/kdegraphics/okular/; revision=671928
remotes/origin/KDE/4.0
Albert Astals Cid 19 years ago
parent 23e780c7aa
commit b883cbcfa6
  1. 57
      part.cpp
  2. 3
      part.h
  3. 4
      shell/shell.cpp
  4. 46
      ui/pageview.cpp

@ -419,22 +419,6 @@ m_searchStarted(false), m_cliPresentation(false)
closeFindBar->setShortcut( QKeySequence( Qt::Key_Escape ) ); closeFindBar->setShortcut( QKeySequence( Qt::Key_Escape ) );
widget()->addAction(closeFindBar); widget()->addAction(closeFindBar);
// attach the actions of the children widgets too
m_pageView->setupActions( ac );
m_formsMessage->setActionButton( m_pageView->toggleFormsAction() );
// apply configuration (both internal settings and GUI configured items)
QList<int> splitterSizes = Okular::Settings::splitterSizes();
if ( !splitterSizes.count() )
{
// the first time use 1/10 for the panel and 9/10 for the pageView
splitterSizes.push_back( 50 );
splitterSizes.push_back( 500 );
}
m_splitter->setSizes( splitterSizes );
// get notified about splitter size changes
connect( m_splitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( splitterMoved( int, int ) ) );
// document watcher and reloader // document watcher and reloader
m_watcher = new KDirWatch( this ); m_watcher = new KDirWatch( this );
connect( m_watcher, SIGNAL( dirty( const QString& ) ), this, SLOT( slotFileDirty( const QString& ) ) ); connect( m_watcher, SIGNAL( dirty( const QString& ) ), this, SLOT( slotFileDirty( const QString& ) ) );
@ -455,6 +439,11 @@ m_searchStarted(false), m_cliPresentation(false)
setXMLFile("part.rc"); setXMLFile("part.rc");
// //
updateViewActions(); 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();
} }
@ -498,6 +487,8 @@ QStringList Part::supportedMimeTypes() const
void Part::openUrlFromDocument(const KUrl &url) void Part::openUrlFromDocument(const KUrl &url)
{ {
if (m_dummyMode) return;
m_bExtension->openUrlNotify(); m_bExtension->openUrlNotify();
m_bExtension->setLocationBarUrl(url.prettyUrl()); m_bExtension->setLocationBarUrl(url.prettyUrl());
openUrl(url); openUrl(url);
@ -699,7 +690,8 @@ bool Part::openFile()
bool hasEmbeddedFiles = ok && m_document->embeddedFiles() && m_document->embeddedFiles()->count() > 0; bool hasEmbeddedFiles = ok && m_document->embeddedFiles() && m_document->embeddedFiles()->count() > 0;
m_showEmbeddedFiles->setEnabled( hasEmbeddedFiles ); m_showEmbeddedFiles->setEnabled( hasEmbeddedFiles );
m_topMessage->setVisible( hasEmbeddedFiles ); m_topMessage->setVisible( hasEmbeddedFiles );
m_formsMessage->setVisible( ok && m_pageView->toggleFormsAction()->isEnabled() ); // m_pageView->toggleFormsAction() may be null on dummy mode
m_formsMessage->setVisible( ok && m_pageView->toggleFormsAction() && m_pageView->toggleFormsAction()->isEnabled() );
m_showPresentation->setEnabled( ok ); m_showPresentation->setEnabled( ok );
if ( ok ) if ( ok )
{ {
@ -1173,6 +1165,8 @@ void Part::slotFindNext()
void Part::slotSaveFileAs() void Part::slotSaveFileAs()
{ {
if (m_dummyMode) return;
KUrl saveUrl = KFileDialog::getSaveUrl( url().isLocalFile() ? url().url() : url().fileName(), QString(), widget() ); KUrl saveUrl = KFileDialog::getSaveUrl( url().isLocalFile() ? url().url() : url().fileName(), QString(), widget() );
if ( saveUrl.isValid() && !saveUrl.isEmpty() ) if ( saveUrl.isValid() && !saveUrl.isEmpty() )
{ {
@ -1288,6 +1282,8 @@ void Part::slotPrintPreview()
void Part::slotShowMenu(const Okular::Page *page, const QPoint &point) void Part::slotShowMenu(const Okular::Page *page, const QPoint &point)
{ {
if (m_dummyMode) return;
bool reallyShow = false; bool reallyShow = false;
if (!m_actionsSearched) if (!m_actionsSearched)
{ {
@ -1583,6 +1579,33 @@ void Part::psTransformEnded(int exit, QProcess::ExitStatus status)
} }
void Part::unsetDummyMode()
{
if (!m_dummyMode) return;
m_dummyMode = false;
m_leftPanel->setVisible( Okular::Settings::showLeftPanel() );
// apply configuration (both internal settings and GUI configured items)
QList<int> splitterSizes = Okular::Settings::splitterSizes();
if ( !splitterSizes.count() )
{
// the first time use 1/10 for the panel and 9/10 for the pageView
splitterSizes.push_back( 50 );
splitterSizes.push_back( 500 );
}
m_splitter->setSizes( splitterSizes );
// get notified about splitter size changes
connect( m_splitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( splitterMoved( int, int ) ) );
m_pageView->setupActions( actionCollection() );
// attach the actions of the children widgets too
m_formsMessage->setActionButton( m_pageView->toggleFormsAction() );
}
bool Part::handleCompressed(KUrl & url, const QString &path, const KMimeType::Ptr mimetype) bool Part::handleCompressed(KUrl & url, const QString &path, const KMimeType::Ptr mimetype)
{ {

@ -162,6 +162,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
void slotFileDirty( const QString& ); void slotFileDirty( const QString& );
void slotDoFileDirty(); void slotDoFileDirty();
void psTransformEnded(int, QProcess::ExitStatus); void psTransformEnded(int, QProcess::ExitStatus);
void unsetDummyMode();
private: private:
void doPrint( KPrinter& printer ); void doPrint( KPrinter& printer );
@ -241,6 +242,8 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
QString m_addBookmarkText; QString m_addBookmarkText;
QIcon m_addBookmarkIcon; QIcon m_addBookmarkIcon;
bool m_dummyMode;
private slots: private slots:
void slotGeneratorPreferences(); void slotGeneratorPreferences();
}; };

@ -71,6 +71,9 @@ void Shell::init()
m_part = (KParts::ReadOnlyPart*) factory->createPart(this, this); m_part = (KParts::ReadOnlyPart*) factory->createPart(this, this);
if (m_part) if (m_part)
{ {
// we don't want the dummy mode
QMetaObject::invokeMethod(m_part, "unsetDummyMode");
// then, setup our actions // then, setup our actions
setupActions(); setupActions();
// tell the KParts::MainWindow that this is indeed the main widget // tell the KParts::MainWindow that this is indeed the main widget
@ -103,7 +106,6 @@ void Shell::init()
setAutoSaveSettings(); setAutoSaveSettings();
if (m_openUrl.isValid()) QTimer::singleShot(0, this, SLOT(delayedOpen())); if (m_openUrl.isValid()) QTimer::singleShot(0, this, SLOT(delayedOpen()));
} }
void Shell::delayedOpen() void Shell::delayedOpen()

@ -269,6 +269,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->messageWindow = new PageViewMessage(this); d->messageWindow = new PageViewMessage(this);
d->m_formsVisible = false; d->m_formsVisible = false;
d->aPrevAction = 0; d->aPrevAction = 0;
d->aToggleForms = 0;
d->aPageSizes=0; d->aPageSizes=0;
d->setting_viewMode = Okular::Settings::viewMode(); d->setting_viewMode = Okular::Settings::viewMode();
d->setting_viewCols = Okular::Settings::viewColumns(); d->setting_viewCols = Okular::Settings::viewColumns();
@ -664,19 +665,25 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, bool docu
pageSet.count() ), pageSet.count() ),
PageViewMessage::Info, 4000 ); PageViewMessage::Info, 4000 );
bool pageSizes = d->document->supportsPageSizes(); if ( d->aPageSizes )
d->aPageSizes->setEnabled( pageSizes ); { // may be null if dummy mode is on
// set the new page sizes: bool pageSizes = d->document->supportsPageSizes();
// - if the generator supports them d->aPageSizes->setEnabled( pageSizes );
// - if the document changed // set the new page sizes:
if ( pageSizes && documentChanged ) // - if the generator supports them
{ // - if the document changed
QStringList items; if ( pageSizes && documentChanged )
foreach ( const Okular::PageSize &p, d->document->pageSizes() ) {
items.append( p.name() ); QStringList items;
d->aPageSizes->setItems( items ); foreach ( const Okular::PageSize &p, d->document->pageSizes() )
items.append( p.name() );
d->aPageSizes->setItems( items );
}
}
if ( d->aToggleForms )
{ // may be null if dummy mode is on
d->aToggleForms->setEnabled( !pageSet.isEmpty() && hasformwidgets );
} }
d->aToggleForms->setEnabled( !pageSet.isEmpty() && hasformwidgets );
if ( d->annotator ) if ( d->annotator )
d->annotator->setTextToolsEnabled( d->document->supportsSearching() ); d->annotator->setTextToolsEnabled( d->document->supportsSearching() );
} }
@ -2278,13 +2285,16 @@ void PageView::toggleFormWidgets( bool on )
if ( somehadfocus ) if ( somehadfocus )
setFocus(); setFocus();
d->m_formsVisible = on; d->m_formsVisible = on;
if ( d->m_formsVisible ) if ( d->aToggleForms ) // it may not exist if we are on dummy mode
{ {
d->aToggleForms->setText( i18n( "Hide Forms" ) ); if ( d->m_formsVisible )
} {
else d->aToggleForms->setText( i18n( "Hide Forms" ) );
{ }
d->aToggleForms->setText( i18n( "Show Forms" ) ); else
{
d->aToggleForms->setText( i18n( "Show Forms" ) );
}
} }
} }

Loading…
Cancel
Save