Skip to content
Snippets Groups Projects
Commit ab292112 authored by lat9nq's avatar lat9nq
Browse files

shared_widget: Determine default request earlier

Fixes a bug where a restore button could be created for an unmanaged
widget.
parent f84e7b46
No related branches found
No related tags found
No related merge requests found
......@@ -390,25 +390,6 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
QWidget* data_component{nullptr};
if (!Settings::IsConfiguringGlobal() && managed) {
restore_button = CreateRestoreGlobalButton(setting.UsingGlobal(), this);
touch = [this]() {
LOG_DEBUG(Frontend, "Enabling custom setting for \"{}\"", setting.GetLabel());
restore_button->setEnabled(true);
restore_button->setVisible(true);
};
}
if (require_checkbox) {
QWidget* lhs =
CreateCheckBox(other_setting, label, checkbox_serializer, checkbox_restore_func, touch);
layout->addWidget(lhs);
} else if (setting.TypeId() != typeid(bool)) {
QLabel* qt_label = CreateLabel(label);
layout->addWidget(qt_label);
}
request = [&]() {
if (request != RequestType::Default) {
return request;
......@@ -435,6 +416,25 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
return request;
}();
if (!Settings::IsConfiguringGlobal() && managed) {
restore_button = CreateRestoreGlobalButton(setting.UsingGlobal(), this);
touch = [this]() {
LOG_DEBUG(Frontend, "Enabling custom setting for \"{}\"", setting.GetLabel());
restore_button->setEnabled(true);
restore_button->setVisible(true);
};
}
if (require_checkbox) {
QWidget* lhs =
CreateCheckBox(other_setting, label, checkbox_serializer, checkbox_restore_func, touch);
layout->addWidget(lhs);
} else if (setting.TypeId() != typeid(bool)) {
QLabel* qt_label = CreateLabel(label);
layout->addWidget(qt_label);
}
if (setting.TypeId() == typeid(bool)) {
data_component = CreateCheckBox(&setting, label, serializer, restore_func, touch);
} else if (setting.IsEnum()) {
......@@ -505,6 +505,9 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
QObject::connect(restore_button, &QAbstractButton::clicked,
[this, restore_func, checkbox_restore_func](bool) {
LOG_DEBUG(Frontend, "Restore global state for \"{}\"",
setting.GetLabel());
restore_button->setEnabled(false);
restore_button->setVisible(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment