diff --git a/CHANGELOG.md b/CHANGELOG.md index dd0aefd1bb4..435e774d4fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] * miscellaneous + * added GUI PluginParameter type 'ComboBox' for parameters that can be requested from plugin * added GUI PluginParameter types 'Module' and 'Gated' for parameters that can be requested from plugin * added `Show content` button to `Groupings` widget to show content of grouping as a list * added flag which python editor tab is active when serializing project diff --git a/include/hal_core/plugin_system/plugin_parameter.h b/include/hal_core/plugin_system/plugin_parameter.h index 21f1a3f29e7..60d54da14cd 100644 --- a/include/hal_core/plugin_system/plugin_parameter.h +++ b/include/hal_core/plugin_system/plugin_parameter.h @@ -32,7 +32,7 @@ namespace hal class PluginParameter { public: - enum ParameterType { Absent, Boolean, Color, Dictionary, ExistingDir, Float, Gate, Integer, Module, NewFile, PushButton, String, TabName }; + enum ParameterType { Absent, Boolean, Color, ComboBox, Dictionary, ExistingDir, Float, Gate, Integer, Module, NewFile, PushButton, String, TabName }; private: ParameterType m_type; std::string m_tagname; diff --git a/plugins/gui/src/main_window/plugin_parameter_dialog.cpp b/plugins/gui/src/main_window/plugin_parameter_dialog.cpp index f9bc2cdc7f4..b5c9c05544d 100644 --- a/plugins/gui/src/main_window/plugin_parameter_dialog.cpp +++ b/plugins/gui/src/main_window/plugin_parameter_dialog.cpp @@ -19,6 +19,7 @@ #include #include #include +#include namespace hal { PluginParameterDialog::PluginParameterDialog(const QString &pname, GuiExtensionInterface *geif, QWidget* parent) @@ -148,6 +149,14 @@ namespace hal { case PluginParameter::Gate: mWidgetMap[parTagname] = new PluginParameterNodeDialog(par,this); break; + case PluginParameter::ComboBox: + { + QComboBox* cbox = new QComboBox(this); + cbox->insertItems(0,QString::fromStdString(par.get_value()).split(';')); + if (!par.get_value().empty()) cbox->setCurrentIndex(0); + mWidgetMap[parTagname] = cbox; + break; + } default: break; } @@ -257,6 +266,12 @@ namespace hal { par.set_value(QString::number(nodeDlg->getNodeId()).toStdString()); break; } + case PluginParameter::ComboBox: + { + const QComboBox* cbox = static_cast(w); + par.set_value(cbox->currentText().toStdString()); + break; + } default: continue; break; diff --git a/plugins/gui_extension_demo/python/python_bindings.cpp b/plugins/gui_extension_demo/python/python_bindings.cpp index ee96e1e7d3d..41ab6935f64 100644 --- a/plugins/gui_extension_demo/python/python_bindings.cpp +++ b/plugins/gui_extension_demo/python/python_bindings.cpp @@ -51,10 +51,13 @@ namespace hal .value("Absent", PluginParameter::Absent, R"(Indicate not used.)") .value("Boolean", PluginParameter::Boolean, R"('true' or 'false'.)") .value("Color", PluginParameter::Color, R"(Color value like '#ffe080'.)") + .value("ComboBox", PluginParameter::ComboBox, R"(Combo box to select string from semicolon separated input list.)") .value("Dictionary", PluginParameter::Dictionary, R"(Key value pairs (string).)") .value("ExistingDir", PluginParameter::ExistingDir, R"(Existing directory.)") .value("Float", PluginParameter::Float, R"(Floating point number.)") + .value("Gate", PluginParameter::Gate, R"(Gate ID.)") .value("Integer", PluginParameter::Integer, R"(Integer number.)") + .value("Module", PluginParameter::Gate, R"(Module ID.)") .value("NewFile", PluginParameter::NewFile, R"(New file name.)") .value("PushButton", PluginParameter::PushButton, R"(Push Button.)") .value("String", PluginParameter::String, R"(String value.)")