integrate "QET_ElementScaler" as external software

This commit is contained in:
plc-user
2024-08-19 09:19:28 +02:00
parent 1baf9db799
commit 85d10fc0e6
9 changed files with 376 additions and 118 deletions

View File

@@ -47,6 +47,7 @@
#include "../../newelementwizard.h"
#include "../editorcommands.h"
#include "../../dxf/dxftoelmt.h"
#include "../../qet_elementscaler/qet_elementscaler.h"
#include "../UndoCommand/openelmtcommand.h"
#include <QSettings>
@@ -1332,6 +1333,24 @@ void QETElementEditor::on_m_open_dxf_action_triggered()
DXF -> start(program,arguments);
}
void QETElementEditor::on_m_open_scaled_element_action_triggered()
{
#ifdef TODO_LIST
# pragma message("@TODO Merge 'Element-Scaling' code into QET")
# pragma message("https://github.com/plc-user/QET_ElementScaler")
#endif
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
QString program = (QDir::homePath() + "/Application Data/qet/QET_ElementScaler.exe");
#elif defined(Q_OS_MAC)
QString program = (QDir::homePath() + "/.qet/QET_ElementScaler.app");
#else
QString program = (QDir::homePath() + "/.qet/QET_ElementScaler");
#endif
QStringList arguments;
QProcess *ES = new QProcess(qApp);
ES -> start(program,arguments);
}
bool QETElementEditor::on_m_save_as_file_action_triggered()
{
// Check element before writing
@@ -1504,7 +1523,7 @@ void QETElementEditor::on_m_import_dxf_triggered()
{
QString file_path{QFileDialog::getOpenFileName(this,
QObject::tr("Importer un fichier dxf"),
"/home",
QDir::homePath(),
"DXF (*.dxf)")};
if (file_path.isEmpty()) {
return;
@@ -1524,3 +1543,26 @@ void QETElementEditor::on_m_import_dxf_triggered()
}
}
void QETElementEditor::on_m_import_scaled_element_triggered()
{
if (ElementScalerIsPresent(true, this))
{
QString file_path{QFileDialog::getOpenFileName(this,
tr("Importer un élément à redimensionner"),
QDir::homePath(),
tr("Éléments QElectroTech (*.elmt)"))};
if (file_path.isEmpty()) {
return;
}
const QByteArray array_{ElementScaler(file_path, this)};
if (array_.isEmpty()) {
return;
}
QDomDocument xml_;
xml_.setContent(array_);
m_elmt_scene->undoStack().push(new OpenElmtCommand(xml_, m_elmt_scene));
}
}

View File

@@ -87,6 +87,7 @@ class QETElementEditor : public QMainWindow
void on_m_open_action_triggered();
void on_m_open_from_file_action_triggered();
void on_m_open_dxf_action_triggered();
void on_m_open_scaled_element_action_triggered();
bool on_m_save_as_file_action_triggered();
void on_m_reload_action_triggered();
void on_m_quit_action_triggered();
@@ -111,6 +112,7 @@ class QETElementEditor : public QMainWindow
void on_m_donate_action_triggered();
void on_m_about_qt_action_triggered();
void on_m_import_dxf_triggered();
void on_m_import_scaled_element_triggered();
private:
bool canClose();

View File

@@ -35,6 +35,7 @@
<addaction name="m_new_action"/>
<addaction name="m_open_action"/>
<addaction name="m_open_from_file_action"/>
<addaction name="m_import_scaled_element"/>
<addaction name="m_import_dxf"/>
<addaction name="m_open_dxf_action"/>
<addaction name="m_save_action"/>
@@ -514,6 +515,15 @@
<string>Importer un dxf</string>
</property>
</action>
<action name="m_import_scaled_element">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/folder-open.png</normaloff>:/ico/22x22/folder-open.png</iconset>
</property>
<property name="text">
<string>importer un élément à redimensionner</string>
</property>
</action>
</widget>
<resources>
<include location="../../../qelectrotech.qrc"/>