MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / main

Function main

src/main.cpp:126–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124
125
126int main(int argc, char** argv)
127{
128#ifdef MAPPER_USE_QTSINGLEAPPLICATION
129 // Create single-instance application.
130 // Use "oo-mapper" instead of the executable as identifier, in case we launch from different paths.
131 QtSingleApplication qapp(QString::fromLatin1("oo-mapper"), argc, argv);
132 if (qapp.isRunning()) {
133 // Send a message to activate the running app, and optionally open a file
134 auto const arguments = firstRemoved(QCoreApplication::arguments());
135 for (auto const& arg : arguments)
136 qapp.sendMessage(QFileInfo(arg).absoluteFilePath());
137 return 0;
138 }
139#else
140 QApplication qapp(argc, argv);
141#endif
142
143#ifdef Q_OS_ANDROID
144 qputenv("QT_USE_ANDROID_NATIVE_STYLE", "1");
145#endif
146
147 // Load resources
148 Q_INIT_RESOURCE(resources);
149
150 // QSettings on OS X benefits from using an internet domain here.
151 QCoreApplication::setOrganizationName(QString::fromLatin1("OpenOrienteering.org"));
152 QCoreApplication::setApplicationName(QString::fromLatin1("Mapper"));
153 QGuiApplication::setApplicationDisplayName(APP_NAME + QString::fromUtf8(" " APP_VERSION));
154
155#ifdef WIN32
156 // Load plugins on Windows
157 QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() + QLatin1String("/plugins"));
158#endif
159
160 MapperResource::setSeachPaths();
161
162 // Localization
163 QSettings settings;
164 TranslationUtil::setBaseName(QLatin1String("OpenOrienteering"));
165 TranslationUtil translation(settings);
166 QLocale::setDefault(QLocale(translation.code()));
167#if defined(Q_OS_MACOS)
168 // Normally this is done in Settings::apply() because it is too late here.
169 // But Mapper 0.6.2/0.6.3 accidentally wrote a string instead of a list. This
170 // error caused crashes when opening native dialogs (i.e. the open-file dialog!).
171 settings.setValue(QString::fromLatin1("AppleLanguages"), QStringList{ translation.code() });
172#endif
173#if defined(Mapper_DEBUG_TRANSLATIONS)
174 if (!translation.getAppTranslator().isEmpty())
175 {
176 // Debug translation only if there is a Mapper translation, i.e. not for English.
177 QCoreApplication::installTranslator(new RecordingTranslator());
178 }
179#endif
180 QCoreApplication::installTranslator(&translation.getQtTranslator());
181 QCoreApplication::installTranslator(&translation.getAppTranslator());
182 map_symbol_translator = translation.load(QString::fromLatin1("map_symbols")).release();
183 if (map_symbol_translator)

Callers

nothing calls this directly

Calls 15

firstRemovedFunction · 0.85
QLatin1StringClass · 0.85
setSeachPathsFunction · 0.85
doStaticInitializationsFunction · 0.85
resetActivationWindowFunction · 0.85
codeMethod · 0.80
setValueMethod · 0.80
setControllerMethod · 0.80
openPathLaterMethod · 0.80
QFileInfoClass · 0.50
isRunningMethod · 0.45

Tested by

no test coverage detected