mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Rebuild plugin settings UI on plugin reload
This commit is contained in:
parent
97b56f0226
commit
dc5141dfc7
2 changed files with 27 additions and 6 deletions
|
@ -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,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue