12 #include "ui_ParamsConfig.h"
216 const TextListType& TextList,
const bool AllowResetToDefault);
242 template <
typename EnumType, std::enable_if_t<std::is_enum_v<EnumType>,
int> = 0>
271 void AddParam(
ParamInfo&&
Info,
const std::any Destiny,
const std::vector<DynExp::ItemIDType>& Values,
311 template <
typename ParamT>
312 void Assign(ParamT& Param,
typename ParamT::UnderlyingType Value);
322 template <
typename ParamT>
323 void Assign(ParamT& Param,
const std::vector<typename ParamT::UnderlyingType::value_type>& Values);
374 virtual void accept()
override;
375 virtual void reject()
override;
378 template <
typename EnumType, std::enable_if_t<std::is_enum_v<EnumType>,
int>>
382 using IntegerType = std::underlying_type_t<EnumType>;
385 auto ComboBox =
new QComboBox(
this);
386 int SelectedIndex = 0;
387 int DefaultIndex = 0;
389 for (
const auto& TextValuePair : TextValueList)
391 if (Value == TextValuePair.second)
392 SelectedIndex = ComboBox->count();
393 if (DefaultValue == TextValuePair.second)
394 DefaultIndex = ComboBox->count();
396 ComboBox->addItem(QString::fromStdString(TextValuePair.first), QVariant(
static_cast<IntegerType
>(TextValuePair.second)));
398 ComboBox->setCurrentIndex(SelectedIndex);
400 Param ParamData(ParamType, ComboBox, Destiny, DefaultIndex);
404 template <
typename ParamT>
408 Param = std::move(Value);
411 template <
typename ParamT>
415 Param = std::move(Values);
Implements a dialog with a list of available items on the left and a list of selected items on the ri...
Implements a dialog to edit and save small pieces of text or (Python) code.
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Base class for all DynExp Objects like hardware adapters (DynExp::HardwareAdapterBase),...
Defines the configuration dialog. The dialog must be displayed by calling ParamsConfigDialog::Display...
Util::TextListIndexType TextListIndexType
List index type of Util::TextListType.
size_t GetNumParams() const noexcept
Returns the number of parameters added to the configuration dialog.
std::vector< TextEditor * > TextEditorDialogs
Keeps a list of text editor dialogs so that their ownership can be removed when the ParamsConfigDialo...
qulonglong IndexType
ID type of objects/items managed by DynExp.
bool ResetRequired
Becomes true if an existing DynExp::Object is edited and needs to be reset to apply changes after cli...
Ui::ParamsConfig ui
Bundles Qt widgets of the ParamsConfigDialog instance's user interface.
void Assign(ParamT &Param, typename ParamT::UnderlyingType Value)
When the settings dialog is closed by accepting it, assign a single value from the user interface to ...
std::function< void(void)> FunctionsToCallIfAcceptedType
Signature of a function which is called when the ParamsConfigDialog is closed by the user by clicking...
double NumberType
Number type used for numeric parameters (DynExp::ParamsBase::Param)
void OnOpenParam()
Called when clicking the 'Browse' button for a DynExp::TextUsageType::Path or DynExp::TextUsageType::...
void OnResetParam()
Called when resetting a parameter to its default value.
DynExp::Object * Object
DynExp::Object whose parameters are edited. nullptr if a new DynExp::Object is created and synchroniz...
const DynExp::DynExpCore & Core
Reference to DynExp's core.
Util::TextRefType TextRefType
Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param)
Util::TextListType TextListType
List type of text-type parameters.
bool IsResetRequired() const noexcept
Determines whether the DynExp::Object instance whose parameters have been edited needs to be reset to...
virtual void reject() override
Called when the settings dialog is rejected clicking its 'Cancel' button.
~ParamsConfigDialog()=default
void AddParam(ParamInfo &&Info, const std::any Destiny, const NumberType Value, const NumberType MinValue, const NumberType MaxValue, const NumberType Precision, const NumberType Increment)
Appends a parameter to the configuration dialog.
void InsertWidget(ParamInfo &&Info, Param &&ParamData)
Creates Qt widgets for editing a parameter and inserts them into the configuration dialog.
virtual void accept() override
Called when the settings dialog is accepted clicking its 'OK' button.
ParamsConfigDialog(QWidget *parent, const DynExp::DynExpCore &Core, std::string Title)
Constructs a ParamsConfigDialog instance.
std::vector< Param > ParamList
List of all parameters assigned to this ParamsConfigDialog instance.
std::vector< FunctionsToCallIfAcceptedType > FunctionsToCallIfAccepted
List of functions to be called when acceptig the dialog. Refer to ParamsConfigDialog::FunctionsToCall...
void OnEditParam()
Called when opening a TextEditor for a DynExp::TextUsageType::Code parameter.
void HandleTextEditorDialogsOnClose()
Called when the settings dialog is closed. Removes the parent widget of text editors listed in TextEd...
bool Display(DynExp::Object *Object=nullptr)
Displays the configuration dialog.
Util::TextType TextType
String type of text-type parameters (DynExp::ParamsBase::Param)
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
TextUsageType
Specifies the usage of a text-type parameter. Setting the right usage allows the ParamsConfigDialog t...
size_t ItemIDType
ID type of objects/items managed by DynExp.
std::vector< TextType > TextListType
List type of text-type parameters.
size_t TextListIndexType
List index type of Util::TextListType.
std::string_view TextRefType
Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param)
std::string TextType
String type of text-type parameters (DynExp::ParamsBase::Param)
std::vector< std::pair< TextType, ValueType > > TextValueListType
Type of a list containing key-value pairs where key is a text of type Util::TextType.
Accumulates include statements to provide a precompiled header.
Bundles a parameter's title and description texts.
ParamInfo(std::string Title, std::string Description)
Constructs an instance and initializes Title and Description.
ParamInfo(std::string_view Title, std::string_view Description)
Constructs an instance and initializes Title and Description.
const std::string Title
Refer to DynExp::ParamsBase::ParamBase::ParamTitle.
const std::string Description
Refer to DynExp::ParamsBase::ParamBase::ParamDescription.
Collection of data defining a single parameter to be managed by a ParamsConfigDialog instance....
QWidget *const Widget
Widget to edit/show the parameter's value in the UI.
ParamType
Identifies the type of a parameter shown in the user interface. Also refer to DynExp::TextUsageType.
const ParamType Type
Type of the managed parameter.
const IndexType DefaultIndex
Default selection index for combo box-based parameters used in case of a parameter reset.
const bool AllowResetToDefault
Determines whether to show a reset button in the UI to allow resetting the parameter to its default v...
Param(const ParamType Type, QWidget *const Widget, const std::any Destiny, IndexType DefaultIndex=0, const bool AllowResetToDefault=true)
Constructs a Param instance.
const std::any Destiny
Reference to destination variable where to store the parameter's value after editing.