Skip to content

Commit

Permalink
Test with hardcoded editor path
Browse files Browse the repository at this point in the history
  • Loading branch information
samamou committed Dec 27, 2024
1 parent 13487a2 commit 34af3bf
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/plugins/score-lib-process/Process/Script/ScriptEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QCodeEditor>
#include <QDialogButtonBox>
#include <QFile>
#include <QMessageBox>
#include <QPlainTextEdit>
#include <QProcess>
#include <QPushButton>
Expand Down Expand Up @@ -54,7 +55,8 @@ ScriptDialog::ScriptDialog(
&QDialog::close);

auto openExternalBtn = new QPushButton{tr("Open in external editor.."), this};
connect(openExternalBtn, &QPushButton::clicked, this, [this] {});
connect(
openExternalBtn, &QPushButton::clicked, this, [this] { openInExternalEditor(); });
lay->addWidget(openExternalBtn);
}

Expand Down Expand Up @@ -156,4 +158,30 @@ void MultiScriptDialog::clearError()
m_error->clear();
}

void ScriptDialog::openInExternalEditor() { }
void ScriptDialog::openInExternalEditor()
{
QString editorPath
= "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";

if(editorPath.isEmpty())
{
QMessageBox::warning(
this, tr("Error"), tr("no 'Default editor' configured in score settings"));
return;
}

QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QString tempFile = tempDir + "/ossia_script_temp.js";

QFile file(tempFile);

QTextStream stream(&file);
stream << "Temporary file content for testing.";
file.close();

if(!QProcess::startDetached(editorPath, QStringList() << tempFile))
{
QMessageBox::warning(this, tr("Error"), tr("Failed to launch external editor"));
}
}
}

0 comments on commit 34af3bf

Please sign in to comment.