File indexing completed on 2024-04-14 03:46:42
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // SPDX-FileCopyrightText: 2014 Dennis Nienhüser <nienhueser@kde.org> 0006 // 0007 0008 #include "GameMainWindow.h" 0009 0010 #include <marble/MarbleDirs.h> 0011 #include <marble/MarbleDebug.h> 0012 #include <marble/MarbleLocale.h> 0013 #include <marble/MarbleGlobal.h> 0014 0015 #include <QApplication> 0016 #include <QDir> 0017 #include <QLocale> 0018 #include <QTranslator> 0019 #include <QDebug> 0020 0021 using namespace Marble; 0022 0023 int main(int argc, char *argv[]) 0024 { 0025 QApplication app(argc, argv); 0026 app.setApplicationName(QStringLiteral("Marble Game")); 0027 app.setOrganizationName(QStringLiteral("KDE")); 0028 app.setOrganizationDomain(QStringLiteral("kde.org")); 0029 // Widget translation 0030 0031 QString lang = QLocale::system().name().section(QLatin1Char('_'), 0, 0); 0032 QTranslator translator; 0033 translator.load(QLatin1String("marble-") + lang, MarbleDirs::path(QStringLiteral("lang"))); 0034 app.installTranslator(&translator); 0035 0036 // For non static builds on mac and win 0037 // we need to be sure we can find the qt image 0038 // plugins. In mac be sure to look in the 0039 // application bundle... 0040 0041 #ifdef Q_WS_WIN 0042 QApplication::addLibraryPath( QApplication::applicationDirPath() 0043 + QDir::separator() + QLatin1String("plugins")); 0044 #endif 0045 0046 QString marbleDataPath; 0047 int dataPathIndex=0; 0048 0049 QStringList args = QApplication::arguments(); 0050 0051 if (args.contains(QStringLiteral("-h")) || args.contains(QStringLiteral("--help"))) { 0052 qWarning() << "Usage: marble [options]"; 0053 qWarning(); 0054 qWarning() << "general options:"; 0055 qWarning() << " --marbledatapath=<path> .... Overwrite the compile-time path to map themes and other data"; 0056 qWarning(); 0057 qWarning() << "debug options:"; 0058 qWarning() << " --debug-info ............... write (more) debugging information to the console"; 0059 0060 return 0; 0061 } 0062 0063 for ( int i = 1; i < args.count(); ++i ) { 0064 const QString arg = args.at(i); 0065 0066 if ( arg == QLatin1String( "--debug-info" ) ) 0067 { 0068 MarbleDebug::setEnabled( true ); 0069 } 0070 else if ( arg.startsWith( QLatin1String( "--marbledatapath=" ), Qt::CaseInsensitive ) ) 0071 { 0072 marbleDataPath = args.at(i).mid(17); 0073 } 0074 else if ( arg.compare( QLatin1String( "--marbledatapath" ), Qt::CaseInsensitive ) == 0 && i+1 < args.size() ) { 0075 dataPathIndex = i + 1; 0076 marbleDataPath = args.value( dataPathIndex ); 0077 ++i; 0078 } 0079 } 0080 0081 MarbleLocale::MeasurementSystem const measurement = 0082 (MarbleLocale::MeasurementSystem)QLocale::system().measurementSystem(); 0083 MarbleGlobal::getInstance()->locale()->setMeasurementSystem( measurement ); 0084 0085 MainWindow *window = new MainWindow( marbleDataPath ); 0086 window->show(); 0087 return app.exec(); 0088 }