Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b883cbcf authored by Albert Astals Cid's avatar Albert Astals Cid

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
parent 23e780c7
......@@ -419,22 +419,6 @@ m_searchStarted(false), m_cliPresentation(false)
closeFindBar->setShortcut( QKeySequence( Qt::Key_Escape ) );
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
m_watcher = new KDirWatch( this );
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");
//
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)
{
if (m_dummyMode) return;
m_bExtension->openUrlNotify();
m_bExtension->setLocationBarUrl(url.prettyUrl());
openUrl(url);
......@@ -699,7 +690,8 @@ bool Part::openFile()
bool hasEmbeddedFiles = ok && m_document->embeddedFiles() && m_document->embeddedFiles()->count() > 0;
m_showEmbeddedFiles->setEnabled( 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 );
if ( ok )
{
......@@ -1173,6 +1165,8 @@ void Part::slotFindNext()
void Part::slotSaveFileAs()
{
if (m_dummyMode) return;
KUrl saveUrl = KFileDialog::getSaveUrl( url().isLocalFile() ? url().url() : url().fileName(), QString(), widget() );
if ( saveUrl.isValid() && !saveUrl.isEmpty() )
{
......@@ -1288,6 +1282,8 @@ void Part::slotPrintPreview()
void Part::slotShowMenu(const Okular::Page *page, const QPoint &point)
{
if (m_dummyMode) return;
bool reallyShow = false;
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)
{
......
......@@ -162,6 +162,7 @@ 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 );
......@@ -241,6 +242,8 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
QString m_addBookmarkText;
QIcon m_addBookmarkIcon;
bool m_dummyMode;
private slots:
void slotGeneratorPreferences();
};
......
......@@ -71,6 +71,9 @@ 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
......@@ -103,7 +106,6 @@ void Shell::init()
setAutoSaveSettings();
if (m_openUrl.isValid()) QTimer::singleShot(0, this, SLOT(delayedOpen()));
}
void Shell::delayedOpen()
......
......@@ -269,6 +269,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->messageWindow = new PageViewMessage(this);
d->m_formsVisible = false;
d->aPrevAction = 0;
d->aToggleForms = 0;
d->aPageSizes=0;
d->setting_viewMode = Okular::Settings::viewMode();
d->setting_viewCols = Okular::Settings::viewColumns();
......@@ -664,19 +665,25 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, bool docu
pageSet.count() ),
PageViewMessage::Info, 4000 );
bool pageSizes = d->document->supportsPageSizes();
d->aPageSizes->setEnabled( pageSizes );
// set the new page sizes:
// - if the generator supports them
// - if the document changed
if ( pageSizes && documentChanged )
{
QStringList items;
foreach ( const Okular::PageSize &p, d->document->pageSizes() )
items.append( p.name() );
d->aPageSizes->setItems( items );
if ( d->aPageSizes )
{ // may be null if dummy mode is on
bool pageSizes = d->document->supportsPageSizes();
d->aPageSizes->setEnabled( pageSizes );
// set the new page sizes:
// - if the generator supports them
// - if the document changed
if ( pageSizes && documentChanged )
{
QStringList 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 )
d->annotator->setTextToolsEnabled( d->document->supportsSearching() );
}
......@@ -2278,13 +2285,16 @@ void PageView::toggleFormWidgets( bool on )
if ( somehadfocus )
setFocus();
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" ) );
}
else
{
d->aToggleForms->setText( i18n( "Show Forms" ) );
if ( d->m_formsVisible )
{
d->aToggleForms->setText( i18n( "Hide Forms" ) );
}
else
{
d->aToggleForms->setText( i18n( "Show Forms" ) );
}
}
}
......
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