src/toolsets/extprogramtoolset.cpp

changeset 971
c00f9665a9f8
parent 970
c8aae45afd85
child 974
b2fa5f89798a
equal deleted inserted replaced
970:c8aae45afd85 971:c00f9665a9f8
22 #include <QDialogButtonBox> 22 #include <QDialogButtonBox>
23 #include <QSpinBox> 23 #include <QSpinBox>
24 #include <QCheckBox> 24 #include <QCheckBox>
25 #include <QComboBox> 25 #include <QComboBox>
26 #include <QGridLayout> 26 #include <QGridLayout>
27 #include <QSettings>
27 #include <QFileInfo> 28 #include <QFileInfo>
28 #include "../main.h" 29 #include "../main.h"
29 #include "../configuration.h"
30 #include "../miscallenous.h" 30 #include "../miscallenous.h"
31 #include "../mainwindow.h" 31 #include "../mainwindow.h"
32 #include "../ldDocument.h" 32 #include "../ldDocument.h"
33 #include "../radioGroup.h" 33 #include "../radioGroup.h"
34 #include "../editHistory.h" 34 #include "../editHistory.h"
58 58
59 ExtProgramToolset::ExtProgramToolset (MainWindow* parent) : 59 ExtProgramToolset::ExtProgramToolset (MainWindow* parent) :
60 Toolset (parent) 60 Toolset (parent)
61 { 61 {
62 extProgramInfo[Isecalc].name = "Isecalc"; 62 extProgramInfo[Isecalc].name = "Isecalc";
63 extProgramInfo[Isecalc].path = &m_config->isecalcPath;
64 extProgramInfo[Isecalc].wine = &m_config->isecalcUsesWine;
65 extProgramInfo[Intersector].name = "Intersector"; 63 extProgramInfo[Intersector].name = "Intersector";
66 extProgramInfo[Intersector].path = &m_config->intersectorPath;
67 extProgramInfo[Intersector].wine = &m_config->intersectorUsesWine;
68 extProgramInfo[Coverer].name = "Coverer"; 64 extProgramInfo[Coverer].name = "Coverer";
69 extProgramInfo[Coverer].path = &m_config->covererPath;
70 extProgramInfo[Coverer].wine = &m_config->covererUsesWine;
71 extProgramInfo[Ytruder].name = "Ytruder"; 65 extProgramInfo[Ytruder].name = "Ytruder";
72 extProgramInfo[Ytruder].path = &m_config->ytruderPath;
73 extProgramInfo[Ytruder].wine = &m_config->ytruderUsesWine;
74 extProgramInfo[Rectifier].name = "Rectifier"; 66 extProgramInfo[Rectifier].name = "Rectifier";
75 extProgramInfo[Rectifier].path = &m_config->rectifierPath;
76 extProgramInfo[Rectifier].wine = &m_config->rectifierUsesWine;
77 extProgramInfo[Edger2].name = "Edger2"; 67 extProgramInfo[Edger2].name = "Edger2";
78 extProgramInfo[Edger2].path = &m_config->edger2Path;
79 extProgramInfo[Edger2].wine = &m_config->edger2UsesWine;
80 } 68 }
81 69
82 bool ExtProgramToolset::makeTempFile (QTemporaryFile& tmp, QString& fname) 70 bool ExtProgramToolset::makeTempFile (QTemporaryFile& tmp, QString& fname)
83 { 71 {
84 if (not tmp.open()) 72 if (not tmp.open())
96 #else 84 #else
97 return false; 85 return false;
98 #endif 86 #endif
99 } 87 }
100 88
101 bool& ExtProgramToolset::getWineSetting (ExtProgramType program) 89 bool ExtProgramToolset::getWineSetting (ExtProgramType program)
102 { 90 {
103 return *extProgramInfo[program].wine; 91 return m_window->getConfigValue (externalProgramName (program) + "UsesWine").toBool();
104 } 92 }
105 93
106 QString ExtProgramToolset::getPathSetting (ExtProgramType program) 94 QString ExtProgramToolset::getPathSetting (ExtProgramType program)
107 { 95 {
108 return *extProgramInfo[program].path; 96 return m_window->getConfigValue (externalProgramName (program) + "Path").toString();
97 }
98
99 void ExtProgramToolset::setPathSetting (ExtProgramType program, QString value)
100 {
101 m_window->getSettings()->setValue (externalProgramName (program) + "Path", QVariant::fromValue (value));
102 }
103
104 void ExtProgramToolset::setWineSetting (ExtProgramType program, bool value)
105 {
106 m_window->getSettings()->setValue (externalProgramName (program) + "UsesWine", QVariant::fromValue (value));
109 } 107 }
110 108
111 QString ExtProgramToolset::externalProgramName (ExtProgramType program) 109 QString ExtProgramToolset::externalProgramName (ExtProgramType program)
112 { 110 {
113 return extProgramInfo[program].name; 111 return extProgramInfo[program].name;
114 } 112 }
115 113
116 QString ExtProgramToolset::checkExtProgramPath(ExtProgramType program) 114 bool ExtProgramToolset::checkExtProgramPath (ExtProgramType program)
117 { 115 {
118 QString& path = getPathSetting (program); 116 QString path = getPathSetting (program);
119 117
120 if (not path.isEmpty()) 118 if (not path.isEmpty())
121 return true; 119 return true;
122 120
123 ExtProgPathPrompt* dlg = new ExtProgPathPrompt (externalProgramName (program)); 121 ExtProgPathPrompt* dialog = new ExtProgPathPrompt (externalProgramName (program));
124 122
125 if (dlg->exec() and not dlg->getPath().isEmpty()) 123 if (dialog->exec() and not dialog->getPath().isEmpty())
126 { 124 {
127 path = dlg->getPath(); 125 setPathSetting (program, dialog->getPath());
128 return true; 126 return true;
129 } 127 }
130 128
131 return false; 129 return false;
132 } 130 }
390 condAngle, 388 condAngle,
391 inDATName, 389 inDATName,
392 outDATName 390 outDATName
393 }); 391 });
394 392
395 WriteSelection (inDATName); 393 writeSelection (inDATName);
396 394
397 if (not runExtProgram (Ytruder, argv)) 395 if (not runExtProgram (Ytruder, argv))
398 return; 396 return;
399 397
400 InsertOutput (outDATName, false, {}); 398 insertOutput (outDATName, false, {});
401 } 399 }
402 400
403 // ============================================================================= 401 // =============================================================================
404 // Rectifier interface 402 // Rectifier interface
405 // ============================================================================= 403 // =============================================================================
435 ui.dsb_coplthres->value(), 433 ui.dsb_coplthres->value(),
436 inDATName, 434 inDATName,
437 outDATName 435 outDATName
438 }); 436 });
439 437
440 WriteSelection (inDATName); 438 writeSelection (inDATName);
441 439
442 if (not runExtProgram (Rectifier, argv)) 440 if (not runExtProgram (Rectifier, argv))
443 return; 441 return;
444 442
445 InsertOutput (outDATName, true, {}); 443 insertOutput (outDATName, true, {});
446 } 444 }
447 445
448 // ============================================================================= 446 // =============================================================================
449 // Intersector interface 447 // Intersector interface
450 // ============================================================================= 448 // =============================================================================

mercurial