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

View file

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