2021-08-22 20:38:44 +01:00
|
|
|
#include "UiLoader.hpp"
|
|
|
|
|
|
|
|
|
|
#include <QtUiTools>
|
|
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
// Custom widgets
|
2021-10-06 00:39:40 +01:00
|
|
|
#include "Widgets/PanelWidget.hpp"
|
2021-08-22 20:38:44 +01:00
|
|
|
#include "Widgets/RotatableLabel.hpp"
|
2021-12-18 18:02:01 +00:00
|
|
|
#include "Widgets/LabeledSeparator.hpp"
|
2021-08-22 20:38:44 +01:00
|
|
|
#include "Widgets/SvgWidget.hpp"
|
|
|
|
|
#include "Widgets/SvgToolButton.hpp"
|
|
|
|
|
#include "Widgets/ExpandingHeightScrollAreaWidget.hpp"
|
2021-09-26 18:18:12 +01:00
|
|
|
#include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp"
|
2021-08-22 20:38:44 +01:00
|
|
|
|
|
|
|
|
using namespace Bloom;
|
|
|
|
|
using namespace Bloom::Widgets;
|
|
|
|
|
|
|
|
|
|
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
|
|
|
|
this->customWidgetConstructorsByWidgetName = decltype(this->customWidgetConstructorsByWidgetName) {
|
|
|
|
|
{
|
2021-10-06 00:39:40 +01:00
|
|
|
"PanelWidget",
|
2021-10-08 23:08:15 +01:00
|
|
|
[this] (QWidget* parent, const QString& name) {
|
2021-10-28 20:44:38 +01:00
|
|
|
auto* widget = new PanelWidget(parent);
|
2021-08-22 20:38:44 +01:00
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-10-06 00:39:40 +01:00
|
|
|
"RotatableLabel",
|
2021-10-08 23:08:15 +01:00
|
|
|
[this] (QWidget* parent, const QString& name) {
|
2021-10-28 20:44:38 +01:00
|
|
|
auto* widget = new RotatableLabel("", parent);
|
2021-08-22 20:38:44 +01:00
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-12-18 18:02:01 +00:00
|
|
|
{
|
|
|
|
|
"LabeledSeparator",
|
|
|
|
|
[this] (QWidget* parent, const QString& name) {
|
|
|
|
|
auto* widget = new LabeledSeparator(parent);
|
|
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-08-22 20:38:44 +01:00
|
|
|
{
|
|
|
|
|
"ExpandingHeightScrollAreaWidget",
|
2021-10-08 23:08:15 +01:00
|
|
|
[this] (QWidget* parent, const QString& name) {
|
2021-10-28 20:44:38 +01:00
|
|
|
auto* widget = new ExpandingHeightScrollAreaWidget(parent);
|
2021-08-22 20:38:44 +01:00
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"SvgWidget",
|
2021-10-08 23:08:15 +01:00
|
|
|
[this] (QWidget* parent, const QString& name) {
|
2021-10-28 20:44:38 +01:00
|
|
|
auto* widget = new SvgWidget(parent);
|
2021-08-22 20:38:44 +01:00
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"SvgToolButton",
|
2021-10-08 23:08:15 +01:00
|
|
|
[this] (QWidget* parent, const QString& name) {
|
2021-10-28 20:44:38 +01:00
|
|
|
auto* widget = new SvgToolButton(parent);
|
2021-08-22 20:38:44 +01:00
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-26 18:18:12 +01:00
|
|
|
{
|
|
|
|
|
"TargetPackageWidgetContainer",
|
2021-10-08 23:08:15 +01:00
|
|
|
[this] (QWidget* parent, const QString& name) {
|
2021-10-28 20:44:38 +01:00
|
|
|
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent);
|
2021-09-26 18:18:12 +01:00
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-08-22 20:38:44 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|