Commit b8f86fd3 authored by CABEL Tristan's avatar CABEL Tristan
Browse files

Merge branch 'feature/backport_parameter_signals_from_dtkcore' into 'develop'

Move `advanced` property from core param to widget param.

See merge request !61
parents 5f4e2cf0 ecc5529f
Pipeline #138222 passed with stage
in 0 seconds
......@@ -236,12 +236,12 @@ dtkWidgetsMenuItemParameterFacade::dtkWidgetsMenuItemParameterFacade(dtkWidgetsM
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
layout->addRow(source->title(), source->widget());
if(source->parameter()->advanced()) {
if (source->widget()->advanced()) {
this->hide();
}
this->param_connect = connect(source->parameter(), &dtkCoreParameter::advancedChanged, [this] (bool advanced) {
if(advanced)
this->param_connect = connect(source->widget(), &dtkWidgetsParameter::advancedChanged, [this] (bool advanced) {
if (advanced)
this->hide();
else
this->show();
......
......@@ -33,5 +33,16 @@ void dtkWidgetsParameter::setReadOnly(bool)
};
void dtkWidgetsParameter::setAdvanced(bool adv)
{
m_advanced = adv;
emit advancedChanged(m_advanced);
}
bool dtkWidgetsParameter::advanced(void)
{
return m_advanced;
}
//
// dtkWidgetsParameter.cpp ends here
......@@ -26,6 +26,8 @@ class dtkCoreParameter;
class DTKWIDGETS_EXPORT dtkWidgetsParameter : public QWidget
{
Q_OBJECT
public:
dtkWidgetsParameter(QWidget *);
~dtkWidgetsParameter(void) = default;
......@@ -40,8 +42,15 @@ public:
bool isReadOnly(void);
virtual void setReadOnly(bool);
void setAdvanced(bool);
bool advanced(void);
signals:
void advancedChanged(bool);
protected:
bool m_readonly = false;
bool m_advanced = false;
};
Q_DECLARE_METATYPE(dtkWidgetsParameter *);
......
......@@ -87,14 +87,8 @@ void dtkWidgetsParameterMenuBarGeneratorPrivate::parseParameter(dtkWidgetsMenu *
}
dtkCoreParameter *parameter = this->parameters[parameter_uid];
if(parameter_object.contains("advanced")) {
if(parameter) {
parameter->setAdvanced(parameter_object["advanced"].toBool());
} else {
qWarning() << "The parameter with uid :" << parameter_uid << "is nullptr";
}
if (!parameter) {
qWarning() << Q_FUNC_INFO << "The parameter with uid :" << parameter_uid << "is nullptr";
}
dtkWidgetsMenuItem *parameter_item = nullptr;
......@@ -106,11 +100,12 @@ void dtkWidgetsParameterMenuBarGeneratorPrivate::parseParameter(dtkWidgetsMenu *
}
if(parameter_item) {
auto&& param_widget = static_cast<dtkWidgetsMenuItemParameter *>(parameter_item)->widget();
param_widget->setAdvanced(parameter_object["advanced"].toBool());
if(parameter_object.contains("widget_read_only")) {
static_cast<dtkWidgetsMenuItemParameter *>(parameter_item)->widget()->setReadOnly(parameter_object["widget_read_only"].toBool());
param_widget->setReadOnly(parameter_object["widget_read_only"].toBool());
}
}
}
template<class T>
......
  • @trcabel @tkloczko Manquerait pas des trucs dans votre MR :

    params["spinbox_to_hide"]->setAdvanced(false); dans exp/dtkWidgetsMenu.

    D'ailleurs, c'est pas forcément marrant à solutionner ,-)

    Mais, comme c'est pas forcément logique de changer le statut advanced d'un widget pour le cacher... je pense qu'on peut s'en passer.

    Ce qui serait plus intéressant, c'est d'intégrer un bouton dans la menu bar à sa construction (comme les thèmes), qui permette de switcher entre un état où on affiche tous les advanced, et un autre où on les voit pas.

    Edited by LE BRETON Come
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment