main.cpp 2.96 KB
Newer Older
1 2 3
/*
 *  main.cpp
 *  Program:  kalarm
4
 *  Copyright © 2001-2017 by David Jarvie <djarvie@kde.org>
5 6 7 8 9
 *
 *  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.
David Jarvie's avatar
David Jarvie committed
10 11 12 13 14 15
 *
 *  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.
 *
David Jarvie's avatar
David Jarvie committed
16 17 18
 *  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.
19 20 21 22
 */

#include "kalarm.h"

23
#include "kalarmapp.h"
David Jarvie's avatar
David Jarvie committed
24
#include "kalarm_debug.h"
25

Laurent Montel's avatar
Laurent Montel committed
26
#include <kalarmcal/version.h>
David Jarvie's avatar
David Jarvie committed
27

David Jarvie's avatar
David Jarvie committed
28
#include <KAboutData>
Laurent Montel's avatar
Laurent Montel committed
29
#include <KLocalizedString>
David Jarvie's avatar
David Jarvie committed
30 31

#include <QDir>
Palo Kisa's avatar
Palo Kisa committed
32
#include <QScopedPointer>
33

34
#include <iostream>
35
#include <stdlib.h>
36

David Jarvie's avatar
David Jarvie committed
37
#define PROGRAM_NAME "kalarm"
38

David Jarvie's avatar
Tidy  
David Jarvie committed
39
int main(int argc, char* argv[])
40
{
Palo Kisa's avatar
Palo Kisa committed
41 42 43 44
    // Use QScopedPointer to ensure the QCoreApplication instance is deleted
    // before libraries unload, to avoid crashes during clean-up.
    QScopedPointer<KAlarmApp> app(KAlarmApp::create(argc, argv));

45
    const QStringList args = app->arguments();
David Jarvie's avatar
David Jarvie committed
46
    app->setAttribute(Qt::AA_UseHighDpiPixmaps, true);
Laurent Montel's avatar
Laurent Montel committed
47
    app->setAttribute(Qt::AA_EnableHighDpiScaling);
Laurent Montel's avatar
Laurent Montel committed
48
    app->setDesktopFileName(QStringLiteral("org.kde.kalarm"));
David Jarvie's avatar
David Jarvie committed
49

Laurent Montel's avatar
Laurent Montel committed
50
    KLocalizedString::setApplicationDomain("kalarm");
David Jarvie's avatar
David Jarvie committed
51 52
    KAboutData aboutData(QStringLiteral(PROGRAM_NAME), i18n("KAlarm"),
                         QStringLiteral(KALARM_VERSION),
53
                         i18n("Personal alarm message, command and email scheduler by KDE"),
David Jarvie's avatar
David Jarvie committed
54
                         KAboutLicense::GPL,
55
                         ki18n("Copyright 2001-%1, David Jarvie").subs(2017).toString(), QString(),
David Jarvie's avatar
David Jarvie committed
56 57
                         QStringLiteral("http://www.astrojar.org.uk/kalarm"));
    aboutData.addAuthor(i18n("David Jarvie"), i18n("Author"), QStringLiteral("djarvie@kde.org"));
58
    aboutData.setOrganizationDomain("kde.org");
David Jarvie's avatar
David Jarvie committed
59
    KAboutData::setApplicationData(aboutData);
60

Laurent Montel's avatar
Laurent Montel committed
61
    qCDebug(KALARM_LOG) << "initialising";
David Jarvie's avatar
David Jarvie committed
62

63 64 65 66 67 68 69 70 71 72 73
    QString outputText;
    int exitCode = app->activate(args, QDir::currentPath(), outputText);
    if (exitCode >= 0)
    {
        if (exitCode > 0)
            std::cout << qPrintable(outputText) << std::endl;
        else
            std::cerr << qPrintable(outputText) << std::endl;
        exit(exitCode);
    }

74 75
    app->restoreSession();
    return app->exec();
76
}
77 78 79 80 81 82 83 84 85

namespace KAlarm
{

/******************************************************************************
* Return the current KAlarm version number.
*/
int Version()
{
86 87
    static int version = 0;
    if (!version)
Laurent Montel's avatar
Laurent Montel committed
88
        version = KAlarmCal::getVersionNumber(QStringLiteral(KALARM_VERSION));
89
    return version;
90 91 92
}

} // namespace KAlarm
93 94

// vim: et sw=4: