| 215 | } |
| 216 | |
| 217 | Application::Application(int& argc, char** argv) : QApplication(argc, argv) |
| 218 | { |
| 219 | #if defined Q_OS_WIN32 |
| 220 | // attach the parent console if stdout not already captured |
| 221 | if (AttachWindowsConsole()) { |
| 222 | consoleAttached = true; |
| 223 | } |
| 224 | #endif |
| 225 | setOrganizationName(BuildConfig.LAUNCHER_NAME); |
| 226 | setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN); |
| 227 | setApplicationName(BuildConfig.LAUNCHER_NAME); |
| 228 | setApplicationDisplayName(QString("%1 %2").arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString())); |
| 229 | setApplicationVersion(BuildConfig.printableVersionString() + "\n" + BuildConfig.GIT_COMMIT); |
| 230 | setDesktopFileName(BuildConfig.LAUNCHER_DESKTOPFILENAME); |
| 231 | m_startTime = QDateTime::currentDateTime(); |
| 232 | |
| 233 | // Don't quit on hiding the last window |
| 234 | this->setQuitOnLastWindowClosed(false); |
| 235 | this->setQuitLockEnabled(false); |
| 236 | |
| 237 | // Commandline parsing |
| 238 | QCommandLineParser parser; |
| 239 | parser.setApplicationDescription(BuildConfig.LAUNCHER_DISPLAYNAME); |
| 240 | |
| 241 | parser.addOptions( |
| 242 | { { { "d", "dir" }, "Use a custom path as application root (use '.' for current directory)", "directory" }, |
| 243 | { { "l", "launch" }, "Launch the specified instance (by instance ID)", "instance" }, |
| 244 | { { "s", "server" }, "Join the specified server on launch (only valid in combination with --launch)", "address" }, |
| 245 | { { "w", "world" }, "Join the specified world on launch (only valid in combination with --launch)", "world" }, |
| 246 | { { "a", "profile" }, "Use the account specified by its profile name (only valid in combination with --launch)", "profile" }, |
| 247 | { "alive", "Write a small '" + liveCheckFile + "' file after the launcher starts" }, |
| 248 | { { "I", "import" }, "Import instance or resource from specified local path or URL", "url" }, |
| 249 | { "show", "Opens the window for the specified instance (by instance ID)", "show" } }); |
| 250 | // Has to be positional for some OS to handle that properly |
| 251 | parser.addPositionalArgument("URL", "Import the resource(s) at the given URL(s) (same as -I / --import)", "[URL...]"); |
| 252 | |
| 253 | parser.addHelpOption(); |
| 254 | parser.addVersionOption(); |
| 255 | |
| 256 | parser.process(arguments()); |
| 257 | |
| 258 | m_instanceIdToLaunch = parser.value("launch"); |
| 259 | m_serverToJoin = parser.value("server"); |
| 260 | m_worldToJoin = parser.value("world"); |
| 261 | m_profileToUse = parser.value("profile"); |
| 262 | m_liveCheck = parser.isSet("alive"); |
| 263 | |
| 264 | m_instanceIdToShowWindowOf = parser.value("show"); |
| 265 | |
| 266 | for (auto url : parser.values("import")) { |
| 267 | m_urlsToImport.append(normalizeImportUrl(url)); |
| 268 | } |
| 269 | |
| 270 | // treat unspecified positional arguments as import urls |
| 271 | for (auto url : parser.positionalArguments()) { |
| 272 | m_urlsToImport.append(normalizeImportUrl(url)); |
| 273 | } |
| 274 |
nothing calls this directly
no test coverage detected