Compare commits

..

7 Commits

Author SHA1 Message Date
Laurent Trinques 2c8797415c Merge pull request #335 from plc-user/master
rewrite code for executing “qet_tb_generator” plugin
2025-01-30 10:20:24 +01:00
plc-user 8162da1515 reorder search-paths and added currentPath() 2025-01-30 08:30:11 +01:00
plc-user 3cadc9275e improve readability 2025-01-30 07:25:30 +01:00
plc-user a459029f0d simplify code even more... 2025-01-30 00:15:09 +01:00
plc-user 9dda9f890f close the process in any case 2025-01-29 22:27:56 +01:00
plc-user 9be2ed604e moved "#endif" to always close process and adjusted qInfo-Text 2025-01-29 22:15:36 +01:00
plc-user a450680f6e rewrite code for executing “qet_tb_generator” plugin
Now it's better readable and maintainable up to the moment
we have our own internal Terminal-Manager for productive use.
Additionally added the storage location “dataDir()/binary”,
so that the new structure for the separation of
configuration and data can be properly kept
2025-01-29 21:57:38 +01:00
+36 -41
View File
@@ -2353,55 +2353,50 @@ void QETDiagramEditor::generateTerminalBlock()
# pragma message("https://github.com/qelectrotech/qet_tb_generator")
#endif
bool success;
bool success = false;
QList<QString> exeList;
QProcess *process = new QProcess(qApp);
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
exeList << (QETApp::dataDir() + "/binary/qet_tb_generator.exe")
<< (QDir::currentPath() + "/qet_tb_generator.exe")
<< QStandardPaths::findExecutable("qet_tb_generator.exe")
<< (QDir::homePath() + "/Application Data/qet/qet_tb_generator.exe")
<< "qet_tb_generator.exe"
<< "qet_tb_generator"; // from original code: missing ".exe" ???
#elif defined(Q_OS_MACOS)
exeList << (QETApp::dataDir() + "/binary/qet_tb_generator")
<< (QDir::currentPath() + "/qet_tb_generator")
<< QStandardPaths::findExecutable("qet_tb_generator")
<< (QDir::homePath() + "/.qet/qet_tb_generator.app")
<< "/Library/Frameworks/Python.framework/Versions/3.11/bin/qet_tb_generator";
#else
exeList << (QETApp::dataDir() + "/binary/qet_tb_generator")
<< (QDir::currentPath() + "/qet_tb_generator")
<< (QDir::homePath() + "/.qet/qet_tb_generator")
<< QStandardPaths::findExecutable("qet_tb_generator")
<< "qet_tb_generator";
#endif
// If launched under control:
//connect(process, SIGNAL(errorOcurred(int error)), this, SLOT(slot_generateTerminalBlock_error()));
//process->start("qet_tb_generator");
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
if (openedProjects().count()){
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
else {
success = process->startDetached("qet_tb_generator", {("")});
}
if (openedProjects().count()){
success = process->startDetached(QDir::homePath() + "/Application Data/qet/qet_tb_generator.exe", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
else {
success = process->startDetached(QDir::homePath() + "/Application Data/qet/qet_tb_generator.exe", {("")});
}
if (openedProjects().count()){
success = process->startDetached(QDir::homePath() + "/qet_tb_generator.exe", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
else {
success = process->startDetached(QDir::homePath() + "/qet_tb_generator.exe", {("")});
}
qInfo() << " project to use for qet_tb_generator: "
<< (QETDiagramEditor::currentProjectView()->project()->filePath());
if (openedProjects().count()) {
foreach(QString exe, exeList) {
qInfo() << " success so far: " << success << " - now searching for " << exe;
if ((success == false) && exe.length() && QFile::exists(exe)) {
success = process->startDetached(exe, {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
}
} else {
qInfo() << "No project loaded - no need to start \"qet_tb_generator\"";
}
process->close();
#elif defined(Q_OS_MACOS)
if (openedProjects().count()){
success = process->startDetached("/Library/Frameworks/Python.framework/Versions/3.11/bin/qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
else {
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
#else
if (openedProjects().count()){
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
else {
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
}
#endif
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
QString message=QObject::tr(
"To install the plugin qet_tb_generator"