11 #include <QFormLayout>
12 #include <QGridLayout>
13 #include <QHBoxLayout>
15 #include <QDialogButtonBox>
16 #include <QPushButton>
20 #include <QFileDialog>
21 #include <QTableWidget>
26 :
QDialog(parent), mPluginName(pname), mGuiExtensionInterface(geif)
48 setupForm(
layout,it.key());
49 tabw->
addTab(tab,it.value());
72 void PluginParameterDialog::setupHash()
74 if (!mGuiExtensionInterface)
return;
75 for (PluginParameter par : mGuiExtensionInterface->
get_parameter())
82 mParameterList.append(par);
85 if (tabbed.
size() > 1)
89 mTabNames[tabTag] = tabTag;
92 switch (par.get_type())
95 mTabNames[parTagname] = parLabel;
98 mWidgetMap[parTagname] =
new QPushButton(parLabel,
this);
102 KeyValueTable* kvt =
new KeyValueTable(parLabel,
this);
103 kvt->setJson(par.get_value());
104 mWidgetMap[parTagname] = kvt;
109 mWidgetMap[parTagname] =
new ColorSelection(parDefault, parLabel,
true);
116 mWidgetMap[parTagname] = check;
124 mWidgetMap[parTagname] = intBox;
132 mWidgetMap[parTagname] = floatBox;
139 mWidgetMap[parTagname] = label;
146 mWidgetMap[parTagname] = ledit;
152 mWidgetMap[parTagname] =
new PluginParameterFileDialog(par,
this);
155 mWidgetMap[parTagname] =
new PluginParameterNodeDialog(par,
this);
158 mWidgetMap[parTagname] =
new PluginParameterNodeDialog(par,
this);
165 mWidgetMap[parTagname] = cbox;
176 for (
const PluginParameter& par : mParameterList)
181 if (!widget)
continue;
183 switch (par.get_type())
187 if (par.get_tagname().find(
'/')!=std::string::npos)
198 form->addRow(widget);
203 form->addRow(parLabel, widget);
211 if (!mGuiExtensionInterface)
return;
212 std::vector<PluginParameter> settings;
213 std::string buttonClicked;
219 switch (par.get_type())
222 if (par.get_value() ==
"clicked")
224 buttonClicked = par.get_tagname();
230 par.set_value(kvt->
toJson());
259 par.set_value(std::string());
265 par.set_value(ledit->
text().toStdString());
293 settings.push_back(par);
298 if (!buttonClicked.empty())
306 void PluginParameterDialog::handlePushbuttonClicked()
314 par.set_value(
"clicked");
321 :
QWidget(parent), mParameter(par)
332 ?
":/icons/folder-down"
340 void PluginParameterFileDialog::handleActivateFileDialog()
365 return mEditor->
text();
369 :
QWidget(parent), mParameter(par)
375 mNodeName =
new QLabel(
this);
388 iconPath =
":/icons/ne_module";
389 setModule(defaultId);
395 iconPath =
":/icons/ne_gate";
407 for (
u32 id : mValidIds)
411 if (defaultId > maxValue)
418 void PluginParameterNodeDialog::setGate(
int id)
420 if (!
id || !isValidId(
id))
422 mNodeName->
setText(
"(no gate selected)");
429 void PluginParameterNodeDialog::setModule(
int id)
431 if (!
id || !isValidId(
id))
433 mNodeName->
setText(
"(no module selected)");
440 bool PluginParameterNodeDialog::isValidId(
int id)
const
442 return (mValidIds.find(
id)!=mValidIds.end());
445 void PluginParameterNodeDialog::handleActivateModuleDialog()
447 ModuleDialog md({},
"Select module",
false,
nullptr,
this);
450 setModule(md.selectedId());
455 void PluginParameterNodeDialog::handleActivateGateDialog()
457 GateDialog gd({},
"Select gate",
nullptr,
this);
460 setGate(gd.selectedId());
467 return mNodeId->
value();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source form
QString colorName() const
virtual void execute_function(std::string tag, Netlist *nl, const std::vector< u32 > &mods, const std::vector< u32 > &gats, const std::vector< u32 > &nets)
virtual void set_parameter(const std::vector< PluginParameter > ¶ms)
virtual std::vector< PluginParameter > get_parameter() const
std::string toJson() const
Gate * get_gate_by_id(const u32 gate_id) const
std::set< u32 > get_used_gate_ids() const
std::set< u32 > get_used_module_ids() const
Module * get_module_by_id(u32 module_id) const
PluginParameterDialog(const QString &pname, GuiExtensionInterface *geif, QWidget *parent=nullptr)
QString getFilename() const
PluginParameterFileDialog(const PluginParameter &par, QWidget *parent=nullptr)
std::string get_label() const
std::string get_value() const
ParameterType get_type() const
PluginParameterNodeDialog(const PluginParameter &par, QWidget *parent=nullptr)
std::vector< u32 > selectedGatesVector() const
std::vector< u32 > selectedNetsVector() const
std::vector< u32 > selectedModulesVector() const
QIcon getStyledSvgIcon(const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
PythonContext * gPythonContext
SelectionRelay * gSelectionRelay
Qt::CheckState checkState() const const
void setCurrentIndex(int index)
void insertItems(int index, const QStringList &list)
void setMaximum(double max)
void setValue(double val)
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
QString path() const const
void setText(const QString &)
void setText(const QString &)
const T & at(int i) const const
QMap::const_iterator constBegin() const const
QMap::const_iterator constEnd() const const
bool contains(const Key &key) const const
bool isEmpty() const const
const T value(const Key &key, const T &defaultValue) const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * sender() const const
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString fromStdString(const std::string &str)
bool isEmpty() const const
QString number(int n, int base)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
double toDouble(bool *ok) const const
int toInt(bool *ok, int base) const const
QString toLower() const const
std::string toStdString() const const
uint toUInt(bool *ok, int base) const const