1/*
2 * Copyright (C) 1997-2002 Richard J. Moore <rich@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20
21#include <kapplication.h>
22#include <kimageio.h>
23#include <klocale.h>
24#include <kcmdlineargs.h>
25#include <kaboutdata.h>
26#include <kiconloader.h>
27
28#include "ksnapshotadaptor.h"
29#include "ksnapshot.h"
30#include "ksnapshot_options.h"
31
32#define KSNAPVERSION "0.8.2"
33
34static const char description[] = I18N_NOOP("KDE Screenshot Utility");
35
36int main(int argc, char **argv)
37{
38 KAboutData aboutData( "ksnapshot", 0, ki18n("KSnapshot"),
39 KSNAPVERSION, ki18n(description), KAboutData::License_GPL,
40 ki18n("(c) 1997-2008, Richard J. Moore,\n(c) 2000, Matthias Ettrich,\n(c) 2002-2003 Aaron J. Seigo"));
41 aboutData.addAuthor(ki18n("Richard J. Moore"),KLocalizedString(), "rich@kde.org");
42 aboutData.addAuthor(ki18n("Matthias Ettrich"),KLocalizedString(), "ettrich@kde.org");
43 aboutData.addAuthor(ki18n("Aaron J. Seigo"), KLocalizedString(), "aseigo@kde.org");
44 aboutData.addCredit( ki18n("Nadeem Hasan"), ki18n("Region Grabbing\nReworked GUI"),
45 "nhasan@kde.org" );
46 aboutData.addCredit( ki18n("Marcus Hufgard"), ki18n("\"Open With\" function"),
47 "Marcus.Hufgard@hufgard.de" );
48 aboutData.addCredit( ki18n("Pau Garcia i Quiles"), ki18n("Free region grabbing, KIPI plugins support, port to Windows"),
49 "pgquiles@elpauer.org" );
50
51 KCmdLineArgs::init( argc, argv, &aboutData );
52 KCmdLineArgs::addCmdLineOptions( ksnapshot_options() ); // Add our own options.
53 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
54
55 // This is one of the applications that requires the "native" / X11 graphics backend to work.
56 QApplication::setGraphicsSystem("native");
57 KApplication app;
58
59 // Create top level window
60 KSnapshot *toplevel;
61 bool showTopLevel = false;
62
63 if ( args->isSet( "current" ) )
64 toplevel = new KSnapshot( 0, KSnapshotObject::WindowUnderCursor );
65 else if(args->isSet( "fullscreen" ))
66 {
67 //we grad directly desktop => show dialogbox
68 showTopLevel = true;
69 toplevel = new KSnapshot( 0, KSnapshotObject::FullScreen );
70 }
71 else if(args->isSet( "region" ))
72 toplevel = new KSnapshot( 0, KSnapshotObject::Region );
73 else if(args->isSet( "freeregion" ))
74 toplevel = new KSnapshot( 0, KSnapshotObject::FreeRegion );
75 else if(args->isSet( "child" ))
76 toplevel = new KSnapshot( 0, KSnapshotObject::ChildWindow );
77 else
78 {
79 showTopLevel = true;
80 toplevel = new KSnapshot();
81 }
82
83 args->clear();
84 new KsnapshotAdaptor(toplevel);
85 QDBusConnection::sessionBus().registerObject("/KSnapshot", toplevel);
86
87 if(showTopLevel)
88 toplevel->show();
89 return app.exec();
90}
91
92