main.cpp 4.06 KB
Newer Older
Ian Monroe's avatar
Ian Monroe committed
1 2 3
/***********************************************************************
 * Copyright 2004  Max Howell <max.howell@methylblue.com>
 *           2007  Ian Monroe <ian@monroe.nu>
Lukáš Tinkl's avatar
Lukáš Tinkl committed
4
 * Copyright 2014 Lukáš Tinkl <lukas@kde.org>
Ian Monroe's avatar
Ian Monroe committed
5 6 7 8 9 10
 *
 * 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) version 3 or any later version
 * accepted by the membership of KDE e.V. (or its successor approved
11
 * by the membership of KDE e.V.), which shall act as a proxy
Ian Monroe's avatar
Ian Monroe committed
12 13 14 15 16 17 18 19 20 21
 * defined in Section 14 of version 3 of the license.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 ***********************************************************************/
22
#include "codeine.h"
23
#include "playerApplication.h"
24

Lukáš Tinkl's avatar
Lukáš Tinkl committed
25 26 27 28
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
29 30
#include <QDir>
#include <QUrl>
Lukáš Tinkl's avatar
Lukáš Tinkl committed
31

Ian Monroe's avatar
Ian Monroe committed
32
#include <KAboutData>
Anthony Fieroni's avatar
Anthony Fieroni committed
33
#include <KConfigGroup>
34
#include <KCrash>
Anthony Fieroni's avatar
Anthony Fieroni committed
35
#include <KSharedConfig>
Ian Monroe's avatar
Ian Monroe committed
36
#include <KLocalizedString>
Lukáš Tinkl's avatar
Lukáš Tinkl committed
37
#include <KDBusService>
38

Lukáš Tinkl's avatar
Lukáš Tinkl committed
39
int main( int argc, char **argv )
40
{
Lukáš Tinkl's avatar
Lukáš Tinkl committed
41 42
    Dragon::PlayerApplication app(argc, argv);
    app.setOrganizationDomain("org.kde");
43
    KCrash::initialize();
Lukáš Tinkl's avatar
Lukáš Tinkl committed
44

45 46
    KLocalizedString::setApplicationDomain("dragonplayer");

47
    KAboutData aboutData( APP_NAME, i18n("Dragon Player"), QLatin1Literal(APP_VERSION),
Lukáš Tinkl's avatar
Lukáš Tinkl committed
48 49 50 51
                          i18n("A video player that has a usability focus"), KAboutLicense::GPL_V2,
                          i18n("Copyright 2006, Max Howell\nCopyright 2007, Ian Monroe"),
                          i18n("IRC:\nirc.freenode.net #dragonplayer\n\nFeedback:\nimonroe@kde.org"),
                          "http://multimedia.kde.org" );
Harald Sitter's avatar
Harald Sitter committed
52
    aboutData.setDesktopFileName(QStringLiteral("org.kde.dragonplayer"));
Lukáš Tinkl's avatar
Lukáš Tinkl committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    aboutData.addCredit( QStringLiteral("David Edmundson"), i18n("Improvements and polish") );
    aboutData.addCredit( QStringLiteral("Matthias Kretz"), i18n("Creator of Phonon") );
    aboutData.addCredit( QStringLiteral("Eugene Trounev"), i18n("Dragon Player icon") );
    aboutData.addCredit( QStringLiteral("Mike Diehl"), i18n("Handbook") );
    aboutData.addCredit( QStringLiteral("The Kaffeine Developers"), i18n("Great reference code") );
    aboutData.addCredit( QStringLiteral("Greenleaf"), i18n("Yatta happened to be the only video on my laptop to test with. :)") );
    aboutData.addCredit( QStringLiteral("Eike Hein"), i18n("MPRIS v2 support") );
    aboutData.addCredit( QStringLiteral("Lukáš Tinkl"), i18n("Port to KF5/Plasma 5"), QStringLiteral("lukas@kde.org") );

    KAboutData::setApplicationData(aboutData);

    QCommandLineParser parser;
    aboutData.setupCommandLine(&parser);

    parser.addOption(QCommandLineOption("play-dvd", i18n("Play DVD Video")));
    parser.addPositionalArgument("url", i18n("Play 'URL'"), QStringLiteral("+[URL]"));

    parser.process(app);
    aboutData.processCommandLine(&parser);

Anthony Fieroni's avatar
Anthony Fieroni committed
73 74
    const bool multiple = KSharedConfig::openConfig()->group("KDE").readEntry("MultipleInstances", QVariant(false)).toBool();
    KDBusService service(multiple ? KDBusService::Multiple : KDBusService::Unique);
Lukáš Tinkl's avatar
Lukáš Tinkl committed
75 76 77 78 79 80
    QObject::connect(&service, &KDBusService::activateRequested, &app, &Dragon::PlayerApplication::slotActivateRequested);
    QObject::connect(&service, &KDBusService::openRequested, &app, &Dragon::PlayerApplication::slotOpenRequested);

    QList<QUrl> urls;
    const QStringList args = parser.positionalArguments();
    if (!args.isEmpty()) {
81 82 83
        urls.append(QUrl::fromUserInput(args.first(),
                                        QDir::currentPath(),
                                        QUrl::AssumeLocalFile));
Lukáš Tinkl's avatar
Lukáš Tinkl committed
84 85 86 87 88
    }

    app.newInstance(parser.isSet("play-dvd"), urls);

    return app.exec();
89
}