Commit 1fc01ac1 authored by Alessandro Portale's avatar Alessandro Portale

ScxmlEditor: Inline the ShapeGroupWidget ui creation

Change-Id: I519716e73a5d2c0c50642d65f8312e671a0e1595
Reviewed-by: Alessandro Portale's avatarAlessandro Portale <alessandro.portale@qt.io>
parent d4238ed1
......@@ -63,7 +63,6 @@ FORMS += \
$$PWD/magnifier.ui \
$$PWD/navigatorslider.ui \
$$PWD/search.ui \
$$PWD/shapegroupwidget.ui \
$$PWD/shapestoolbox.ui \
$$PWD/stateview.ui \
$$PWD/statistics.ui \
......
......@@ -30,18 +30,18 @@
#include <utils/flowlayout.h>
#include <utils/utilsicons.h>
#include <QLabel>
#include <QToolBar>
using namespace ScxmlEditor::PluginInterface;
using namespace ScxmlEditor::Common;
ShapeGroupWidget::ShapeGroupWidget(ShapeProvider *shapeProvider, int groupIndex, QWidget *parent)
: QWidget(parent)
{
m_ui.setupUi(this);
m_ui.m_closeButton->setIcon(Utils::Icons::COLLAPSE_TOOLBAR.icon());
auto layout = new Utils::FlowLayout;
layout->setContentsMargins(0, 0, 0, 0);
createUi();
m_ui.m_title->setText(shapeProvider->groupTitle(groupIndex));
m_title->setText(shapeProvider->groupTitle(groupIndex));
for (int i = 0; i < shapeProvider->shapeCount(groupIndex); ++i) {
auto button = new DragShapeButton(this);
......@@ -49,15 +49,35 @@ ShapeGroupWidget::ShapeGroupWidget(ShapeProvider *shapeProvider, int groupIndex,
button->setIcon(shapeProvider->shapeIcon(groupIndex, i));
button->setShapeInfo(groupIndex, i);
layout->addWidget(button);
m_content->layout()->addWidget(button);
}
connect(m_ui.m_closeButton, &QToolButton::clicked, this, [this]() {
m_ui.m_content->setVisible(!m_ui.m_content->isVisible());
m_ui.m_closeButton->setIcon(m_ui.m_content->isVisible()
? Utils::Icons::COLLAPSE_TOOLBAR.icon()
: Utils::Icons::EXPAND_TOOLBAR.icon());
connect(m_closeButton, &QToolButton::clicked, this, [this]() {
m_content->setVisible(!m_content->isVisible());
m_closeButton->setIcon(m_content->isVisible()
? Utils::Icons::COLLAPSE_TOOLBAR.icon()
: Utils::Icons::EXPAND_TOOLBAR.icon());
});
}
void ShapeGroupWidget::createUi()
{
m_title = new QLabel;
m_title->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_closeButton = new QToolButton;
m_closeButton->setIcon(Utils::Icons::COLLAPSE_TOOLBAR.icon());
auto toolBar = new QToolBar;
toolBar->addWidget(m_title);
toolBar->addWidget(m_closeButton);
m_content = new QWidget;
m_content->setLayout(new Utils::FlowLayout);
m_ui.m_content->setLayout(layout);
setLayout(new QVBoxLayout);
layout()->setMargin(0);
layout()->setSpacing(0);
layout()->addWidget(toolBar);
layout()->addWidget(m_content);
}
......@@ -25,10 +25,11 @@
#pragma once
#include "ui_shapegroupwidget.h"
#include <QWidget>
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QToolButton)
namespace ScxmlEditor {
namespace PluginInterface { class ShapeProvider; }
......@@ -43,7 +44,11 @@ public:
explicit ShapeGroupWidget(PluginInterface::ShapeProvider *shapeProvider, int groupIndex, QWidget *parent = nullptr);
private:
Ui::ShapeGroupWidget m_ui;
void createUi();
QLabel *m_title = nullptr;
QToolButton *m_closeButton = nullptr;
QWidget *m_content = nullptr;
};
} // namespace Common
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScxmlEditor::Common::ShapeGroupWidget</class>
<widget class="QWidget" name="ScxmlEditor::Common::ShapeGroupWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>113</width>
<height>184</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="m_titleFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_title">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Shape title</string>
</property>
<property name="margin">
<number>5</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="m_closeButton">
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::NoArrow</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="m_content" native="true"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -74,7 +74,6 @@ QtcPlugin {
"colorthemedialog.ui",
"navigatorslider.ui",
"search.ui",
"shapegroupwidget.ui",
"shapestoolbox.ui",
"stateview.ui",
"statistics.ui",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment