|
|
|
@ -150,9 +150,21 @@ bool ScriptManager::runCommand(const QString& command) |
|
|
|
|
|
|
|
|
|
bool ScriptManager::loadFromFile(const QString& path) |
|
|
|
|
{ |
|
|
|
|
QFile f(path); |
|
|
|
|
auto fixedPath = path; |
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_LINUX) |
|
|
|
|
if (path[0] != '/') |
|
|
|
|
fixedPath = QStringLiteral("%1/%2").arg(LOCAL_PATH, path); |
|
|
|
|
#elif defined(Q_OS_WIN32) | defined(Q_OS_WIN64) |
|
|
|
|
if (path[1] != ':') |
|
|
|
|
fixedPath = QStringLiteral("%1/%2").arg(LOCAL_PATH, path); |
|
|
|
|
#else |
|
|
|
|
#error Unsupported platform! Update Script/Manager.cpp (ScriptManager::loadFromFile) accordingly. |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
QFile f(fixedPath); |
|
|
|
|
if (!f.open(QIODevice::ReadOnly)) { |
|
|
|
|
QMessageBox::warning(this, tr("Open script"), tr("Unable to open script file from\n%1").arg(path)); |
|
|
|
|
QMessageBox::warning(this, tr("Open script"), tr("Unable to open script file from\n%1").arg(fixedPath)); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
QByteArray data(f.readAll()); |
|
|
|
|