Added arguments to dialog and script call.
This commit is contained in:
parent
e008ca6f87
commit
f0f39f9c53
|
@ -95,16 +95,16 @@ private:
|
|||
QFileInfo fileInfo = list.at(i);
|
||||
scripts.push_back(fileInfo.baseName().toStdString());
|
||||
}
|
||||
std::string selected;
|
||||
std::string processor;
|
||||
PathGui::DlgProcessorChooser Dlg(scripts);
|
||||
if (Dlg.exec() != QDialog::Accepted) {
|
||||
return Py::None();
|
||||
}
|
||||
selected = Dlg.getSelected();
|
||||
|
||||
processor = Dlg.getProcessor();
|
||||
|
||||
std::ostringstream pre;
|
||||
std::ostringstream cmd;
|
||||
if (selected.empty()) {
|
||||
if (processor.empty()) {
|
||||
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
|
||||
Gui::Command::runCommand(Gui::Command::Gui,"import Path");
|
||||
cmd << "Path.read(\"" << EncodedName << "\",\"" << pcDoc->getName() << "\")";
|
||||
|
@ -112,14 +112,14 @@ private:
|
|||
} else {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
QFileInfo fileInfo = list.at(i);
|
||||
if (fileInfo.baseName().toStdString() == selected) {
|
||||
if (fileInfo.baseName().toStdString() == processor) {
|
||||
if (fileInfo.absoluteFilePath().contains(QString::fromLatin1("PathScripts"))) {
|
||||
pre << "from PathScripts import " << selected;
|
||||
pre << "from PathScripts import " << processor;
|
||||
} else {
|
||||
pre << "import " << selected;
|
||||
pre << "import " << processor;
|
||||
}
|
||||
Gui::Command::runCommand(Gui::Command::Gui,pre.str().c_str());
|
||||
cmd << selected << ".open(\"" << EncodedName << "\")";
|
||||
cmd << processor << ".open(\"" << EncodedName << "\")";
|
||||
Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -162,12 +162,12 @@ private:
|
|||
QFileInfo fileInfo = list.at(i);
|
||||
scripts.push_back(fileInfo.baseName().toStdString());
|
||||
}
|
||||
std::string selected;
|
||||
std::string processor;
|
||||
PathGui::DlgProcessorChooser Dlg(scripts);
|
||||
if (Dlg.exec() != QDialog::Accepted) {
|
||||
return Py::None();
|
||||
}
|
||||
selected = Dlg.getSelected();
|
||||
processor = Dlg.getProcessor();
|
||||
|
||||
App::Document *pcDoc = 0;
|
||||
if (DocName)
|
||||
|
@ -181,21 +181,21 @@ private:
|
|||
|
||||
std::ostringstream pre;
|
||||
std::ostringstream cmd;
|
||||
if (selected.empty()) {
|
||||
if (processor.empty()) {
|
||||
Gui::Command::runCommand(Gui::Command::Gui,"import Path");
|
||||
cmd << "Path.read(\"" << EncodedName << "\",\"" << pcDoc->getName() << "\")";
|
||||
Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str());
|
||||
} else {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
QFileInfo fileInfo = list.at(i);
|
||||
if (fileInfo.baseName().toStdString() == selected) {
|
||||
if (fileInfo.baseName().toStdString() == processor) {
|
||||
if (fileInfo.absoluteFilePath().contains(QString::fromLatin1("PathScripts"))) {
|
||||
pre << "from PathScripts import " << selected;
|
||||
pre << "from PathScripts import " << processor;
|
||||
} else {
|
||||
pre << "import " << selected;
|
||||
pre << "import " << processor;
|
||||
}
|
||||
Gui::Command::runCommand(Gui::Command::Gui,pre.str().c_str());
|
||||
cmd << selected << ".insert(\"" << EncodedName << "\",\"" << pcDoc->getName() << "\")";
|
||||
cmd << processor << ".insert(\"" << EncodedName << "\",\"" << pcDoc->getName() << "\")";
|
||||
Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -238,16 +238,16 @@ private:
|
|||
QFileInfo fileInfo = list.at(i);
|
||||
scripts.push_back(fileInfo.baseName().toStdString());
|
||||
}
|
||||
std::string selected;
|
||||
PathGui::DlgProcessorChooser Dlg(scripts);
|
||||
PathGui::DlgProcessorChooser Dlg(scripts, true);
|
||||
if (Dlg.exec() != QDialog::Accepted) {
|
||||
return Py::None();
|
||||
}
|
||||
selected = Dlg.getSelected();
|
||||
std::string processor = Dlg.getProcessor();
|
||||
std::string arguments = Dlg.getArguments();
|
||||
|
||||
std::ostringstream pre;
|
||||
std::ostringstream cmd;
|
||||
if (selected.empty()) {
|
||||
if (processor.empty()) {
|
||||
if (objlist.size() > 1) {
|
||||
throw Py::RuntimeError("Cannot export more than one object without using a post script");
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ private:
|
|||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
App::Document* doc = obj->getDocument();
|
||||
Gui::Command::runCommand(Gui::Command::Gui,"import Path");
|
||||
cmd << "Path.write(FreeCAD.getDocument(\"" << doc->getName() << "\").getObject(\"" << obj->getNameInDocument() << "\"),\"" << EncodedName << "\")";
|
||||
cmd << "Path.write(FreeCAD.getDocument(\"" << doc->getName() << "\").getObject(\"" << obj->getNameInDocument() << "\"),\"" << EncodedName << "\")";
|
||||
Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str());
|
||||
} else {
|
||||
return Py::None();
|
||||
|
@ -264,14 +264,14 @@ private:
|
|||
} else {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
QFileInfo fileInfo = list.at(i);
|
||||
if (fileInfo.baseName().toStdString() == selected) {
|
||||
if (fileInfo.baseName().toStdString() == processor) {
|
||||
if (fileInfo.absoluteFilePath().contains(QString::fromLatin1("PathScripts"))) {
|
||||
pre << "from PathScripts import " << selected;
|
||||
pre << "from PathScripts import " << processor;
|
||||
} else {
|
||||
pre << "import " << selected;
|
||||
pre << "import " << processor;
|
||||
}
|
||||
Gui::Command::runCommand(Gui::Command::Gui,pre.str().c_str());
|
||||
cmd << selected << ".export(__objs__,\"" << EncodedName << "\")";
|
||||
cmd << processor << ".export(__objs__,\"" << EncodedName << "\",\"" << arguments << "\")";
|
||||
Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ using namespace PathGui;
|
|||
|
||||
/* TRANSLATOR PathGui::DlgProcessorChooser */
|
||||
|
||||
DlgProcessorChooser::DlgProcessorChooser(std::vector<std::string> &scriptnames)
|
||||
DlgProcessorChooser::DlgProcessorChooser(std::vector<std::string> &scriptnames, bool withArguments)
|
||||
: QDialog(Gui::getMainWindow()), ui(new Ui_DlgProcessorChooser)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -50,23 +50,35 @@ DlgProcessorChooser::DlgProcessorChooser(std::vector<std::string> &scriptnames)
|
|||
for (std::vector<std::string>::const_iterator it = scriptnames.begin(); it != scriptnames.end(); ++it)
|
||||
ui->comboBox->addItem(QString::fromUtf8((*it).c_str()));
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
if (withArguments) {
|
||||
ui->argsLabel->setEnabled(true);
|
||||
ui->argsLineEdit->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
DlgProcessorChooser::~DlgProcessorChooser()
|
||||
{
|
||||
}
|
||||
|
||||
std::string DlgProcessorChooser::getSelected()
|
||||
std::string DlgProcessorChooser::getProcessor()
|
||||
{
|
||||
return entry;
|
||||
return processor;
|
||||
}
|
||||
|
||||
std::string DlgProcessorChooser::getArguments()
|
||||
{
|
||||
return arguments;
|
||||
}
|
||||
|
||||
void DlgProcessorChooser::accept()
|
||||
{
|
||||
if (ui->comboBox->currentText() == tr("None"))
|
||||
entry = "";
|
||||
else
|
||||
entry = ui->comboBox->currentText().toUtf8().data();
|
||||
if (ui->comboBox->currentText() == tr("None")) {
|
||||
processor = "";
|
||||
arguments = "";
|
||||
} else {
|
||||
processor = ui->comboBox->currentText().toUtf8().data();
|
||||
arguments = ui->argsLineEdit->text().toUtf8().data();
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
#include "moc_DlgProcessorChooser.cpp"
|
||||
|
|
|
@ -36,10 +36,11 @@ class DlgProcessorChooser : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgProcessorChooser(std::vector<std::string> &scriptnames);
|
||||
DlgProcessorChooser(std::vector<std::string> &scriptnames, bool withArguments = false);
|
||||
~DlgProcessorChooser();
|
||||
|
||||
std::string getSelected();
|
||||
std::string getProcessor();
|
||||
std::string getArguments();
|
||||
|
||||
void accept();
|
||||
|
||||
|
@ -47,7 +48,7 @@ protected Q_SLOTS:
|
|||
|
||||
private:
|
||||
Ui_DlgProcessorChooser* ui;
|
||||
std::string entry;
|
||||
std::string processor, arguments;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,18 +6,42 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>239</width>
|
||||
<height>82</height>
|
||||
<width>272</width>
|
||||
<height>107</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Choose a processor</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Processor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="argsLabel">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Arguments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="argsLineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -25,6 +49,9 @@
|
|||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in New Issue
Block a user