summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorEran Mizrahi <erasmux@gmail.com>2017-12-10 23:33:01 +0200
committerEran Mizrahi <erasmux@gmail.com>2017-12-10 23:33:01 +0200
commitd43f35f56bc2d9164b6fe9aa5591eef287bebe07 (patch)
tree6c9c953943d8657ea15f081ae7720da57cf2d241 /src/main.cpp
parentdb973f7422258399726f8e5223079b6919535fd5 (diff)
Run shortcuts using moshortcut:// to avoid command line problems
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 40224170..9b2afecc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -126,6 +126,16 @@ bool isNxmLink(const QString &link)
return link.startsWith("nxm://", Qt::CaseInsensitive);
}
+bool isMoShortcut(const QString &link)
+{
+ return link.startsWith("moshortcut://", Qt::CaseInsensitive);
+}
+
+QString moShortcutName(const QString &link)
+{
+ return link.mid(strlen("moshortcut://"));
+}
+
static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs)
{
if ((exceptionPtrs->ExceptionRecord->ExceptionCode < 0x80000000) // non-critical
@@ -467,7 +477,16 @@ 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 (isNxmLink(arguments.at(1))) {
+ if (isMoShortcut(arguments.at(1))) {
+ try {
+ organizer.runShortcut(moShortcutName(arguments.at(1)));
+ return 0;
+ } catch (const std::exception &e) {
+ reportError(
+ QObject::tr("failed to start shortcut: %1").arg(e.what()));
+ return 1;
+ }
+ } else if (isNxmLink(arguments.at(1))) {
qDebug("starting download from command line: %s",
qPrintable(arguments.at(1)));
organizer.externalMessage(arguments.at(1));