File indexing completed on 2024-04-28 04:03:13

0001 /***************************************************************************
0002     File                 : main.cpp
0003     Project              : Knights
0004     Description          : main function
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2016-2017 Alexander Semke (alexander.semke@web.de)
0007     SPDX-FileCopyrightText: 2009-2011 Miha Čančula (miha@noughmad.eu)
0008 
0009  ***************************************************************************/
0010 
0011 /***************************************************************************
0012  *                                                                         *
0013  *  SPDX-License-Identifier: GPL-2.0-or-later
0014  *                                                                         *
0015  *  This program is distributed in the hope that it will be useful,        *
0016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0018  *  GNU General Public License for more details.                           *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the Free Software           *
0022  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0023  *   Boston, MA  02110-1301  USA                                           *
0024  *                                                                         *
0025  ***************************************************************************/
0026 
0027 
0028 #include "knights.h"
0029 #include "knights_version.h"
0030 
0031 #include <KAboutData>
0032 #include <KCrash>
0033 #include <KLocalizedString>
0034 
0035 #include <QApplication>
0036 #include <QCommandLineParser>
0037 
0038 static QString version = QStringLiteral ("2.6.0");
0039 
0040 int main ( int argc, char **argv ) {
0041     QApplication app(argc, argv);
0042 
0043     KLocalizedString::setApplicationDomain(QByteArrayLiteral("knights"));
0044     KCrash::initialize();
0045 
0046     KAboutData about ( QStringLiteral("knights"), i18n ( "Knights" ),
0047                        QStringLiteral(KNIGHTS_VERSION_STRING),
0048                        i18n( "KDE Chess Board" ),
0049                        KAboutLicense::GPL, i18n ( "(C) 2016-2017 Alexander Semke, 2009-2011 Miha Čančula" ),
0050                QString(),
0051                QStringLiteral("https://apps.kde.org/knights"));
0052     about.addAuthor(i18n("Alexander Semke"), QString(), QStringLiteral("alexander.semke@web.de"));
0053     about.addAuthor ( i18n ( "Miha Čančula" ), QString(), QStringLiteral ("miha@noughmad.eu"),
0054                       QStringLiteral ("https://noughmad.eu/"), QStringLiteral ("noughmad") );
0055     about.addCredit ( i18n ( "Troy Corbin" ), i18n ( "Original Knights for KDE3 and theme author" ),
0056                       QStringLiteral ("troy@pedanticwebspaces.com") );
0057     about.addCredit ( i18n ( "Dave Kaye" ), i18n ( "Help with new theme features and rendering without KGameRenderer" ) );
0058     about.addCredit ( i18n ( "Thomas Kamps" ), i18n ( "Clock displaying the remaining time" ),
0059                       QString(), QString(), QStringLiteral("cpttom") );
0060 
0061     app.setWindowIcon(QIcon::fromTheme(QStringLiteral("knights")));
0062     KAboutData::setApplicationData(about);
0063 
0064     QCommandLineParser parser;
0065     parser.addOption(QCommandLineOption( QStringLiteral ("+[URL]"), i18n ( "Document to open" ) ));
0066     about.setupCommandLine(&parser);
0067     parser.process(app);
0068     about.processCommandLine(&parser);
0069 
0070     // register types for connecting with Qt::QueuedConnection
0071     qRegisterMetaType<Knights::Color>("Color");
0072 
0073     // see if we are starting with session management
0074     if ( app.isSessionRestored() ) {
0075                 kRestoreMainWindows<Knights::MainWindow>();
0076     } else {
0077         // no session.. just start up normally
0078         if ( parser.positionalArguments().isEmpty() ) {
0079             Knights::MainWindow *widget = new Knights::MainWindow;
0080             widget->show();
0081         } else {
0082             int i = 0;
0083             for ( ; i < parser.positionalArguments().count(); i++ ) {
0084                 Knights::MainWindow *widget = new Knights::MainWindow;
0085                 widget->show();
0086             }
0087         }
0088     }
0089 
0090     return app.exec();
0091 }