Rebuild plugin settings UI on plugin reload

This commit is contained in:
Mm2PL 2023-01-31 15:46:01 +01:00
parent 97b56f0226
commit dc5141dfc7
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
2 changed files with 27 additions and 6 deletions

View file

@ -11,16 +11,24 @@
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <qwidget.h>
namespace chatterino { namespace chatterino {
PluginsPage::PluginsPage() PluginsPage::PluginsPage()
: scrollArea_(nullptr)
{ {
LayoutCreator<PluginsPage> layoutCreator(this); LayoutCreator<PluginsPage> layoutCreator(this);
this->scrollArea_ = layoutCreator.emplace<QScrollArea>();
auto scroll = layoutCreator.emplace<QScrollArea>(); this->rebuildContent();
auto widget = scroll.emplaceScrollAreaWidget(); }
removeScrollAreaBackground(scroll.getElement(), widget.getElement());
void PluginsPage::rebuildContent()
{
auto widget = this->scrollArea_.emplaceScrollAreaWidget();
removeScrollAreaBackground(this->scrollArea_.getElement(),
widget.getElement());
auto layout = widget.setLayoutType<QVBoxLayout>(); auto layout = widget.setLayoutType<QVBoxLayout>();
auto group = layout.emplace<QGroupBox>("Plugins"); auto group = layout.emplace<QGroupBox>("Plugins");
@ -76,8 +84,10 @@ PluginsPage::PluginsPage()
pl->addRow("Used libraries", libs); pl->addRow("Used libraries", libs);
auto *reload = new QPushButton("Reload"); auto *reload = new QPushButton("Reload");
QObject::connect(reload, &QPushButton::pressed, [name = codename]() { QObject::connect(reload, &QPushButton::pressed,
[name = codename, this]() {
getApp()->plugins->reload(name); getApp()->plugins->reload(name);
this->rebuildContent();
}); });
pl->addRow(reload); pl->addRow(reload);
} }

View file

@ -1,9 +1,20 @@
#pragma once #pragma once
#include "util/LayoutCreator.hpp"
#include "widgets/settingspages/SettingsPage.hpp" #include "widgets/settingspages/SettingsPage.hpp"
#include <QFormLayout>
#include <QGroupBox>
namespace chatterino { namespace chatterino {
class Plugin;
class PluginsPage : public SettingsPage class PluginsPage : public SettingsPage
{ {
public: public:
PluginsPage(); PluginsPage();
private:
void rebuildContent();
LayoutCreator<QScrollArea> scrollArea_;
}; };
} // namespace chatterino } // namespace chatterino