Skip to content

Commit

Permalink
Fix layout to layout addition killing the creator
Browse files Browse the repository at this point in the history
  • Loading branch information
Salanto committed Mar 25, 2024
1 parent e63b799 commit ec1b26f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/elementstyler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QSpinBox>
#include <QTextEdit>
#include <QWidget>
Expand Down Expand Up @@ -113,6 +114,16 @@ ElementStyler::ElementStyler(QObject *parent, QWidget *full_ui)
qlabel_styler["pointsize"] = &ElementStyler::setPointSize<QLabel>;
styler["QLabel"] = qlabel_styler;

QMap<QString, ElementStylist> qpushbutton_styler;
qpushbutton_styler["size"] = &ElementStyler::setFixedSize<QPushButton>;
qpushbutton_styler["position"] = &ElementStyler::move<QPushButton>;
qpushbutton_styler["visible"] = &ElementStyler::setVisible<QPushButton>;
qpushbutton_styler["enabled"] = &ElementStyler::setEnabled<QPushButton>;
qpushbutton_styler["text"] = &ElementStyler::setText<QPushButton>;
qpushbutton_styler["font"] = &ElementStyler::setFont<QPushButton>;
qpushbutton_styler["pointsize"] = &ElementStyler::setPointSize<QPushButton>;
styler["QPushButton"] = qpushbutton_styler;

// Layouts

// Effects
Expand Down
3 changes: 2 additions & 1 deletion src/spriteuiloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ SpriteUiLoader::SpriteUiLoader(QObject *parent)
<< "QComboBox"
<< "QLineEdit"
<< "QTextEdit"
<< "QSpinBox";
<< "QSpinBox"
<< "QPushButton";
supported_layouts << availableLayouts();
supported_effects << "QGraphicsDropShadowEffect" << "QGraphicsBlurEffect"
<< "QGraphicsColorizeEffect" << "QGraphicsOpacityEffect";
Expand Down
17 changes: 11 additions & 6 deletions src/widgetbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void WidgetBuilder::appendWidgetToWidget(QString parent_widget,
QString widget_type,
QString child_widget)
{
qDebug() << "Creating object with name" << child_widget;
qDebug() << "Creating widget with name" << child_widget;
QWidget *parent = objectPointer<QWidget *>(parent_widget);
loader->createWidget(widget_type, parent, child_widget);
}
Expand All @@ -117,7 +117,7 @@ void WidgetBuilder::appendWidgetToLayout(QString parent_layout,
QString widget_type,
QString child_widget)
{
qDebug() << "Creating object with name" << child_widget;
qDebug() << "Creating widget with name" << child_widget;
QLayout *parent = objectPointer<QLayout *>(parent_layout);
QWidget *widget = loader->createWidget(widget_type, nullptr, child_widget);
parent->addWidget(widget);
Expand All @@ -127,7 +127,8 @@ void WidgetBuilder::appendLayoutToWidget(QString parent_widget,
QString layout_type,
QString child_layout)
{
qDebug() << "Creating object with name" << child_layout;
qDebug() << root_widget;
qDebug() << "Creating layout with name" << child_layout;
QWidget *parent = objectPointer<QWidget *>(parent_widget);
QLayout *layout = loader->createLayout(layout_type, parent, child_layout);
parent->setLayout(layout);
Expand All @@ -137,10 +138,14 @@ void WidgetBuilder::appendLayoutToLayout(QString parent_layout,
QString layout_type,
QString child_layout)
{
qDebug() << "Creating object with name" << child_layout;
QLayout *parent = objectPointer<QLayout *>(parent_layout);
qDebug() << "Creating layout with name" << child_layout;
QBoxLayout *parent = objectPointer<QBoxLayout *>(parent_layout);
if (parent == nullptr) {
qDebug() << "Layout" << parent_layout << "does not support sublayouts.";
return;
}
QLayout *layout = loader->createLayout(layout_type, parent, child_layout);
parent->addItem(layout);
parent->addLayout(layout);
}

void WidgetBuilder::appendEffectToWidget(QString parent_widget,
Expand Down

0 comments on commit ec1b26f

Please sign in to comment.