1 /***************************************************************************
2 * Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
3 * Copyright (C) 2003 by Christophe Devriese *
4 * <Christophe.Devriese@student.kuleuven.ac.be> *
5 * Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
6 * Copyright (C) 2003-2007 by Albert Astals Cid <aacid@kde.org> *
7 * Copyright (C) 2004 by Andy Goossens <andygoossens@telenet.be> *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 ***************************************************************************/
16 #include <kapplication.h>
17 #include <kcmdlineargs.h>
19 #include <QtDBus/qdbusinterface.h>
20 #include "aboutdata.h"
22 static bool attachUniqueInstance(KCmdLineArgs
* args
)
24 if (!args
->isSet("unique") || args
->count() != 1)
27 QDBusInterface
iface("org.kde.okular", "/okular", "org.kde.okular");
31 iface
.call("openDocument", args
->url(0).pathOrUrl());
36 int main(int argc
, char** argv
)
38 KAboutData about
= okularAboutData( "okular", I18N_NOOP( "Okular" ) );
40 KCmdLineArgs::init(argc
, argv
, &about
);
42 KCmdLineOptions options
;
44 options
.add("page <number>", ki18n("Page of the document to be shown"));
45 options
.add("presentation", ki18n("Start the document in presentation mode"));
46 options
.add("unique", ki18n("\"Unique session\" control"));
47 options
.add("+[URL]", ki18n("Document to open"));
48 KCmdLineArgs::addCmdLineOptions( options
);
51 // see if we are starting with session management
52 if (app
.isSessionRestored())
56 // no session.. just start up normally
57 KCmdLineArgs
* args
= KCmdLineArgs::parsedArgs();
59 // try to attach the "unique" session: if we succeed, do nothing more and exit
60 if (attachUniqueInstance(args
))
66 if (args
->count() == 0)
68 Shell
* widget
= new Shell(args
);
73 for (int i
= 0; i
< args
->count(); ++i
)
75 Shell
* widget
= new Shell(args
, args
->url(i
));
84 // vim:ts=2:sw=2:tw=78:et