File indexing completed on 2024-04-21 03:41:44

0001 /*
0002     SPDX-FileCopyrightText: 2003-2008 Carsten Niehaus <cniehaus@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include <config-kalzium.h>
0008 
0009 #include <QApplication>
0010 #include <QCommandLineOption>
0011 #include <QCommandLineParser>
0012 
0013 #include <KAboutData>
0014 #include <KLocalizedString>
0015 
0016 #include "kalzium.h"
0017 #include "kalzium_version.h"
0018 
0019 #ifdef HAVE_FACILE
0020 extern "C" {
0021 void caml_startup(char **);
0022 }
0023 #endif
0024 
0025 int main(int argc, char **argv)
0026 {
0027 #ifdef HAVE_FACILE
0028     caml_startup(argv);
0029 #endif
0030 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0031     QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0032     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
0033 #endif
0034     QApplication app(argc, argv);
0035     KLocalizedString::setApplicationDomain("kalzium");
0036 
0037     KAboutData about(QStringLiteral("kalzium"),
0038                      i18n("Kalzium"),
0039                      QStringLiteral(KALZIUM_VERSION_STRING),
0040                      i18n("A periodic table of the elements"),
0041                      KAboutLicense::GPL,
0042                      i18n("(C) 2002-2016 Carsten Niehaus & the KDE Edu Developers"),
0043                      QString(),
0044                      QStringLiteral("https://edu.kde.org/kalzium"));
0045 
0046     about.addAuthor(i18n("Carsten Niehaus"), QString(), QStringLiteral("cniehaus@kde.org"));
0047 
0048     about.addCredit(i18n("Pino Toscano"), i18n("Large code contributions; resident guru helping the other developers"));
0049 
0050     about.addCredit(i18n("Benoit Jacob"), i18n("Base work on the molecular viewer, mentored Marcus during his SoC"));
0051 
0052     about.addCredit(i18n("Marcus Hanwell"), i18n("SoC on the molecular viewer and libavogadro porting/integration"));
0053 
0054     about.addCredit(i18n("Kashyap R Puranik"), i18n("SoC on the calculator widget and a few smaller improvements"));
0055 
0056     about.addCredit(i18n("Thomas Nagy"), i18n("EqChem, the equation solver"));
0057 
0058     about.addCredit(i18n("Inge Wallin"), i18n("Code cleaning, parser for the molecule weight calculator, and a lot of smaller improvements"));
0059 
0060     about.addCredit(i18n("Anne-Marie Mahfouf"), i18n("A lot of small things and the documentation"));
0061 
0062     about.addCredit(i18n("Johannes Simon"), i18n("Code and documentation contributions to the equation solver and molecular viewer"));
0063 
0064     about.addCredit(i18n("Jarle Akselsen"), i18n("Many beautiful element icons"));
0065 
0066     about.addCredit(i18n("Noémie Scherer"), i18n("Many beautiful element icons, too!"));
0067 
0068     about.addCredit(i18n("Danny Allen"), i18n("Several icons"));
0069 
0070     about.addCredit(i18n("Lee Olson"), i18n("Several icons in the information dialog"));
0071 
0072     about.addCredit(i18n("Jörg Buchwald"), i18n("Contributed most isotope information"));
0073 
0074     about.addCredit(i18n("Marco Martin"), i18n("Some icons and inspiration for others"));
0075 
0076     about.addCredit(i18n("Daniel Haas"), i18n("The design of the information dialog"));
0077 
0078     about.addCredit(i18n("Brian Beck"), i18n("The orbits icon"));
0079 
0080     about.addCredit(i18n("Paulo Cattai"), i18n("New interface design and usability improvements"));
0081 
0082     about.addCredit(i18n("Danilo Balzaque"), i18n("New interface design and usability improvements"));
0083 
0084     about.addCredit(i18n("Roberto Cunha"), i18n("New interface design and usability improvements"));
0085 
0086     about.addCredit(i18n("Tadeu Araujo"), i18n("New interface design and usability improvements"));
0087 
0088     about.addCredit(i18n("Tiago Porangaba"), i18n("New interface design and usability improvements"));
0089 
0090     about.addCredit(i18n("Etienne Rebetez"), i18n("Adding new sizable Periodic System"));
0091 
0092     QApplication::setApplicationName(QStringLiteral("kalzium"));
0093     QApplication::setApplicationVersion(KALZIUM_VERSION_STRING);
0094     QApplication::setOrganizationDomain(QStringLiteral("kde.org"));
0095     QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kalzium")));
0096 
0097     KAboutData::setApplicationData(about);
0098 
0099     QCommandLineParser parser;
0100 
0101 #if defined(HAVE_OPENBABEL) && defined(HAVE_EIGEN) && defined(HAVE_AVOGADRO)
0102     parser.addOption(
0103         QCommandLineOption(QStringList() << QStringLiteral("m") << QStringLiteral("molecule"), i18n("Open the given molecule file"), QStringLiteral("file")));
0104 #endif
0105     about.setupCommandLine(&parser);
0106     parser.process(app);
0107     about.processCommandLine(&parser);
0108 
0109     Kalzium *mainWin = nullptr;
0110 
0111     if (app.isSessionRestored()) {
0112         kRestoreMainWindows<Kalzium>();
0113     } else {
0114         // no session.. just start up normally
0115 
0116         /// @todo do something with the command line args here
0117 
0118         mainWin = new Kalzium();
0119         mainWin->show();
0120 #if defined(HAVE_OPENBABEL) && defined(HAVE_EIGEN) && defined(HAVE_AVOGADRO)
0121         const QStringList molecules = parser.values(QStringLiteral("molecule"));
0122         if (molecules.count() == 1) {
0123             mainWin->loadMolecule(molecules[0]);
0124         } else if (molecules.count() > 1) {
0125             QTextStream ts(stderr);
0126             ts << i18n("Can't open more than one molecule at a time");
0127         }
0128 #endif
0129     }
0130 
0131     // mainWin has WDestructiveClose flag by default, so it will delete itself.
0132     return app.exec();
0133 }