2004-08-26 21:17:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
|
|
|
|
* Copyright (C) 2003 by Christophe Devriese *
|
|
|
|
* <Christophe.Devriese@student.kuleuven.ac.be> *
|
|
|
|
* Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
|
2007-10-11 18:57:28 +00:00
|
|
|
* Copyright (C) 2003-2007 by Albert Astals Cid <aacid@kde.org> *
|
2004-08-26 21:17:24 +00:00
|
|
|
* Copyright (C) 2004 by Andy Goossens <andygoossens@telenet.be> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2005-01-02 14:29:37 +00:00
|
|
|
#include "shell.h"
|
2002-08-30 09:14:01 +00:00
|
|
|
#include <kapplication.h>
|
|
|
|
#include <kcmdlineargs.h>
|
|
|
|
#include <klocale.h>
|
2008-09-21 22:52:02 +00:00
|
|
|
#include <QtDBus/qdbusinterface.h>
|
2007-03-10 23:45:12 +00:00
|
|
|
#include "aboutdata.h"
|
2002-08-30 09:14:01 +00:00
|
|
|
|
2008-09-21 22:52:02 +00:00
|
|
|
static bool attachUniqueInstance(KCmdLineArgs* args)
|
|
|
|
{
|
|
|
|
if (!args->isSet("unique") || args->count() != 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QDBusInterface iface("org.kde.okular", "/okular", "org.kde.okular");
|
|
|
|
if (!iface.isValid())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
iface.call("openDocument", args->url(0).pathOrUrl());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-08-30 09:14:01 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2008-01-20 15:35:19 +00:00
|
|
|
KAboutData about = okularAboutData( "okular", I18N_NOOP( "Okular" ) );
|
2004-08-28 16:59:55 +00:00
|
|
|
|
2007-09-30 16:52:27 +00:00
|
|
|
KCmdLineArgs::init(argc, argv, &about);
|
2007-07-02 08:52:55 +00:00
|
|
|
|
|
|
|
KCmdLineOptions options;
|
|
|
|
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"));
|
2008-11-18 18:50:50 +00:00
|
|
|
options.add("unique", ki18n("\"Unique instance\" control"));
|
2009-01-06 21:58:38 +00:00
|
|
|
options.add("+[URL]", ki18n("Document to open. Specify '-' to read from stdin."));
|
2003-08-15 00:55:25 +00:00
|
|
|
KCmdLineArgs::addCmdLineOptions( options );
|
|
|
|
KApplication app;
|
|
|
|
|
|
|
|
// see if we are starting with session management
|
2006-03-21 20:03:08 +00:00
|
|
|
if (app.isSessionRestored())
|
2002-08-30 09:14:01 +00:00
|
|
|
{
|
2006-09-21 08:45:36 +00:00
|
|
|
RESTORE(Shell);
|
2003-08-15 00:55:25 +00:00
|
|
|
} else {
|
|
|
|
// no session.. just start up normally
|
|
|
|
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
|
|
|
|
|
2008-09-21 22:52:02 +00:00
|
|
|
// try to attach the "unique" session: if we succeed, do nothing more and exit
|
|
|
|
if (attachUniqueInstance(args))
|
|
|
|
{
|
|
|
|
args->clear();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-08-15 00:55:25 +00:00
|
|
|
if (args->count() == 0)
|
|
|
|
{
|
2007-01-04 00:20:50 +00:00
|
|
|
Shell* widget = new Shell(args);
|
2003-08-15 00:55:25 +00:00
|
|
|
widget->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < args->count(); ++i)
|
|
|
|
{
|
2009-05-17 18:08:43 +00:00
|
|
|
Shell* widget = new Shell(args, i);
|
2003-08-15 00:55:25 +00:00
|
|
|
widget->show();
|
|
|
|
}
|
|
|
|
}
|
2002-08-30 09:14:01 +00:00
|
|
|
}
|
2007-06-06 15:33:17 +00:00
|
|
|
|
2007-09-30 16:52:27 +00:00
|
|
|
return app.exec();
|
2002-08-30 09:14:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// vim:ts=2:sw=2:tw=78:et
|