1 | /* |
2 | * main.cc - part of KImageShop |
3 | * |
4 | * Copyright (c) 1999 Matthias Elter <me@kde.org> |
5 | * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | */ |
20 | |
21 | #include <stdlib.h> |
22 | |
23 | #include <QString> |
24 | #include <QPixmap> |
25 | #include <QDebug> |
26 | #include <QProcess> |
27 | #include <QProcessEnvironment> |
28 | #include <QDesktopServices> |
29 | #include <QDir> |
30 | |
31 | #include <kglobal.h> |
32 | #include <kcmdlineargs.h> |
33 | #include <ksycoca.h> |
34 | #include <kstandarddirs.h> |
35 | #include <kcrash.h> |
36 | |
37 | #include <KoApplication.h> |
38 | #include <KoConfig.h> |
39 | |
40 | #include <krita_export.h> |
41 | |
42 | #include "data/splash/splash_screen.xpm" |
43 | #include "ui/kis_aboutdata.h" |
44 | #include "ui/kis_factory2.h" |
45 | #include "ui/kis_doc2.h" |
46 | #include "kis_splash_screen.h" |
47 | |
48 | #if defined Q_OS_WIN |
49 | #include "stdlib.h" |
50 | #include <ui/input/wintab/kis_tablet_support_win.h> |
51 | #ifdef USE_BREAKPAD |
52 | #include "kis_crash_handler.h" |
53 | #endif |
54 | #elif defined Q_WS_X11 |
55 | #include <ui/input/wintab/kis_tablet_support_x11.h> |
56 | |
57 | #endif |
58 | |
59 | extern "C" KDE_EXPORT int kdemain(int argc, char **argv) |
60 | { |
61 | #ifdef Q_WS_X11 |
62 | if (!qgetenv("KDE_FULL_SESSION" ).isEmpty()) { |
63 | setenv("QT_NO_GLIB" , "1" , true); |
64 | } |
65 | #endif |
66 | #ifdef USE_BREAKPAD |
67 | qputenv("KDE_DEBUG" , "1" ); |
68 | KisCrashHandler crashHandler; |
69 | Q_UNUSED(crashHandler); |
70 | #endif |
71 | |
72 | int state; |
73 | KAboutData *aboutData = KisFactory2::aboutData(); |
74 | |
75 | KCmdLineArgs::init(argc, argv, aboutData); |
76 | |
77 | KCmdLineOptions options; |
78 | options.add("+[file(s)]" , ki18n("File(s) or URL(s) to open" )); |
79 | options.add( "hwinfo" , ki18n( "Show some information about the hardware" )); |
80 | KCmdLineArgs::addCmdLineOptions(options); |
81 | |
82 | // first create the application so we can create a pixmap |
83 | KoApplication app(KIS_MIME_TYPE); |
84 | |
85 | #if defined Q_OS_WIN |
86 | KisTabletSupportWin::init(); |
87 | app.setEventFilter(&KisTabletSupportWin::eventFilter); |
88 | app.setAttribute(Qt::AA_DontShowIconsInMenus); |
89 | #elif defined Q_WS_X11 |
90 | KisTabletSupportX11::init(); |
91 | app.setEventFilter(&KisTabletSupportX11::eventFilter); |
92 | #endif |
93 | |
94 | #if defined Q_WS_X11 && QT_VERSION >= 0x040800 |
95 | app.setAttribute(Qt::AA_X11InitThreads, true); |
96 | #endif |
97 | |
98 | // then create the pixmap from an xpm: we cannot get the |
99 | // location of our datadir before we've started our components, |
100 | // so use an xpm. |
101 | QWidget *splash = new KisSplashScreen(aboutData->version(), QPixmap(splash_screen_xpm)); |
102 | app.setSplashScreen(splash); |
103 | |
104 | if (!app.start()) { |
105 | return 1; |
106 | } |
107 | |
108 | state = app.exec(); |
109 | |
110 | return state; |
111 | } |
112 | |
113 | |