Skip to content

Commit

Permalink
added GUI PluginParameter type 'ComboBox' for parameters that can be …
Browse files Browse the repository at this point in the history
…requested from plugin
  • Loading branch information
joern274 committed Sep 15, 2023
1 parent 77614ec commit 81b8107
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/hal_core/plugin_system/plugin_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions plugins/gui/src/main_window/plugin_parameter_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <QTabWidget>
#include <QFileDialog>
#include <QTableWidget>
#include <QComboBox>

namespace hal {
PluginParameterDialog::PluginParameterDialog(const QString &pname, GuiExtensionInterface *geif, QWidget* parent)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -257,6 +266,12 @@ namespace hal {
par.set_value(QString::number(nodeDlg->getNodeId()).toStdString());
break;
}
case PluginParameter::ComboBox:
{
const QComboBox* cbox = static_cast<const QComboBox*>(w);
par.set_value(cbox->currentText().toStdString());
break;
}
default:
continue;
break;
Expand Down
3 changes: 3 additions & 0 deletions plugins/gui_extension_demo/python/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.)")
Expand Down

0 comments on commit 81b8107

Please sign in to comment.