main.cpp 6.67 KB
Newer Older
1
2
/***************************************************************************
 *   Copyright (C) 2003-2008 Carsten Niehaus <cniehaus@kde.org>            *
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 *                                                                         *
 *   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 Foundation, Inc.,                                       *
Carsten Niehaus's avatar
Carsten Niehaus committed
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
18
 ***************************************************************************/
19

20
#include <config-kalzium.h>
Yuri Chornoivan's avatar
Yuri Chornoivan committed
21

22
23
#include <QApplication>
#include <QCommandLineOption>
Yuri Chornoivan's avatar
Yuri Chornoivan committed
24
25
26
27
#include <QCommandLineParser>

#include <KAboutData>
#include <KLocalizedString>
28

Andreas Cord-Landwehr's avatar
Andreas Cord-Landwehr committed
29
#include "kalzium.h"
30
#include "kalzium_version.h"
31

32
#ifdef HAVE_FACILE
Laurent Montel's avatar
Laurent Montel committed
33
34
extern "C" {
         void caml_startup(char**);
Anne-Marie Mahfouf's avatar
Anne-Marie Mahfouf committed
35
}
36
37
#endif

38
int main(int argc, char **argv)
39
{
40
#ifdef HAVE_FACILE
Laurent Montel's avatar
Laurent Montel committed
41
   caml_startup(argv);
42
43
#endif

Johnny Jazeix's avatar
Johnny Jazeix committed
44
45
    QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
46
    QApplication app(argc, argv);
47
48
    KLocalizedString::setApplicationDomain("kalzium");

Laurent Montel's avatar
Laurent Montel committed
49
    KAboutData about(QStringLiteral("kalzium"),
50
                      i18n("Kalzium"),
51
                      QStringLiteral(KALZIUM_VERSION_STRING),
52
                      i18n("A periodic table of the elements"),
53
                      KAboutLicense::GPL,
54
                      i18n("(C) 2002-2016 Carsten Niehaus & the KDE Edu Developers"),
55
                      QString(),
56
                      QStringLiteral("https://edu.kde.org/kalzium"));
57

58
    about.addAuthor(i18n("Carsten Niehaus"),
59
                    QString(),
Laurent Montel's avatar
Laurent Montel committed
60
                    QStringLiteral("cniehaus@kde.org"));
61
62


63
64
    about.addCredit(i18n("Pino Toscano"),
                    i18n("Large code contributions; resident guru helping the other developers"));
65

66
67
    about.addCredit(i18n("Benoit Jacob"),
                    i18n("Base work on the molecular viewer, mentored Marcus during his SoC"));
68

69
70
    about.addCredit(i18n("Marcus Hanwell"),
                    i18n("SoC on the molecular viewer and libavogadro porting/integration"));
71

72
73
    about.addCredit(i18n("Kashyap R Puranik"),
                    i18n("SoC on the calculator widget and a few smaller improvements"));
74

75
76
    about.addCredit(i18n("Thomas Nagy"),
                    i18n("EqChem, the equation solver"));
77

78
79
    about.addCredit(i18n("Inge Wallin"),
                    i18n("Code cleaning, parser for the molecule weight calculator, and a lot of smaller improvements"));
80

81
82
    about.addCredit(i18n("Anne-Marie Mahfouf"),
                    i18n("A lot of small things and the documentation"));
83

84
85
    about.addCredit(i18n("Johannes Simon"),
                    i18n("Code and documentation contributions to the equation solver and molecular viewer"));
86

87
88
    about.addCredit(i18n("Jarle Akselsen"),
                    i18n("Many beautiful element icons"));
89

90
91
    about.addCredit(i18n("Noémie Scherer"),
                    i18n("Many beautiful element icons, too!"));
92

93
94
    about.addCredit(i18n("Danny Allen"),
                    i18n("Several icons"));
95

96
97
    about.addCredit(i18n("Lee Olson"),
                    i18n("Several icons in the information dialog"));
98

99
100
    about.addCredit(i18n("Jörg Buchwald"),
                    i18n("Contributed most isotope information"));
101

102
103
    about.addCredit(i18n("Marco Martin"),
                    i18n("Some icons and inspiration for others"));
104

105
106
    about.addCredit(i18n("Daniel Haas"),
                    i18n("The design of the information dialog"));
107

108
109
    about.addCredit(i18n("Brian Beck"),
                    i18n("The orbits icon"));
110

111
112
    about.addCredit(i18n("Paulo Cattai"),
                    i18n("New interface design and usability improvements"));
113

114
115
    about.addCredit(i18n("Danilo Balzaque"),
                    i18n("New interface design and usability improvements"));
116

117
118
    about.addCredit(i18n("Roberto Cunha"),
                    i18n("New interface design and usability improvements"));
119

120
121
    about.addCredit(i18n("Tadeu Araujo"),
                    i18n("New interface design and usability improvements"));
122

123
124
    about.addCredit(i18n("Tiago Porangaba"),
                    i18n("New interface design and usability improvements"));
125

126
127
    about.addCredit(i18n("Etienne Rebetez"),
                    i18n("Adding new sizable Periodic System"));
128
129


Laurent Montel's avatar
Laurent Montel committed
130
    QApplication::setApplicationName(QStringLiteral("kalzium"));
131
    QApplication::setApplicationVersion(KALZIUM_VERSION_STRING);
Laurent Montel's avatar
Laurent Montel committed
132
    QApplication::setOrganizationDomain(QStringLiteral("kde.org"));
133

Andreas Cord-Landwehr's avatar
Andreas Cord-Landwehr committed
134
135
    KAboutData::setApplicationData(about);

136
137
    QCommandLineParser parser;

138
    parser.addPositionalArgument(i18n("[molecule]"), i18n("Open the given molecule file"));
139

140
    QCommandLineOption moleculeOption(i18n("molecule"), i18n("Open the given molecule file"));
141
142
143
144
145
146
147
    parser.addOption(moleculeOption);

    about.setupCommandLine(&parser);
    parser.process(app);
    about.processCommandLine(&parser);

    #if defined(HAVE_OPENBABEL2) && defined(HAVE_EIGEN) && defined(HAVE_AVOGADRO)
Laurent Montel's avatar
Laurent Montel committed
148
    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("m") << QStringLiteral("molecule"), i18n("Open the given molecule file"), QStringLiteral("file")));
149
    #endif
150

151
    Kalzium *mainWin = nullptr;
152

153
    if (app.isSessionRestored()) {
154
        kRestoreMainWindows<Kalzium>();
155
    } else {
156
157
158
159
160
161
        // no session.. just start up normally

        /// @todo do something with the command line args here

        mainWin = new Kalzium();
        mainWin->show();
162

Laurent Montel's avatar
Laurent Montel committed
163
        const QStringList molecules = parser.values(QStringLiteral("molecule"));
164
        if (molecules.count() == 1) {
165
            mainWin->loadMolecule(molecules[0]);
166
        } else if (molecules.count() > 1) {
167
168
169
            QTextStream ts(stderr);
            ts << i18n("Can't open more than one molecule at a time");
        }
170
171
172
173
174

    }

    // mainWin has WDestructiveClose flag by default, so it will delete itself.
    return app.exec();
175
}