Commit 5ab30aae authored by Tomáš Poledný's avatar Tomáš Poledný Committed by Albert Astals Cid

Open print dialog from command line

BUGS: 252462
REVIEW: 109096
FIXED-IN: 4.11.0
GUI
parent ab9283ae
......@@ -289,7 +289,7 @@ const QVariantList &args,
KComponentData componentData )
: KParts::ReadWritePart(parent),
m_tempfile( 0 ), m_fileWasRemoved( false ), m_showMenuBarAction( 0 ), m_showFullScreenAction( 0 ), m_actionsSearched( false ),
m_cliPresentation(false), m_embedMode(detectEmbedMode(parentWidget, parent, args)), m_generatorGuiClient(0), m_keeper( 0 )
m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentWidget, parent, args)), m_generatorGuiClient(0), m_keeper( 0 )
{
// first, we check if a config file name has been specified
QString configFileName = detectConfigFileName( args );
......@@ -982,6 +982,7 @@ void Part::slotJobFinished(KJob *job)
void Part::loadCancelled(const QString &reason)
{
emit setWindowCaption( QString() );
resetStartArguments();
// when m_viewportDirty.pageNumber != -1 we come from slotDoFileDirty
// so we don't want to show an ugly messagebox just because the document is
......@@ -1312,6 +1313,11 @@ bool Part::openFile()
m_generatorGuiClient = factory() ? m_document->guiClient() : 0;
if ( m_generatorGuiClient )
factory()->addClient( m_generatorGuiClient );
if ( m_cliPrint )
{
m_cliPrint = false;
slotPrint();
}
return true;
}
......@@ -1354,6 +1360,7 @@ bool Part::openUrl(const KUrl &_url)
}
else
{
resetStartArguments();
KMessageBox::error( widget(), i18n("Could not open %1", url.pathOrUrl() ) );
}
......@@ -2376,6 +2383,10 @@ void Part::reload()
}
}
void Part::enableStartWithPrint()
{
m_cliPrint = true;
}
void Part::slotAboutBackend()
{
......@@ -2756,6 +2767,11 @@ void Part::updateAboutBackendAction()
}
}
void Part::resetStartArguments()
{
m_cliPrint = false;
}
void Part::setReadWrite(bool readwrite)
{
m_document->setAnnotationEditingEnabled( readwrite );
......
......@@ -148,6 +148,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
Q_SCRIPTABLE void slotGotoLast();
Q_SCRIPTABLE void slotTogglePresentation();
Q_SCRIPTABLE Q_NOREPLY void reload();
Q_SCRIPTABLE Q_NOREPLY void enableStartWithPrint();
signals:
void enablePrintAction(bool enable);
......@@ -234,6 +235,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void updateAboutBackendAction();
void unsetDummyMode();
void slotRenameBookmark( const DocumentViewport &viewport );
void resetStartArguments();
static int numberOfParts;
......@@ -319,6 +321,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
QList<Okular::ExportFormat> m_exportFormats;
QList<QAction*> m_bookmarkActions;
bool m_cliPresentation;
bool m_cliPrint;
QString m_addBookmarkText;
QIcon m_addBookmarkIcon;
......
......@@ -31,6 +31,8 @@ static bool attachUniqueInstance(KCmdLineArgs* args)
if (!iface.isValid() || !iface2.isValid())
return false;
if (args->isSet("print"))
iface.call("enableStartWithPrint");
if (args->isSet("page"))
iface.call("openDocument", ShellUtils::urlFromArg(args->arg(0), ShellUtils::qfileExistFunc(), args->getOption("page")).url());
else
......@@ -52,6 +54,7 @@ int main(int argc, char** argv)
options.add("p");
options.add("page <number>", ki18n("Page of the document to be shown"));
options.add("presentation", ki18n("Start the document in presentation mode"));
options.add("print", ki18n("Start with print dialog"));
options.add("unique", ki18n("\"Unique instance\" control"));
options.add("noraise", ki18n("Not raise window"));
options.add("+[URL]", ki18n("Document to open. Specify '-' to read from stdin."));
......
......@@ -179,8 +179,12 @@ void Shell::openUrl( const KUrl & url )
}
else
{
if ( m_doc && m_args && m_args->isSet( "presentation" ) )
m_doc->startPresentation();
if ( m_args ){
if ( m_doc && m_args->isSet( "presentation" ) )
m_doc->startPresentation();
if ( m_args->isSet( "print" ) )
QMetaObject::invokeMethod( m_part, "enableStartWithPrint" );
}
bool openOk = m_part->openUrl( url );
const bool isstdin = url.fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" );
if ( !isstdin )
......
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