File indexing completed on 2024-04-21 05:43:21

0001 /***************************************************************************
0002  *   Copyright (C) 2003-2005 by David Saxton                               *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #include "diagnosticstyle.h"
0012 #include "ktechlab.h"
0013 
0014 //#include <dcopclient.h>
0015 #include <ktechlab_version.h>
0016 
0017 #include <KAboutData>
0018 #include <KLocalizedString>
0019 
0020 #include <QApplication>
0021 #include <QCommandLineParser>
0022 #include <QDir>
0023 #include <QStandardPaths>
0024 
0025 int main(int argc, char **argv)
0026 {
0027     // enable high dpi support
0028     QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0029     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
0030 
0031     QApplication app(argc, argv);
0032     KLocalizedString::setApplicationDomain("ktechlab");
0033 
0034     KAboutData about(
0035         "ktechlab", i18n("KTechLab"), KTECHLAB_VERSION_STRING, i18n("An IDE for microcontrollers and electronics"), KAboutLicense::GPL_V2, i18n("(C) 2003-2017, The KTechLab developers"), "", "https://userbase.kde.org/KTechlab", "ktechlab-devel@kde.org");
0036     about.addAuthor(i18n("Alan Grimes"), i18n("Developer, Simulation"), "");
0037     about.addAuthor(i18n("Zoltan Padrah"), i18n("Developer"), "zoltan_padrah@users.sourceforge.net");
0038     about.addAuthor(i18n("Julian Bäume"), i18n("Developer, KDE4 Port, GUI"), "julian@svg4all.de");
0039     about.addAuthor(i18n("Juan De Vincenzo"), i18n("KDE4 Port"), "");
0040     about.addCredit(i18n("Lawrence Shafer"), i18n("Website, wiki and forum"), "");
0041     about.addCredit(i18n("Jason Lucas"), i18n("Keeping up the project during lack of developers"), "");
0042     about.addCredit(i18n("David Saxton"), i18n("Former developer, project founder, former maintainer"), "david@bluehaze.org");
0043     about.addCredit(i18n("Daniel Clarke"), i18n("Former developer"), "daniel.jc@gmail.com");
0044     about.addCredit(i18n("Couriousous"), i18n("JK flip-flop, asynchronous preset/reset in the D flip-flop"), "");
0045     about.addCredit(i18n("John Myers"), i18n("Rotary Switch"), "");
0046     about.addCredit(i18n("Ali Akcaagac"), i18n("Glib friendliness"), "");
0047     about.addCredit(i18n("David Leggett"), i18n("Former website hosting and feedback during early development"), "");
0048     KAboutData::setApplicationData(about);
0049     QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("ktechlab")));
0050 
0051     QCommandLineParser parser;
0052     about.setupCommandLine(&parser);
0053     // 2019.10.03 - note: to add options to set icon and caption of the
0054     //              application's window? currently this is not implemented
0055     //              but it had references in the .destop file
0056     parser.addPositionalArgument(QStringLiteral("url"), i18n("Document to open."), QStringLiteral("[url]"));
0057 
0058     parser.process(app);
0059     about.processCommandLine(&parser);
0060 
0061     // Add our custom icons to the search path
0062     const QStringList iconDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "ktechlab/icons", QStandardPaths::LocateDirectory);
0063     const QStringList picsDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "ktechlab/pics", QStandardPaths::LocateDirectory);
0064     QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << iconDirs);
0065     QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << iconDirs << picsDirs);
0066 
0067     if (true) { // TODO add a command line option for debugging the program's visual look
0068         // app.setStyle(new DiagnosticStyle());
0069     }
0070 
0071     // register ourselves as a dcop client
0072     // app.dcopClient()->registerAs(app.name(), false);
0073 
0074     KTechlab *ktechlab = new KTechlab();
0075 
0076     // 2019.10.03 - note: possibly add support for multiple URLs to be opened from
0077     //              command line?
0078     if (parser.positionalArguments().count() > 0) {
0079         const QUrl url = QUrl::fromUserInput(parser.positionalArguments().at(0), QDir::currentPath(), QUrl::AssumeLocalFile);
0080         ktechlab->load(url);
0081     }
0082 
0083     ktechlab->show();
0084     return app.exec();
0085 }