2021-08-22 20:38:44 +01:00
|
|
|
#include "UiLoader.hpp"
|
|
|
|
|
|
|
|
|
|
#include <QtUiTools>
|
|
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
// Custom widgets
|
2022-05-03 20:00:52 +01:00
|
|
|
#include "Widgets/Label.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-12-19 18:30:41 +00:00
|
|
|
#include "Widgets/TextInput.hpp"
|
2022-12-21 15:39:18 +00:00
|
|
|
#include "Widgets/PushButton.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
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
namespace Bloom
|
|
|
|
|
{
|
|
|
|
|
using namespace Bloom::Widgets;
|
2021-08-22 20:38:44 +01:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
2022-09-08 14:48:28 +01:00
|
|
|
this->customWidgetConstructorsByWidgetName = {
|
2022-05-03 20:00:52 +01:00
|
|
|
{
|
|
|
|
|
"Label",
|
|
|
|
|
[this] (QWidget* parent, const QString& name) {
|
|
|
|
|
auto* widget = new Label(parent);
|
|
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
2022-02-05 15:32:08 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"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;
|
|
|
|
|
}
|
2022-12-21 15:39:18 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"PushButton",
|
|
|
|
|
[this] (QWidget* parent, const QString& name) {
|
|
|
|
|
auto* widget = new PushButton(parent);
|
|
|
|
|
widget->setObjectName(name);
|
|
|
|
|
widget->setStyleSheet(parent->styleSheet());
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
2022-02-05 15:32:08 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"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;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
2021-08-22 20:38:44 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) {
|
2022-12-03 22:16:21 +00:00
|
|
|
const auto widgetContructorIt = this->customWidgetConstructorsByWidgetName.find(className);
|
|
|
|
|
|
|
|
|
|
if (widgetContructorIt != this->customWidgetConstructorsByWidgetName.end()) {
|
2022-02-05 15:32:08 +00:00
|
|
|
// This is a custom widget - call the mapped constructor
|
2022-12-03 22:16:21 +00:00
|
|
|
return widgetContructorIt->second(parent, name);
|
2022-02-05 15:32:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QUiLoader::createWidget(className, parent, name);
|
|
|
|
|
}
|
2021-08-22 20:38:44 +01:00
|
|
|
}
|