From dc5141dfc774bc05eed8c6538c02f574e305616a Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Tue, 31 Jan 2023 15:46:01 +0100 Subject: [PATCH] Rebuild plugin settings UI on plugin reload --- src/widgets/settingspages/PluginsPage.cpp | 22 ++++++++++++++++------ src/widgets/settingspages/PluginsPage.hpp | 11 +++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/widgets/settingspages/PluginsPage.cpp b/src/widgets/settingspages/PluginsPage.cpp index 245e69b8e..7b195f74f 100644 --- a/src/widgets/settingspages/PluginsPage.cpp +++ b/src/widgets/settingspages/PluginsPage.cpp @@ -11,16 +11,24 @@ #include #include #include +#include namespace chatterino { PluginsPage::PluginsPage() + : scrollArea_(nullptr) { LayoutCreator layoutCreator(this); + this->scrollArea_ = layoutCreator.emplace(); - auto scroll = layoutCreator.emplace(); - auto widget = scroll.emplaceScrollAreaWidget(); - removeScrollAreaBackground(scroll.getElement(), widget.getElement()); + this->rebuildContent(); +} + +void PluginsPage::rebuildContent() +{ + auto widget = this->scrollArea_.emplaceScrollAreaWidget(); + removeScrollAreaBackground(this->scrollArea_.getElement(), + widget.getElement()); auto layout = widget.setLayoutType(); auto group = layout.emplace("Plugins"); @@ -76,9 +84,11 @@ PluginsPage::PluginsPage() pl->addRow("Used libraries", libs); auto *reload = new QPushButton("Reload"); - QObject::connect(reload, &QPushButton::pressed, [name = codename]() { - getApp()->plugins->reload(name); - }); + QObject::connect(reload, &QPushButton::pressed, + [name = codename, this]() { + getApp()->plugins->reload(name); + this->rebuildContent(); + }); pl->addRow(reload); } } diff --git a/src/widgets/settingspages/PluginsPage.hpp b/src/widgets/settingspages/PluginsPage.hpp index ce6296ab1..27d664dce 100644 --- a/src/widgets/settingspages/PluginsPage.hpp +++ b/src/widgets/settingspages/PluginsPage.hpp @@ -1,9 +1,20 @@ #pragma once +#include "util/LayoutCreator.hpp" #include "widgets/settingspages/SettingsPage.hpp" + +#include +#include namespace chatterino { +class Plugin; + class PluginsPage : public SettingsPage { public: PluginsPage(); + +private: + void rebuildContent(); + + LayoutCreator scrollArea_; }; } // namespace chatterino