Skip to content

Commit

Permalink
Remove parameters for launching thonny in macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Bonani authored Jun 29, 2022
1 parent 3a1eb77 commit 92b0354
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aseba/launcher/src/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ Q_INVOKABLE bool Launcher::platformHasSerialPorts() const {

#ifdef Q_OS_MACOS
bool Launcher::launchOsXBundle(const QString& name, const QVariantMap& args) const {
return doLaunchOsXBundle(name, args);
if (name=="Thonny")
return doLaunchThonnyBundle();
else
return doLaunchOsXBundle(name, args);
}
#endif
#ifdef Q_OS_IOS
Expand Down
1 change: 1 addition & 0 deletions aseba/launcher/src/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Launcher : public QObject {

#ifdef Q_OS_OSX
bool doLaunchPlaygroundBundle() const;
bool doLaunchThonnyBundle() const;
#endif
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
Q_INVOKABLE void applicationStateChanged(Qt::ApplicationState state);
Expand Down
14 changes: 14 additions & 0 deletions aseba/launcher/src/launcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,21 @@ auto QStringListToNSArray(const QStringList &list)
options:NSWorkspaceLaunchNewInstance
configuration:@{} error:nil];
return true;
}

bool Launcher::doLaunchThonnyBundle() const {
const auto path = QDir(QCoreApplication::applicationDirPath() +
QStringLiteral("/../Applications/Thonny.app")).absolutePath();
auto* bundle = [NSBundle bundleWithPath:path.toNSString()];
if(!bundle) {
NSLog(@"Unable to find the bundle");
return false;
}
auto ws = [NSWorkspace sharedWorkspace];
[ws launchApplicationAtURL:[bundle bundleURL]
options:NSWorkspaceLaunchNewInstance
configuration:@{} error:nil];
return true;
}

bool Launcher::doLaunchOsXBundle(const QString& name, const QVariantMap &args) const {
Expand Down

0 comments on commit 92b0354

Please sign in to comment.