diff options
| author | Al12rs <gabriel.cortesi@outlook.com> | 2018-04-06 21:35:15 +0200 |
|---|---|---|
| committer | Al12rs <gabriel.cortesi@outlook.com> | 2018-04-07 14:10:16 +0200 |
| commit | 5c39a762e68c3559438a622dbf747eb8bddec7ed (patch) | |
| tree | 7d74dc78c8b8f6cb0dcb24556fe9dd0dc6f076fc /src/main.cpp | |
| parent | a905ce130d0f1f4894f135660d9cf515788bb2ad (diff) | |
Allow MO2 shortcuts that open the indicated MO2 instance in the argument if the executable name is omitted.
This should be added after the MO2 exe path: ' "moshortcut://myInstanceName:" '. If there are caracters after the ":" then MO2 will assume that is an execuatble and will try to run it.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0464ca9a..fc332fe7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -561,36 +561,42 @@ int runApplication(MOApplication &application, SingleInstance &instance, // if we have a command line parameter, it is either a nxm link or
// a binary to start
- if (arguments.size() > 1) {
- if (MOShortcut shortcut{ arguments.at(1) }) {
- try {
- organizer.runShortcut(shortcut);
- return 0;
- } catch (const std::exception &e) {
- reportError(
- QObject::tr("failed to start shortcut: %1").arg(e.what()));
- return 1;
- }
- } else if (OrganizerCore::isNxmLink(arguments.at(1))) {
- qDebug("starting download from command line: %s",
- qPrintable(arguments.at(1)));
- organizer.externalMessage(arguments.at(1));
- } else {
- QString exeName = arguments.at(1);
- qDebug("starting %s from command line", qPrintable(exeName));
- arguments.removeFirst(); // remove application name (ModOrganizer.exe)
- arguments.removeFirst(); // remove binary name
- // pass the remaining parameters to the binary
- try {
- organizer.startApplication(exeName, arguments, QString(), QString());
- return 0;
- } catch (const std::exception &e) {
- reportError(
- QObject::tr("failed to start application: %1").arg(e.what()));
- return 1;
- }
- }
- }
+ if (arguments.size() > 1) {
+ if (MOShortcut shortcut{ arguments.at(1) }) {
+ if (shortcut.hasExecutable()) {
+ try {
+ organizer.runShortcut(shortcut);
+ return 0;
+ }
+ catch (const std::exception &e) {
+ reportError(
+ QObject::tr("failed to start shortcut: %1").arg(e.what()));
+ return 1;
+ }
+ }
+ }
+ else if (OrganizerCore::isNxmLink(arguments.at(1))) {
+ qDebug("starting download from command line: %s",
+ qPrintable(arguments.at(1)));
+ organizer.externalMessage(arguments.at(1));
+ }
+ else {
+ QString exeName = arguments.at(1);
+ qDebug("starting %s from command line", qPrintable(exeName));
+ arguments.removeFirst(); // remove application name (ModOrganizer.exe)
+ arguments.removeFirst(); // remove binary name
+ // pass the remaining parameters to the binary
+ try {
+ organizer.startApplication(exeName, arguments, QString(), QString());
+ return 0;
+ }
+ catch (const std::exception &e) {
+ reportError(
+ QObject::tr("failed to start application: %1").arg(e.what()));
+ return 1;
+ }
+ }
+ }
QPixmap pixmap(splashPath);
QSplashScreen splash(pixmap);
|
