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 <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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue