main.cc 2.96 KB
Newer Older
1 2 3 4
/*
 *  main.cc - part of KImageShop
 *
 *  Copyright (c) 1999 Matthias Elter <me@kde.org>
Patrick Julien's avatar
Patrick Julien committed
5
 *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 *  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.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 */
Halla Rempt's avatar
Halla Rempt committed
20

Halla Rempt's avatar
Halla Rempt committed
21
#include <stdlib.h>
22 23 24 25

#include <QString>
#include <QPixmap>
#include <QDebug>
26 27
#include <QProcess>
#include <QProcessEnvironment>
Halla Rempt's avatar
Halla Rempt committed
28
#include <QDesktopServices>
29
#include <QDir>
30

31
#include <kcmdlineargs.h>
Halla Rempt's avatar
Halla Rempt committed
32
#include <ksycoca.h>
33
#include <kcrash.h>
34

35
#include <KoApplication.h>
36
#include <KoConfig.h>
37

38
#include <krita_export.h>
39

40
#include "data/splash/splash_screen.xpm"
41
#include "ui/kis_aboutdata.h"
Halla Rempt's avatar
Halla Rempt committed
42
#include "ui/kis_factory2.h"
43
#include "ui/kis_doc2.h"
44
#include "kis_splash_screen.h"
45

46
#if defined Q_OS_WIN
47
#include "stdlib.h"
Dmitry Kazakov's avatar
Dmitry Kazakov committed
48
#include <ui/input/wintab/kis_tablet_support_win.h>
49 50 51
#ifdef USE_BREAKPAD
    #include "kis_crash_handler.h"
#endif
52 53 54
#elif defined Q_WS_X11
#include <ui/input/wintab/kis_tablet_support_x11.h>

55 56
#endif

57 58
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
59
#ifdef Q_WS_X11
60 61 62
    if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
        setenv("QT_NO_GLIB", "1", true);
    }
63
#endif
64 65 66 67 68
#ifdef USE_BREAKPAD
    qputenv("KDE_DEBUG", "1");
    KisCrashHandler crashHandler;
    Q_UNUSED(crashHandler);
#endif
69

Cyrille Berger's avatar
Cyrille Berger committed
70
    int state;
Halla Rempt's avatar
Halla Rempt committed
71
    KAboutData *aboutData = KisFactory2::aboutData();
Cyrille Berger's avatar
Cyrille Berger committed
72 73

    KCmdLineArgs::init(argc, argv, aboutData);
74 75 76

    KCmdLineOptions options;
    options.add("+[file(s)]", ki18n("File(s) or URL(s) to open"));
Halla Rempt's avatar
Halla Rempt committed
77
    options.add( "hwinfo", ki18n( "Show some information about the hardware" ));
78
    KCmdLineArgs::addCmdLineOptions(options);
79

80
    // first create the application so we can create a  pixmap
81
    KoApplication app(KIS_MIME_TYPE);
82

83
#if defined Q_OS_WIN
84 85
    KisTabletSupportWin::init();
    app.setEventFilter(&KisTabletSupportWin::eventFilter);
86
    app.setAttribute(Qt::AA_DontShowIconsInMenus);
87 88 89
#elif defined Q_WS_X11
    KisTabletSupportX11::init();
    app.setEventFilter(&KisTabletSupportX11::eventFilter);
Dmitry Kazakov's avatar
Dmitry Kazakov committed
90
#endif
91

Dmitry Kazakov's avatar
Dmitry Kazakov committed
92
#if defined Q_WS_X11 && QT_VERSION >= 0x040800
93 94 95
    app.setAttribute(Qt::AA_X11InitThreads, true);
#endif

96 97
    // then create the pixmap from an xpm: we cannot get the
    // location of our datadir before we've started our components,
98
    // so use an xpm.
99
    QWidget *splash = new KisSplashScreen(aboutData->version(), QPixmap(splash_screen_xpm));
100 101 102
    app.setSplashScreen(splash);

    if (!app.start()) {
103
        return 1;
104 105
    }

Halla Rempt's avatar
Halla Rempt committed
106
    state = app.exec();
Cyrille Berger's avatar
Cyrille Berger committed
107 108

    return state;
109
}
Patrick Julien's avatar
Patrick Julien committed
110