main.cpp 2.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 *   Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2,
 *   or (at your option) any later version, as published by the Free
 *   Software Foundation
 *
 *   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 Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */


21
#include "splashapp.h"
22
#include <QQuickWindow>
23

24
25
#include <QTextStream>

26
27
#include <kworkspace.h>

28
29
30
#include <iostream>
#include <unistd.h>

31
32
33
34
35
void logMessageHandler(QtMsgType type, const char *msg)
{
    QString txt;
    switch (type) {
    case QtDebugMsg:
36
        txt = QStringLiteral("Debug: %1").arg(msg);
37
        break;
David Edmundson's avatar
David Edmundson committed
38
39
40
    case QtInfoMsg:
        txt = QStringLiteral("Info: %1").arg(msg);
        break;
41
    case QtWarningMsg:
42
        txt = QStringLiteral("Warning: %1").arg(msg);
43
44
    break;
    case QtCriticalMsg:
45
        txt = QStringLiteral("Critical: %1").arg(msg);
46
47
    break;
    case QtFatalMsg:
48
        txt = QStringLiteral("Fatal: %1").arg(msg);
49
50
    break;
    }
51
    QFile outFile(QStringLiteral("/tmp/ksplash"));
52
53
54
55
56
    outFile.open(QIODevice::WriteOnly | QIODevice::Append);
    QTextStream ts(&outFile);
    ts << txt << '\n';
}

57
58
59
60
61
int main(int argc, char **argv)
{
    bool test = false;

    for (int i = 1; i < argc; i++) {
62
        if (strcmp("--test", argv[i]) == 0 || strcmp("--help", argv[i]) == 0)
63
64
            test = true;
    }
65
66
67
    //enable to send log output to /tmp/ksplash
    //which is useful for debugging
//     qInstallMsgHandler(myMessageHandler);
68
    KWorkSpace::detectPlatform(argc, argv);
69
    QQuickWindow::setDefaultAlphaBuffer(true);
70
71
72
73
74
    SplashApp app(argc, argv);

    return app.exec();
}