Files
BloomPatched/src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp

105 lines
3.9 KiB
C++
Raw Normal View History

#include "UiLoader.hpp"
#include <QtUiTools>
// Custom widgets
#include "Widgets/PanelWidget.hpp"
#include "Widgets/RotatableLabel.hpp"
2021-12-18 18:02:01 +00:00
#include "Widgets/LabeledSeparator.hpp"
#include "Widgets/TextInput.hpp"
#include "Widgets/SvgWidget.hpp"
#include "Widgets/SvgToolButton.hpp"
#include "Widgets/ExpandingHeightScrollAreaWidget.hpp"
#include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp"
namespace Bloom
{
using namespace Bloom::Widgets;
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
this->customWidgetConstructorsByWidgetName = decltype(this->customWidgetConstructorsByWidgetName) {
{
"PanelWidget",
[this] (QWidget* parent, const QString& name) {
auto* widget = new PanelWidget(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"RotatableLabel",
[this] (QWidget* parent, const QString& name) {
auto* widget = new RotatableLabel("", parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"LabeledSeparator",
[this] (QWidget* parent, const QString& name) {
auto* widget = new LabeledSeparator(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"TextInput",
[this] (QWidget* parent, const QString& name) {
auto* widget = new TextInput(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"ExpandingHeightScrollAreaWidget",
[this] (QWidget* parent, const QString& name) {
auto* widget = new ExpandingHeightScrollAreaWidget(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"SvgWidget",
[this] (QWidget* parent, const QString& name) {
auto* widget = new SvgWidget(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"SvgToolButton",
[this] (QWidget* parent, const QString& name) {
auto* widget = new SvgToolButton(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
{
"TargetPackageWidgetContainer",
[this] (QWidget* parent, const QString& name) {
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent);
widget->setObjectName(name);
widget->setStyleSheet(parent->styleSheet());
return widget;
}
},
};
}
QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) {
if (this->customWidgetConstructorsByWidgetName.contains(className)) {
// This is a custom widget - call the mapped constructor
return this->customWidgetConstructorsByWidgetName.at(className)(parent, name);
}
return QUiLoader::createWidget(className, parent, name);
}
}