forked from qt-creator/qt-creator
LayoutBuilder: Rework
Everying is a LayoutItem now, and everything is split into a proper setup and execution phase. Execution happens only via LayoutBuilder (directly or via convenience wrappers in LayoutItem). No direct access to the widget in creation, funnel out is via the new bindTo() facility. Change-Id: I7eb38fd736ae57a68f9a72a6add5c767da82b49f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -216,9 +216,7 @@ void BaseAspect::addLabeledItem(Layouting::LayoutBuilder &builder, QWidget *widg
|
|||||||
if (QLabel *l = label()) {
|
if (QLabel *l = label()) {
|
||||||
l->setBuddy(widget);
|
l->setBuddy(widget);
|
||||||
builder.addItem(l);
|
builder.addItem(l);
|
||||||
LayoutItem item(widget);
|
builder.addItem(Span(std::max(d->m_spanX - 1, 1), LayoutItem(widget)));
|
||||||
item.span = std::max(d->m_spanX - 1, 1);
|
|
||||||
builder.addItem(item);
|
|
||||||
} else {
|
} else {
|
||||||
builder.addItem(LayoutItem(widget));
|
builder.addItem(LayoutItem(widget));
|
||||||
}
|
}
|
||||||
@@ -425,13 +423,23 @@ void BaseAspect::addToLayout(LayoutBuilder &)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void doLayout(const BaseAspect &aspect, LayoutBuilder &builder)
|
void createItem(Layouting::LayoutItem *item, const BaseAspect &aspect)
|
||||||
{
|
{
|
||||||
|
item->onAdd = [&aspect](LayoutBuilder &builder) {
|
||||||
const_cast<BaseAspect &>(aspect).addToLayout(builder);
|
const_cast<BaseAspect &>(aspect).addToLayout(builder);
|
||||||
if (builder.layoutType() == LayoutBuilder::FormLayout || builder.layoutType() == LayoutBuilder::VBoxLayout)
|
builder.addItem(br);
|
||||||
builder.finishRow();
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createItem(Layouting::LayoutItem *item, const BaseAspect *aspect)
|
||||||
|
{
|
||||||
|
item->onAdd = [aspect](LayoutBuilder &builder) {
|
||||||
|
const_cast<BaseAspect *>(aspect)->addToLayout(builder);
|
||||||
|
builder.addItem(br);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Updates this aspect's value from user-initiated changes in the widget.
|
Updates this aspect's value from user-initiated changes in the widget.
|
||||||
|
|
||||||
@@ -1063,7 +1071,7 @@ void StringAspect::addToLayout(Layouting::LayoutBuilder &builder)
|
|||||||
{
|
{
|
||||||
if (d->m_checker && d->m_checkBoxPlacement == CheckBoxPlacement::Top) {
|
if (d->m_checker && d->m_checkBoxPlacement == CheckBoxPlacement::Top) {
|
||||||
d->m_checker->addToLayout(builder);
|
d->m_checker->addToLayout(builder);
|
||||||
builder.finishRow();
|
builder.addItem(br);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto useMacroExpander = [this](QWidget *w) {
|
const auto useMacroExpander = [this](QWidget *w) {
|
||||||
@@ -1404,8 +1412,7 @@ void BoolAspect::addToLayout(Layouting::LayoutBuilder &builder)
|
|||||||
break;
|
break;
|
||||||
case LabelPlacement::AtCheckBox: {
|
case LabelPlacement::AtCheckBox: {
|
||||||
d->m_checkBox->setText(labelText());
|
d->m_checkBox->setText(labelText());
|
||||||
Layouting::LayoutBuilder::LayoutType type = builder.layoutType();
|
if (builder.isForm())
|
||||||
if (type == LayoutBuilder::FormLayout)
|
|
||||||
builder.addItem(createSubWidget<QLabel>());
|
builder.addItem(createSubWidget<QLabel>());
|
||||||
builder.addItem(d->m_checkBox.data());
|
builder.addItem(d->m_checkBox.data());
|
||||||
break;
|
break;
|
||||||
@@ -1566,7 +1573,8 @@ void SelectionAspect::addToLayout(Layouting::LayoutBuilder &builder)
|
|||||||
button->setChecked(i == value());
|
button->setChecked(i == value());
|
||||||
button->setEnabled(option.enabled);
|
button->setEnabled(option.enabled);
|
||||||
button->setToolTip(option.tooltip);
|
button->setToolTip(option.tooltip);
|
||||||
builder.addItems({Layouting::empty, button});
|
builder.addItem(Layouting::empty);
|
||||||
|
builder.addItem(button);
|
||||||
d->m_buttons.append(button);
|
d->m_buttons.append(button);
|
||||||
d->m_buttonGroup->addButton(button, i);
|
d->m_buttonGroup->addButton(button, i);
|
||||||
if (isAutoApply()) {
|
if (isAutoApply()) {
|
||||||
@@ -2284,7 +2292,7 @@ TextDisplay::~TextDisplay() = default;
|
|||||||
/*!
|
/*!
|
||||||
\reimp
|
\reimp
|
||||||
*/
|
*/
|
||||||
void TextDisplay::addToLayout(LayoutBuilder &builder)
|
void TextDisplay::addToLayout(Layouting::LayoutBuilder &builder)
|
||||||
{
|
{
|
||||||
if (!d->m_label) {
|
if (!d->m_label) {
|
||||||
d->m_label = createSubWidget<InfoLabel>(d->m_message, d->m_type);
|
d->m_label = createSubWidget<InfoLabel>(d->m_message, d->m_type);
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ class QAction;
|
|||||||
class QSettings;
|
class QSettings;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Layouting { class LayoutBuilder; }
|
namespace Layouting {
|
||||||
|
class LayoutItem;
|
||||||
|
class LayoutBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
@@ -204,7 +207,8 @@ private:
|
|||||||
std::unique_ptr<Internal::BaseAspectPrivate> d;
|
std::unique_ptr<Internal::BaseAspectPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT void doLayout(const BaseAspect &aspect, Layouting::LayoutBuilder &builder);
|
QTCREATOR_UTILS_EXPORT void createItem(Layouting::LayoutItem *item, const BaseAspect &aspect);
|
||||||
|
QTCREATOR_UTILS_EXPORT void createItem(Layouting::LayoutItem *item, const BaseAspect *aspect);
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT BoolAspect : public BaseAspect
|
class QTCREATOR_UTILS_EXPORT BoolAspect : public BaseAspect
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,10 +10,12 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
|
#include <QSpacerItem>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
namespace Layouting {
|
namespace Layouting {
|
||||||
|
|
||||||
@@ -26,20 +28,7 @@ namespace Layouting {
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\enum Utils::LayoutBuilder::LayoutType
|
\class Layouting::LayoutItem
|
||||||
\inmodule QtCreator
|
|
||||||
|
|
||||||
The LayoutType enum describes the type of \c QLayout a layout builder
|
|
||||||
operates on.
|
|
||||||
|
|
||||||
\value Form
|
|
||||||
\value Grid
|
|
||||||
\value HBox
|
|
||||||
\value VBox
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class Utils::LayoutBuilder::LayoutItem
|
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
|
||||||
\brief The LayoutItem class represents widgets, layouts, and aggregate
|
\brief The LayoutItem class represents widgets, layouts, and aggregate
|
||||||
@@ -53,8 +42,9 @@ namespace Layouting {
|
|||||||
/*!
|
/*!
|
||||||
Constructs a layout item instance representing an empty cell.
|
Constructs a layout item instance representing an empty cell.
|
||||||
*/
|
*/
|
||||||
LayoutItem::LayoutItem()
|
LayoutItem::LayoutItem() = default;
|
||||||
{}
|
|
||||||
|
LayoutItem::~LayoutItem() = default;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -70,47 +60,38 @@ LayoutItem::LayoutItem()
|
|||||||
\endlist
|
\endlist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct ResultItem
|
||||||
/*!
|
|
||||||
Constructs a layout item representing something that knows how to add it
|
|
||||||
to a layout by itself.
|
|
||||||
*/
|
|
||||||
QLayout *LayoutBuilder::createLayout() const
|
|
||||||
{
|
{
|
||||||
|
ResultItem() = default;
|
||||||
|
explicit ResultItem(QLayout *l) : layout(l) {}
|
||||||
|
explicit ResultItem(QWidget *w) : widget(w) {}
|
||||||
|
|
||||||
|
QString text;
|
||||||
QLayout *layout = nullptr;
|
QLayout *layout = nullptr;
|
||||||
switch (m_layoutType) {
|
QWidget *widget = nullptr;
|
||||||
case LayoutBuilder::FormLayout: {
|
int space = -1;
|
||||||
auto formLayout = new QFormLayout;
|
int stretch = -1;
|
||||||
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
int span = 1;
|
||||||
layout = formLayout;
|
};
|
||||||
break;
|
|
||||||
}
|
struct LayoutBuilder::Slice
|
||||||
case LayoutBuilder::GridLayout: {
|
{
|
||||||
auto gridLayout = new QGridLayout;
|
Slice() = default;
|
||||||
layout = gridLayout;
|
Slice(QLayout *l) : layout(l) {}
|
||||||
break;
|
Slice(QWidget *w) : widget(w) {}
|
||||||
}
|
Slice(QWidget *w, AttachType a) : widget(w), attachType(a) {}
|
||||||
case LayoutBuilder::HBoxLayout: {
|
|
||||||
auto hboxLayout = new QHBoxLayout;
|
QLayout *layout = nullptr;
|
||||||
layout = hboxLayout;
|
QWidget *widget = nullptr;
|
||||||
break;
|
|
||||||
}
|
void flush();
|
||||||
case LayoutBuilder::VBoxLayout: {
|
|
||||||
auto vboxLayout = new QVBoxLayout;
|
int currentGridColumn = 0;
|
||||||
layout = vboxLayout;
|
int currentGridRow = 0;
|
||||||
break;
|
|
||||||
}
|
AttachType attachType = WithMargins;
|
||||||
case LayoutBuilder::StackLayout: {
|
QList<ResultItem> pendingItems;
|
||||||
auto stackLayout = new QStackedLayout;
|
};
|
||||||
layout = stackLayout;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QTC_ASSERT(layout, return nullptr);
|
|
||||||
if (m_spacing)
|
|
||||||
layout->setSpacing(*m_spacing);
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QWidget *widgetForItem(QLayoutItem *item)
|
static QWidget *widgetForItem(QLayoutItem *item)
|
||||||
{
|
{
|
||||||
@@ -135,18 +116,16 @@ static QLabel *createLabel(const QString &text)
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addItemToBoxLayout(QBoxLayout *layout, const LayoutItem &item)
|
static void addItemToBoxLayout(QBoxLayout *layout, const ResultItem &item)
|
||||||
{
|
{
|
||||||
if (QWidget *w = item.widget) {
|
if (QWidget *w = item.widget) {
|
||||||
layout->addWidget(w);
|
layout->addWidget(w);
|
||||||
} else if (QLayout *l = item.layout) {
|
} else if (QLayout *l = item.layout) {
|
||||||
layout->addLayout(l);
|
layout->addLayout(l);
|
||||||
} else if (item.specialType == LayoutItem::SpecialType::Stretch) {
|
} else if (item.stretch != -1) {
|
||||||
layout->addStretch(item.specialValue.toInt());
|
layout->addStretch(item.stretch);
|
||||||
} else if (item.specialType == LayoutItem::SpecialType::Space) {
|
} else if (item.space != -1) {
|
||||||
layout->addSpacing(item.specialValue.toInt());
|
layout->addSpacing(item.space);
|
||||||
} else if (item.specialType == LayoutItem::SpecialType::HorizontalRule) {
|
|
||||||
layout->addWidget(Layouting::createHr());
|
|
||||||
} else if (!item.text.isEmpty()) {
|
} else if (!item.text.isEmpty()) {
|
||||||
layout->addWidget(createLabel(item.text));
|
layout->addWidget(createLabel(item.text));
|
||||||
} else {
|
} else {
|
||||||
@@ -154,41 +133,46 @@ static void addItemToBoxLayout(QBoxLayout *layout, const LayoutItem &item)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flushPendingFormItems(QFormLayout *formLayout,
|
void LayoutBuilder::Slice::flush()
|
||||||
LayoutBuilder::LayoutItems &pendingFormItems)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(formLayout, return);
|
if (pendingItems.empty())
|
||||||
|
|
||||||
if (pendingFormItems.empty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (auto formLayout = qobject_cast<QFormLayout *>(layout)) {
|
||||||
|
|
||||||
// If there are more than two items, we cram the last ones in one hbox.
|
// If there are more than two items, we cram the last ones in one hbox.
|
||||||
if (pendingFormItems.size() > 2) {
|
if (pendingItems.size() > 2) {
|
||||||
auto hbox = new QHBoxLayout;
|
auto hbox = new QHBoxLayout;
|
||||||
hbox->setContentsMargins(0, 0, 0, 0);
|
hbox->setContentsMargins(0, 0, 0, 0);
|
||||||
for (int i = 1; i < pendingFormItems.size(); ++i)
|
for (int i = 1; i < pendingItems.size(); ++i)
|
||||||
addItemToBoxLayout(hbox, pendingFormItems.at(i));
|
addItemToBoxLayout(hbox, pendingItems.at(i));
|
||||||
while (pendingFormItems.size() >= 2)
|
while (pendingItems.size() > 1)
|
||||||
pendingFormItems.pop_back();
|
pendingItems.pop_back();
|
||||||
pendingFormItems.append(LayoutItem(hbox));
|
pendingItems.append(ResultItem(hbox));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pendingFormItems.size() == 1) { // One one item given, so this spans both columns.
|
if (pendingItems.size() == 1) { // One one item given, so this spans both columns.
|
||||||
if (auto layout = pendingFormItems.at(0).layout)
|
const ResultItem &f0 = pendingItems.at(0);
|
||||||
|
if (auto layout = f0.layout)
|
||||||
formLayout->addRow(layout);
|
formLayout->addRow(layout);
|
||||||
else if (auto widget = pendingFormItems.at(0).widget)
|
else if (auto widget = f0.widget)
|
||||||
formLayout->addRow(widget);
|
formLayout->addRow(widget);
|
||||||
} else if (pendingFormItems.size() == 2) { // Normal case, both columns used.
|
} else if (pendingItems.size() == 2) { // Normal case, both columns used.
|
||||||
if (auto label = pendingFormItems.at(0).widget) {
|
ResultItem &f1 = pendingItems[1];
|
||||||
if (auto layout = pendingFormItems.at(1).layout)
|
const ResultItem &f0 = pendingItems.at(0);
|
||||||
formLayout->addRow(label, layout);
|
if (!f1.widget && !f1.layout && !f1.text.isEmpty())
|
||||||
else if (auto widget = pendingFormItems.at(1).widget)
|
f1.widget = createLabel(f1.text);
|
||||||
formLayout->addRow(label, widget);
|
|
||||||
|
if (f0.widget) {
|
||||||
|
if (f1.layout)
|
||||||
|
formLayout->addRow(f0.widget, f1.layout);
|
||||||
|
else if (f1.widget)
|
||||||
|
formLayout->addRow(f0.widget, f1.widget);
|
||||||
} else {
|
} else {
|
||||||
if (auto layout = pendingFormItems.at(1).layout)
|
if (f1.layout)
|
||||||
formLayout->addRow(pendingFormItems.at(0).text, layout);
|
formLayout->addRow(f0.text, f1.layout);
|
||||||
else if (auto widget = pendingFormItems.at(1).widget)
|
else if (f1.widget)
|
||||||
formLayout->addRow(pendingFormItems.at(0).text, widget);
|
formLayout->addRow(f0.text, f1.widget);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
@@ -205,87 +189,112 @@ static void flushPendingFormItems(QFormLayout *formLayout,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingFormItems.clear();
|
} else if (auto gridLayout = qobject_cast<QGridLayout *>(layout)) {
|
||||||
}
|
|
||||||
|
|
||||||
static void doLayoutHelper(QLayout *layout,
|
for (const ResultItem &item : std::as_const(pendingItems)) {
|
||||||
const LayoutBuilder::LayoutItems &items,
|
|
||||||
const Layouting::AttachType attachType,
|
|
||||||
int currentGridRow = 0)
|
|
||||||
{
|
|
||||||
int currentGridColumn = 0;
|
|
||||||
LayoutBuilder::LayoutItems pendingFormItems;
|
|
||||||
|
|
||||||
auto formLayout = qobject_cast<QFormLayout *>(layout);
|
|
||||||
auto gridLayout = qobject_cast<QGridLayout *>(layout);
|
|
||||||
auto boxLayout = qobject_cast<QBoxLayout *>(layout);
|
|
||||||
auto stackLayout = qobject_cast<QStackedLayout *>(layout);
|
|
||||||
|
|
||||||
for (const LayoutItem &item : items) {
|
|
||||||
if (item.specialType == LayoutItem::SpecialType::Break) {
|
|
||||||
if (formLayout)
|
|
||||||
flushPendingFormItems(formLayout, pendingFormItems);
|
|
||||||
else if (gridLayout) {
|
|
||||||
if (currentGridColumn != 0) {
|
|
||||||
++currentGridRow;
|
|
||||||
currentGridColumn = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *widget = item.widget;
|
|
||||||
|
|
||||||
if (gridLayout) {
|
|
||||||
Qt::Alignment align = {};
|
Qt::Alignment align = {};
|
||||||
if (attachType == Layouting::WithFormAlignment && currentGridColumn == 0)
|
// if (attachType == Layouting::WithFormAlignment && currentGridColumn == 0)
|
||||||
align = Qt::Alignment(widget->style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
|
// align = Qt::Alignment(m_widget->style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
|
||||||
if (widget)
|
if (item.widget)
|
||||||
gridLayout->addWidget(widget, currentGridRow, currentGridColumn, 1, item.span, align);
|
gridLayout->addWidget(item.widget, currentGridRow, currentGridColumn, 1, item.span, align);
|
||||||
else if (item.layout)
|
else if (item.layout)
|
||||||
gridLayout->addLayout(item.layout, currentGridRow, currentGridColumn, 1, item.span, align);
|
gridLayout->addLayout(item.layout, currentGridRow, currentGridColumn, 1, item.span, align);
|
||||||
else if (!item.text.isEmpty())
|
else if (!item.text.isEmpty())
|
||||||
gridLayout->addWidget(createLabel(item.text), currentGridRow, currentGridColumn, 1, 1, align);
|
gridLayout->addWidget(createLabel(item.text), currentGridRow, currentGridColumn, 1, 1, align);
|
||||||
currentGridColumn += item.span;
|
currentGridColumn += item.span;
|
||||||
} else if (boxLayout) {
|
}
|
||||||
|
++currentGridRow;
|
||||||
|
currentGridColumn = 0;
|
||||||
|
|
||||||
|
} else if (auto boxLayout = qobject_cast<QBoxLayout *>(layout)) {
|
||||||
|
|
||||||
|
for (const ResultItem &item : std::as_const(pendingItems))
|
||||||
addItemToBoxLayout(boxLayout, item);
|
addItemToBoxLayout(boxLayout, item);
|
||||||
} else if (stackLayout) {
|
|
||||||
|
} else if (auto stackLayout = qobject_cast<QStackedLayout *>(layout)) {
|
||||||
|
for (const ResultItem &item : std::as_const(pendingItems)) {
|
||||||
|
if (item.widget)
|
||||||
stackLayout->addWidget(item.widget);
|
stackLayout->addWidget(item.widget);
|
||||||
|
else
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
pendingFormItems.append(item);
|
QTC_CHECK(false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formLayout)
|
pendingItems.clear();
|
||||||
flushPendingFormItems(formLayout, pendingFormItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void addItemHelper(LayoutBuilder &builder, const LayoutItem &item)
|
||||||
/*!
|
|
||||||
Constructs a layout item from the contents of another LayoutBuilder
|
|
||||||
*/
|
|
||||||
void LayoutItem::setBuilder(const LayoutBuilder &builder)
|
|
||||||
{
|
{
|
||||||
layout = builder.createLayout();
|
if (item.onAdd)
|
||||||
doLayoutHelper(layout, builder.m_items, Layouting::WithoutMargins);
|
item.onAdd(builder);
|
||||||
|
|
||||||
|
if (item.setter) {
|
||||||
|
if (QWidget *widget = builder.stack.last().widget)
|
||||||
|
item.setter(widget);
|
||||||
|
else if (QLayout *layout = builder.stack.last().layout)
|
||||||
|
item.setter(layout);
|
||||||
|
else
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const LayoutItem &subItem : item.subItems)
|
||||||
|
addItemHelper(builder, subItem);
|
||||||
|
|
||||||
|
if (item.onExit)
|
||||||
|
item.onExit(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doAddText(LayoutBuilder &builder, const QString &text)
|
||||||
|
{
|
||||||
|
ResultItem fi;
|
||||||
|
fi.text = text;
|
||||||
|
builder.stack.last().pendingItems.append(fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void doAddSpace(LayoutBuilder &builder, const Space &space)
|
||||||
|
{
|
||||||
|
ResultItem fi;
|
||||||
|
fi.space = space.space;
|
||||||
|
builder.stack.last().pendingItems.append(fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void doAddStretch(LayoutBuilder &builder, const Stretch &stretch)
|
||||||
|
{
|
||||||
|
ResultItem fi;
|
||||||
|
fi.stretch = stretch.stretch;
|
||||||
|
builder.stack.last().pendingItems.append(fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void doAddLayout(LayoutBuilder &builder, QLayout *layout)
|
||||||
|
{
|
||||||
|
builder.stack.last().pendingItems.append(ResultItem(layout));
|
||||||
|
}
|
||||||
|
|
||||||
|
void doAddWidget(LayoutBuilder &builder, QWidget *widget)
|
||||||
|
{
|
||||||
|
builder.stack.last().pendingItems.append(ResultItem(widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Utils::LayoutBuilder::Space
|
\class Layouting::Space
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
|
||||||
\brief The LayoutBuilder::Space class represents some empty space in a layout.
|
\brief The Layouting::Space class represents some empty space in a layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Utils::LayoutBuilder::Stretch
|
\class Layouting::Stretch
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
|
||||||
\brief The LayoutBuilder::Stretch class represents some stretch in a layout.
|
\brief The Layouting::Stretch class represents some stretch in a layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Utils::LayoutBuilder
|
\class LayoutBuilder
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
|
||||||
\brief The LayoutBuilder class provides a convenient way to fill \c QFormLayout
|
\brief The LayoutBuilder class provides a convenient way to fill \c QFormLayout
|
||||||
@@ -298,20 +307,6 @@ void LayoutItem::setBuilder(const LayoutBuilder &builder)
|
|||||||
\sa addItem(), addItems(), addRow(), finishRow()
|
\sa addItem(), addItems(), addRow(), finishRow()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LayoutBuilder::LayoutBuilder(LayoutType layoutType, const LayoutItems &items)
|
|
||||||
: m_layoutType(layoutType)
|
|
||||||
{
|
|
||||||
m_items.reserve(items.size() * 2);
|
|
||||||
for (const LayoutItem &item : items)
|
|
||||||
addItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
LayoutBuilder &LayoutBuilder::setSpacing(int spacing)
|
|
||||||
{
|
|
||||||
m_spacing = spacing;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
LayoutBuilder::LayoutBuilder() = default;
|
LayoutBuilder::LayoutBuilder() = default;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -319,14 +314,30 @@ LayoutBuilder::LayoutBuilder() = default;
|
|||||||
*/
|
*/
|
||||||
LayoutBuilder::~LayoutBuilder() = default;
|
LayoutBuilder::~LayoutBuilder() = default;
|
||||||
|
|
||||||
|
void LayoutBuilder::addItem(const LayoutItem &item)
|
||||||
|
{
|
||||||
|
addItemHelper(*this, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutBuilder::addItems(const LayoutItems &items)
|
||||||
|
{
|
||||||
|
for (const LayoutItem &item : items)
|
||||||
|
addItemHelper(*this, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutBuilder::addRow(const LayoutItems &items)
|
||||||
|
{
|
||||||
|
addItem(br);
|
||||||
|
addItems(items);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Instructs a layout builder to finish the current row.
|
Instructs a layout builder to finish the current row.
|
||||||
This is implicitly called by LayoutBuilder's destructor.
|
This is implicitly called by LayoutBuilder's destructor.
|
||||||
*/
|
*/
|
||||||
LayoutBuilder &LayoutBuilder::finishRow()
|
void LayoutItem::finishRow()
|
||||||
{
|
{
|
||||||
addItem(Break());
|
addItem(br);
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -335,42 +346,26 @@ LayoutBuilder &LayoutBuilder::finishRow()
|
|||||||
|
|
||||||
\sa finishRow(), addItem(), addItems()
|
\sa finishRow(), addItem(), addItems()
|
||||||
*/
|
*/
|
||||||
LayoutBuilder &LayoutBuilder::addRow(const LayoutItems &items)
|
void LayoutItem::addRow(const LayoutItems &items)
|
||||||
{
|
{
|
||||||
return finishRow().addItems(items);
|
finishRow();
|
||||||
|
addItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Adds the layout item \a item to the current row.
|
Adds the layout item \a item as sub items.
|
||||||
*/
|
*/
|
||||||
LayoutBuilder &LayoutBuilder::addItem(const LayoutItem &item)
|
void LayoutItem::addItem(const LayoutItem &item)
|
||||||
{
|
{
|
||||||
if (item.onAdd) {
|
subItems.append(item);
|
||||||
item.onAdd(*this);
|
|
||||||
} else {
|
|
||||||
m_items.push_back(item);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayoutBuilder::doLayout(QWidget *parent, Layouting::AttachType attachType) const
|
|
||||||
{
|
|
||||||
QLayout *layout = createLayout();
|
|
||||||
parent->setLayout(layout);
|
|
||||||
|
|
||||||
doLayoutHelper(layout, m_items, attachType);
|
|
||||||
if (attachType == Layouting::WithoutMargins)
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Adds the layout item \a items to the current row.
|
Adds the layout items \a items as sub items.
|
||||||
*/
|
*/
|
||||||
LayoutBuilder &LayoutBuilder::addItems(const LayoutItems &items)
|
void LayoutItem::addItems(const LayoutItems &items)
|
||||||
{
|
{
|
||||||
for (const LayoutItem &item : items)
|
subItems.append(items);
|
||||||
addItem(item);
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -378,18 +373,106 @@ LayoutBuilder &LayoutBuilder::addItems(const LayoutItems &items)
|
|||||||
|
|
||||||
This operation can only be performed once per LayoutBuilder instance.
|
This operation can only be performed once per LayoutBuilder instance.
|
||||||
*/
|
*/
|
||||||
void LayoutBuilder::attachTo(QWidget *w, Layouting::AttachType attachType) const
|
|
||||||
|
void LayoutItem::attachTo(QWidget *w, AttachType attachType) const
|
||||||
{
|
{
|
||||||
doLayout(w, attachType);
|
LayoutBuilder builder;
|
||||||
|
|
||||||
|
builder.stack.append({w, attachType});
|
||||||
|
addItemHelper(builder, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *LayoutBuilder::emerge(Layouting::AttachType attachType)
|
QWidget *LayoutItem::emerge(Layouting::AttachType attachType)
|
||||||
{
|
{
|
||||||
auto w = new QWidget;
|
auto w = new QWidget;
|
||||||
doLayout(w, attachType);
|
attachTo(w, attachType);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LayoutBuilder::isForm() const
|
||||||
|
{
|
||||||
|
return qobject_cast<QFormLayout *>(stack.last().layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void layoutExit(LayoutBuilder &builder)
|
||||||
|
{
|
||||||
|
builder.stack.last().flush();
|
||||||
|
QLayout *layout = builder.stack.last().layout;
|
||||||
|
if (builder.stack.back().attachType == WithoutMargins)
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
builder.stack.pop_back();
|
||||||
|
|
||||||
|
if (QWidget *widget = builder.stack.last().widget)
|
||||||
|
widget->setLayout(layout);
|
||||||
|
else
|
||||||
|
builder.stack.last().pendingItems.append(ResultItem(layout));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void widgetExit(LayoutBuilder &builder)
|
||||||
|
{
|
||||||
|
QWidget *widget = builder.stack.last().widget;
|
||||||
|
if (builder.stack.back().attachType == WithoutMargins)
|
||||||
|
widget->setContentsMargins(0, 0, 0, 0);
|
||||||
|
builder.stack.pop_back();
|
||||||
|
builder.stack.last().pendingItems.append(ResultItem(widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
Column::Column(std::initializer_list<LayoutItem> items)
|
||||||
|
{
|
||||||
|
subItems = items;
|
||||||
|
onAdd = [](LayoutBuilder &builder) { builder.stack.append(new QVBoxLayout); };
|
||||||
|
onExit = layoutExit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Row::Row(std::initializer_list<LayoutItem> items)
|
||||||
|
{
|
||||||
|
subItems = items;
|
||||||
|
onAdd = [](LayoutBuilder &builder) { builder.stack.append(new QHBoxLayout); };
|
||||||
|
onExit = layoutExit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Grid(std::initializer_list<LayoutItem> items)
|
||||||
|
{
|
||||||
|
subItems = items;
|
||||||
|
onAdd = [](LayoutBuilder &builder) { builder.stack.append(new QGridLayout); };
|
||||||
|
onExit = layoutExit;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QFormLayout *newFormLayout()
|
||||||
|
{
|
||||||
|
auto formLayout = new QFormLayout;
|
||||||
|
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||||
|
return formLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
Form::Form(std::initializer_list<LayoutItem> items)
|
||||||
|
{
|
||||||
|
subItems = items;
|
||||||
|
onAdd = [](LayoutBuilder &builder) { builder.stack.append(newFormLayout()); };
|
||||||
|
onExit = layoutExit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Stack::Stack(std::initializer_list<LayoutItem> items)
|
||||||
|
{
|
||||||
|
subItems = items;
|
||||||
|
onAdd = [](LayoutBuilder &builder) { builder.stack.append(new QStackedLayout); };
|
||||||
|
onExit = layoutExit;
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutItem br()
|
||||||
|
{
|
||||||
|
LayoutItem item;
|
||||||
|
item.onAdd = [](LayoutBuilder &builder) {
|
||||||
|
builder.stack.last().flush();
|
||||||
|
};
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutItem empty()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a layout extender to extend an existing \a layout.
|
Constructs a layout extender to extend an existing \a layout.
|
||||||
|
|
||||||
@@ -399,111 +482,123 @@ QWidget *LayoutBuilder::emerge(Layouting::AttachType attachType)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LayoutExtender::LayoutExtender(QLayout *layout, Layouting::AttachType attachType)
|
LayoutExtender::LayoutExtender(QLayout *layout, Layouting::AttachType attachType)
|
||||||
: m_layout(layout), m_attachType(attachType)
|
|
||||||
{}
|
|
||||||
|
|
||||||
LayoutExtender::~LayoutExtender()
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_layout, return);
|
Slice slice;
|
||||||
int currentGridRow = 0;
|
slice.layout = layout;
|
||||||
if (auto gridLayout = qobject_cast<QGridLayout *>(m_layout))
|
if (auto gridLayout = qobject_cast<QGridLayout *>(layout))
|
||||||
currentGridRow = gridLayout->rowCount();
|
slice.currentGridRow = gridLayout->rowCount();
|
||||||
doLayoutHelper(m_layout, m_items, m_attachType, currentGridRow);
|
slice.attachType = attachType;
|
||||||
|
stack.append(slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special items
|
LayoutExtender::~LayoutExtender() = default;
|
||||||
|
|
||||||
Tab::Tab(const QString &tabName, const LayoutBuilder &item)
|
|
||||||
{
|
|
||||||
text = tabName;
|
|
||||||
widget = new QWidget;
|
|
||||||
item.attachTo(widget);
|
|
||||||
specialType = LayoutItem::SpecialType::Tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "Widgets"
|
// "Widgets"
|
||||||
|
|
||||||
static void applyItems(LayoutItem *owner, QWidget *widget, const QList<LayoutItem> &items)
|
template <class T>
|
||||||
|
void setupWidget(LayoutItem *item)
|
||||||
{
|
{
|
||||||
owner->widget = widget;
|
item->onAdd = [](LayoutBuilder &builder) { builder.stack.append(new T); };
|
||||||
bool hadLayout = false;
|
item->onExit = widgetExit;
|
||||||
for (const LayoutItem &item : items) {
|
};
|
||||||
if (item.setter) {
|
|
||||||
item.setter(widget);
|
|
||||||
} else if (item.specialType == LayoutItem::SpecialType::Tab) {
|
|
||||||
auto tabWidget = qobject_cast<QTabWidget *>(widget);
|
|
||||||
QTC_ASSERT(tabWidget, continue);
|
|
||||||
tabWidget->addTab(item.widget, item.text);
|
|
||||||
} else if (item.layout && !hadLayout) {
|
|
||||||
hadLayout = true;
|
|
||||||
widget->setLayout(item.layout);
|
|
||||||
} else {
|
|
||||||
QTC_CHECK(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Group::Group(std::initializer_list<LayoutItem> items)
|
Group::Group(std::initializer_list<LayoutItem> items)
|
||||||
{
|
{
|
||||||
applyItems(this, new QGroupBox, items);
|
this->subItems = items;
|
||||||
|
setupWidget<QGroupBox>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PushButton::PushButton(std::initializer_list<LayoutItem> items)
|
PushButton::PushButton(std::initializer_list<LayoutItem> items)
|
||||||
{
|
{
|
||||||
applyItems(this, new QPushButton, items);
|
this->subItems = items;
|
||||||
|
setupWidget<QPushButton>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEdit::TextEdit(std::initializer_list<LayoutItem> items)
|
TextEdit::TextEdit(std::initializer_list<LayoutItem> items)
|
||||||
{
|
{
|
||||||
applyItems(this, new QTextEdit, items);
|
this->subItems = items;
|
||||||
|
setupWidget<QTextEdit>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Splitter::Splitter(std::initializer_list<LayoutItem> items)
|
Splitter::Splitter(std::initializer_list<LayoutItem> items)
|
||||||
{
|
{
|
||||||
applyItems(this, new QSplitter(Qt::Vertical), items);
|
this->subItems = items;
|
||||||
}
|
setupWidget<QSplitter>(this); // FIXME: Default was Qt::Vertical)
|
||||||
|
}
|
||||||
|
|
||||||
TabWidget::TabWidget(std::initializer_list<LayoutItem> items)
|
TabWidget::TabWidget(std::initializer_list<LayoutItem> items)
|
||||||
{
|
{
|
||||||
applyItems(this, new QTabWidget, items);
|
this->subItems = items;
|
||||||
|
setupWidget<QTabWidget>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special Tab
|
||||||
|
|
||||||
|
Tab::Tab(const QString &tabName, const LayoutItem &item)
|
||||||
|
{
|
||||||
|
onAdd = [item](LayoutBuilder &builder) {
|
||||||
|
auto tab = new QWidget;
|
||||||
|
builder.stack.append(tab);
|
||||||
|
item.attachTo(tab);
|
||||||
|
};
|
||||||
|
onExit = [tabName](LayoutBuilder &builder) {
|
||||||
|
QWidget *inner = builder.stack.last().widget;
|
||||||
|
builder.stack.pop_back();
|
||||||
|
auto tabWidget = qobject_cast<QTabWidget *>(builder.stack.last().widget);
|
||||||
|
QTC_ASSERT(tabWidget, return);
|
||||||
|
tabWidget->addTab(inner, tabName);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special Application
|
||||||
|
|
||||||
|
Application::Application(std::initializer_list<LayoutItem> items)
|
||||||
|
{
|
||||||
|
subItems = items;
|
||||||
|
setupWidget<QWidget>(this);
|
||||||
|
onExit = {}; // Hack: Don't dropp the last slice, we need the resulting widget.
|
||||||
|
}
|
||||||
|
|
||||||
|
int Application::exec(int &argc, char *argv[])
|
||||||
|
{
|
||||||
|
auto app = new QApplication(argc, argv);
|
||||||
|
LayoutBuilder builder;
|
||||||
|
addItemHelper(builder, *this);
|
||||||
|
if (QWidget *widget = builder.stack.last().widget)
|
||||||
|
widget->show();
|
||||||
|
return app->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Properties"
|
// "Properties"
|
||||||
|
|
||||||
static LayoutItem setter(const LayoutItem::Setter &setter)
|
|
||||||
{
|
|
||||||
LayoutItem item;
|
|
||||||
item.setter = setter;
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
LayoutItem title(const QString &title)
|
LayoutItem title(const QString &title)
|
||||||
{
|
{
|
||||||
return setter([title](QObject *target) {
|
return [title](QObject *target) {
|
||||||
if (auto groupBox = qobject_cast<QGroupBox *>(target)) {
|
if (auto groupBox = qobject_cast<QGroupBox *>(target)) {
|
||||||
groupBox->setTitle(title);
|
groupBox->setTitle(title);
|
||||||
groupBox->setObjectName(title);
|
groupBox->setObjectName(title);
|
||||||
|
} else if (auto widget = qobject_cast<QWidget *>(target)) {
|
||||||
|
widget->setWindowTitle(title);
|
||||||
} else {
|
} else {
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutItem onClicked(const std::function<void ()> &func, QObject *guard)
|
LayoutItem onClicked(const std::function<void ()> &func, QObject *guard)
|
||||||
{
|
{
|
||||||
return setter([func, guard](QObject *target) {
|
return [func, guard](QObject *target) {
|
||||||
if (auto button = qobject_cast<QAbstractButton *>(target)) {
|
if (auto button = qobject_cast<QAbstractButton *>(target)) {
|
||||||
QObject::connect(button, &QAbstractButton::clicked, guard ? guard : target, func);
|
QObject::connect(button, &QAbstractButton::clicked, guard ? guard : target, func);
|
||||||
} else {
|
} else {
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutItem text(const QString &text)
|
LayoutItem text(const QString &text)
|
||||||
{
|
{
|
||||||
return setter([text](QObject *target) {
|
return [text](QObject *target) {
|
||||||
if (auto button = qobject_cast<QAbstractButton *>(target)) {
|
if (auto button = qobject_cast<QAbstractButton *>(target)) {
|
||||||
button->setText(text);
|
button->setText(text);
|
||||||
} else if (auto textEdit = qobject_cast<QTextEdit *>(target)) {
|
} else if (auto textEdit = qobject_cast<QTextEdit *>(target)) {
|
||||||
@@ -511,32 +606,40 @@ LayoutItem text(const QString &text)
|
|||||||
} else {
|
} else {
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutItem tooltip(const QString &toolTip)
|
LayoutItem tooltip(const QString &toolTip)
|
||||||
{
|
{
|
||||||
return setter([toolTip](QObject *target) {
|
return [toolTip](QObject *target) {
|
||||||
if (auto widget = qobject_cast<QWidget *>(target)) {
|
if (auto widget = qobject_cast<QWidget *>(target)) {
|
||||||
widget->setToolTip(toolTip);
|
widget->setToolTip(toolTip);
|
||||||
} else {
|
} else {
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutItem bindTo(QSplitter **out)
|
LayoutItem spacing(int spacing)
|
||||||
{
|
{
|
||||||
return setter([out](QObject *target) {
|
return [spacing](QObject *target) {
|
||||||
*out = qobject_cast<QSplitter *>(target);
|
if (auto layout = qobject_cast<QLayout *>(target)) {
|
||||||
});
|
layout->setSpacing(spacing);
|
||||||
|
} else {
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutItem bindTo(QTabWidget **out)
|
LayoutItem resize(int w, int h)
|
||||||
{
|
{
|
||||||
return setter([out](QObject *target) {
|
return [w, h](QObject *target) {
|
||||||
*out = qobject_cast<QTabWidget *>(target);
|
if (auto widget = qobject_cast<QWidget *>(target)) {
|
||||||
});
|
widget->resize(w, h);
|
||||||
|
} else {
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *createHr(QWidget *parent)
|
QWidget *createHr(QWidget *parent)
|
||||||
@@ -548,9 +651,67 @@ QWidget *createHr(QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Singletons.
|
// Singletons.
|
||||||
Break br;
|
|
||||||
Stretch st;
|
LayoutItem::LayoutItem(const LayoutItem &t)
|
||||||
Space empty(0);
|
{
|
||||||
HorizontalRule hr;
|
operator=(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, LayoutItem(*t)())
|
||||||
|
{
|
||||||
|
*item = t();
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, const std::function<void(QObject *target)> &t)
|
||||||
|
{
|
||||||
|
item->setter = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, QWidget *t)
|
||||||
|
{
|
||||||
|
item->onAdd = [t](LayoutBuilder &builder) { doAddWidget(builder, t); };
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, QLayout *t)
|
||||||
|
{
|
||||||
|
item->onAdd = [t](LayoutBuilder &builder) { doAddLayout(builder, t); };
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, const QString &t)
|
||||||
|
{
|
||||||
|
item->onAdd = [t](LayoutBuilder &builder) { doAddText(builder, t); };
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, const Space &t)
|
||||||
|
{
|
||||||
|
item->onAdd = [t](LayoutBuilder &builder) { doAddSpace(builder, t); };
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, const Stretch &t)
|
||||||
|
{
|
||||||
|
item->onAdd = [t](LayoutBuilder &builder) { doAddStretch(builder, t); };
|
||||||
|
}
|
||||||
|
|
||||||
|
void createItem(LayoutItem *item, const Span &t)
|
||||||
|
{
|
||||||
|
item->onAdd = [t](LayoutBuilder &builder) {
|
||||||
|
addItemHelper(builder, t.item);
|
||||||
|
builder.stack.last().pendingItems.last().span = t.span;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutItem hr()
|
||||||
|
{
|
||||||
|
LayoutItem item;
|
||||||
|
item.onAdd = [](LayoutBuilder &builder) { doAddWidget(builder, createHr()); };
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutItem st()
|
||||||
|
{
|
||||||
|
LayoutItem item;
|
||||||
|
item.onAdd = [](LayoutBuilder &builder) { doAddStretch(builder, Stretch(1)); };
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
} // Layouting
|
} // Layouting
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@@ -18,10 +17,9 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QLayout;
|
class QLayout;
|
||||||
class QSplitter;
|
class QObject;
|
||||||
class QTabWidget;
|
|
||||||
class QTextEdit;
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
template <class T> T qobject_cast(QObject *object);
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Layouting {
|
namespace Layouting {
|
||||||
@@ -34,6 +32,7 @@ enum AttachType {
|
|||||||
|
|
||||||
class LayoutBuilder;
|
class LayoutBuilder;
|
||||||
class LayoutItem;
|
class LayoutItem;
|
||||||
|
class Span;
|
||||||
|
|
||||||
// Special items
|
// Special items
|
||||||
|
|
||||||
@@ -51,28 +50,20 @@ public:
|
|||||||
const int stretch;
|
const int stretch;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Break
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Break() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Span
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Span(int span, const LayoutItem &item) : span(span), item(item) {}
|
|
||||||
const int span;
|
|
||||||
const LayoutItem &item;
|
|
||||||
};
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT HorizontalRule
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HorizontalRule() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// LayoutItem
|
// LayoutItem
|
||||||
|
|
||||||
|
using LayoutItems = QList<LayoutItem>;
|
||||||
|
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const std::function<void(QObject *target)> &t);
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, QWidget *t);
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, QLayout *t);
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, LayoutItem(*t)());
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const QString &t);
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Span &t);
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Space &t);
|
||||||
|
void QTCREATOR_UTILS_EXPORT createItem(LayoutItem *item, const Stretch &t);
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT LayoutItem
|
class QTCREATOR_UTILS_EXPORT LayoutItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -81,72 +72,81 @@ public:
|
|||||||
AlignAsFormLabel,
|
AlignAsFormLabel,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SpecialType {
|
|
||||||
NotSpecial,
|
|
||||||
Space,
|
|
||||||
Stretch,
|
|
||||||
Break,
|
|
||||||
HorizontalRule,
|
|
||||||
Tab,
|
|
||||||
};
|
|
||||||
|
|
||||||
using Setter = std::function<void(QObject *target)>;
|
using Setter = std::function<void(QObject *target)>;
|
||||||
using OnAdder = std::function<void(LayoutBuilder &)>;
|
|
||||||
|
|
||||||
LayoutItem();
|
LayoutItem();
|
||||||
|
~LayoutItem();
|
||||||
|
|
||||||
|
LayoutItem(const LayoutItem &t);
|
||||||
|
LayoutItem &operator=(const LayoutItem &t) = default;
|
||||||
|
|
||||||
template <class T> LayoutItem(const T &t)
|
template <class T> LayoutItem(const T &t)
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<QString, T>) {
|
if constexpr (std::is_base_of_v<LayoutItem, T>)
|
||||||
text = t;
|
|
||||||
} else if constexpr (std::is_same_v<Space, T>) {
|
|
||||||
specialType = LayoutItem::SpecialType::Space;
|
|
||||||
specialValue = t.space;
|
|
||||||
} else if constexpr (std::is_same_v<Stretch, T>) {
|
|
||||||
specialType = LayoutItem::SpecialType::Stretch;
|
|
||||||
specialValue = t.stretch;
|
|
||||||
} else if constexpr (std::is_same_v<Break, T>) {
|
|
||||||
specialType = LayoutItem::SpecialType::Break;
|
|
||||||
} else if constexpr (std::is_same_v<Span, T>) {
|
|
||||||
LayoutItem::operator=(t.item);
|
|
||||||
span = t.span;
|
|
||||||
} else if constexpr (std::is_same_v<HorizontalRule, T>) {
|
|
||||||
specialType = SpecialType::HorizontalRule;
|
|
||||||
} else if constexpr (std::is_base_of_v<LayoutBuilder, T>) {
|
|
||||||
setBuilder(t);
|
|
||||||
} else if constexpr (std::is_base_of_v<LayoutItem, T>) {
|
|
||||||
LayoutItem::operator=(t);
|
LayoutItem::operator=(t);
|
||||||
} else if constexpr (std::is_base_of_v<Setter, T>) {
|
else
|
||||||
setter = t;
|
createItem(this, t);
|
||||||
} else if constexpr (std::is_base_of_v<QLayout, std::remove_pointer_t<T>>) {
|
|
||||||
layout = t;
|
|
||||||
} else if constexpr (std::is_base_of_v<QWidget, std::remove_pointer_t<T>>) {
|
|
||||||
widget = t;
|
|
||||||
} else if constexpr (std::is_pointer_v<T>) {
|
|
||||||
onAdd = [t](LayoutBuilder &builder) { doLayout(*t, builder); };
|
|
||||||
} else {
|
|
||||||
onAdd = [&t](LayoutBuilder &builder) { doLayout(t, builder); };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBuilder(const LayoutBuilder &builder);
|
void attachTo(QWidget *w, AttachType attachType = WithMargins) const;
|
||||||
|
QWidget *emerge(AttachType attachType = WithMargins);
|
||||||
|
|
||||||
QLayout *layout = nullptr;
|
void addItem(const LayoutItem &item);
|
||||||
QWidget *widget = nullptr;
|
void addItems(const LayoutItems &items);
|
||||||
OnAdder onAdd;
|
void addRow(const LayoutItems &items);
|
||||||
|
void finishRow();
|
||||||
|
|
||||||
QString text; // FIXME: Use specialValue for that
|
std::function<void(LayoutBuilder &)> onAdd;
|
||||||
int span = 1;
|
std::function<void(LayoutBuilder &)> onExit;
|
||||||
AlignmentType align = AlignmentType::DefaultAlignment;
|
std::function<void(QObject *target)> setter;
|
||||||
Setter setter;
|
LayoutItems subItems;
|
||||||
SpecialType specialType = SpecialType::NotSpecial;
|
};
|
||||||
QVariant specialValue;
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT Span
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Span(int span, const LayoutItem &item) : span(span), item(item) {}
|
||||||
|
const int span;
|
||||||
|
LayoutItem item;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT Column : public LayoutItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Column(std::initializer_list<LayoutItem> items);
|
||||||
|
};
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT Row : public LayoutItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Row(std::initializer_list<LayoutItem> items);
|
||||||
|
};
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT Grid : public LayoutItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Grid() : Grid({}) {}
|
||||||
|
Grid(std::initializer_list<LayoutItem> items);
|
||||||
|
};
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT Form : public LayoutItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Form() : Form({}) {}
|
||||||
|
Form(std::initializer_list<LayoutItem> items);
|
||||||
|
};
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT Stack : public LayoutItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Stack() : Stack({}) {}
|
||||||
|
Stack(std::initializer_list<LayoutItem> items);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Tab : public LayoutItem
|
class QTCREATOR_UTILS_EXPORT Tab : public LayoutItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Tab(const QString &tabName, const LayoutBuilder &item);
|
Tab(const QString &tabName, const LayoutItem &item);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Group : public LayoutItem
|
class QTCREATOR_UTILS_EXPORT Group : public LayoutItem
|
||||||
@@ -179,124 +179,67 @@ public:
|
|||||||
TabWidget(std::initializer_list<LayoutItem> items);
|
TabWidget(std::initializer_list<LayoutItem> items);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Singleton items.
|
class QTCREATOR_UTILS_EXPORT Application : public LayoutItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Application(std::initializer_list<LayoutItem> items);
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT extern Break br;
|
int exec(int &argc, char *argv[]);
|
||||||
QTCREATOR_UTILS_EXPORT extern Stretch st;
|
};
|
||||||
QTCREATOR_UTILS_EXPORT extern Space empty;
|
|
||||||
QTCREATOR_UTILS_EXPORT extern HorizontalRule hr;
|
// "Singletons"
|
||||||
|
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutItem br();
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutItem st();
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutItem empty();
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutItem hr();
|
||||||
|
|
||||||
// "Properties"
|
// "Properties"
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT LayoutItem bindTo(QTabWidget **);
|
|
||||||
QTCREATOR_UTILS_EXPORT LayoutItem bindTo(QSplitter **);
|
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT LayoutItem title(const QString &title);
|
QTCREATOR_UTILS_EXPORT LayoutItem title(const QString &title);
|
||||||
QTCREATOR_UTILS_EXPORT LayoutItem text(const QString &text);
|
QTCREATOR_UTILS_EXPORT LayoutItem text(const QString &text);
|
||||||
QTCREATOR_UTILS_EXPORT LayoutItem tooltip(const QString &toolTip);
|
QTCREATOR_UTILS_EXPORT LayoutItem tooltip(const QString &toolTip);
|
||||||
QTCREATOR_UTILS_EXPORT LayoutItem onClicked(const std::function<void()> &func,
|
QTCREATOR_UTILS_EXPORT LayoutItem resize(int, int);
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutItem spacing(int);
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutItem windowTitle(const QString &windowTitle);
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutItem onClicked(const std::function<void()> &,
|
||||||
QObject *guard = nullptr);
|
QObject *guard = nullptr);
|
||||||
|
|
||||||
|
|
||||||
// Convenience
|
// Convenience
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT QWidget *createHr(QWidget *parent = nullptr);
|
QTCREATOR_UTILS_EXPORT QWidget *createHr(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
LayoutItem bindTo(T **out)
|
||||||
|
{
|
||||||
|
return [out](QObject *target) { *out = qobject_cast<T *>(target); };
|
||||||
|
}
|
||||||
|
|
||||||
// LayoutBuilder
|
// LayoutBuilder
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT LayoutBuilder
|
class QTCREATOR_UTILS_EXPORT LayoutBuilder
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(LayoutBuilder)
|
Q_DISABLE_COPY_MOVE(LayoutBuilder)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum LayoutType {
|
LayoutBuilder();
|
||||||
HBoxLayout,
|
|
||||||
VBoxLayout,
|
|
||||||
FormLayout,
|
|
||||||
GridLayout,
|
|
||||||
StackLayout,
|
|
||||||
};
|
|
||||||
|
|
||||||
using LayoutItems = QList<LayoutItem>;
|
|
||||||
|
|
||||||
explicit LayoutBuilder(LayoutType layoutType, const LayoutItems &items = {});
|
|
||||||
|
|
||||||
LayoutBuilder(LayoutBuilder &&) = default;
|
|
||||||
LayoutBuilder &operator=(LayoutBuilder &&) = default;
|
|
||||||
|
|
||||||
~LayoutBuilder();
|
~LayoutBuilder();
|
||||||
|
|
||||||
LayoutBuilder &setSpacing(int spacing);
|
void addItem(const LayoutItem &item);
|
||||||
|
void addItems(const LayoutItems &items);
|
||||||
|
void addRow(const LayoutItems &items);
|
||||||
|
|
||||||
LayoutBuilder &addItem(const LayoutItem &item);
|
bool isForm() const;
|
||||||
LayoutBuilder &addItems(const LayoutItems &items);
|
|
||||||
|
|
||||||
LayoutBuilder &finishRow();
|
struct Slice;
|
||||||
LayoutBuilder &addRow(const LayoutItems &items);
|
QList<Slice> stack;
|
||||||
|
|
||||||
LayoutType layoutType() const { return m_layoutType; }
|
|
||||||
|
|
||||||
void attachTo(QWidget *w, Layouting::AttachType attachType = Layouting::WithMargins) const;
|
|
||||||
QWidget *emerge(Layouting::AttachType attachType = Layouting::WithMargins);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class LayoutItem;
|
|
||||||
|
|
||||||
explicit LayoutBuilder(); // Adds to existing layout.
|
|
||||||
|
|
||||||
QLayout *createLayout() const;
|
|
||||||
void doLayout(QWidget *parent, Layouting::AttachType attachType) const;
|
|
||||||
|
|
||||||
LayoutItems m_items;
|
|
||||||
LayoutType m_layoutType;
|
|
||||||
std::optional<int> m_spacing;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT LayoutExtender : public LayoutBuilder
|
class QTCREATOR_UTILS_EXPORT LayoutExtender : public LayoutBuilder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit LayoutExtender(QLayout *layout, Layouting::AttachType attachType);
|
explicit LayoutExtender(QLayout *layout, AttachType attachType);
|
||||||
~LayoutExtender();
|
~LayoutExtender();
|
||||||
|
|
||||||
private:
|
|
||||||
QLayout *m_layout = nullptr;
|
|
||||||
Layouting::AttachType m_attachType = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Column : public LayoutBuilder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Column() : LayoutBuilder(VBoxLayout) {}
|
|
||||||
Column(std::initializer_list<LayoutItem> items) : LayoutBuilder(VBoxLayout, items) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Row : public LayoutBuilder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Row() : LayoutBuilder(HBoxLayout) {}
|
|
||||||
Row(std::initializer_list<LayoutItem> items) : LayoutBuilder(HBoxLayout, items) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Grid : public LayoutBuilder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Grid() : LayoutBuilder(GridLayout) {}
|
|
||||||
Grid(std::initializer_list<LayoutItem> items) : LayoutBuilder(GridLayout, items) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Form : public LayoutBuilder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Form() : LayoutBuilder(FormLayout) {}
|
|
||||||
Form(std::initializer_list<LayoutItem> items) : LayoutBuilder(FormLayout, items) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Stack : public LayoutBuilder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Stack() : LayoutBuilder(StackLayout) {}
|
|
||||||
Stack(std::initializer_list<LayoutItem> items) : LayoutBuilder(StackLayout, items) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Layouting
|
} // Layouting
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSett
|
|||||||
Row { m_useSpecificConfigFile, m_specificConfigFile },
|
Row { m_useSpecificConfigFile, m_specificConfigFile },
|
||||||
m_useHomeFile,
|
m_useHomeFile,
|
||||||
Row { m_useCustomStyle, m_configurations }
|
Row { m_useCustomStyle, m_configurations }
|
||||||
}.attachTo(options);
|
}.attachTo(options, WithoutMargins);
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
Group {
|
Group {
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ ClangFormatGlobalConfigWidget::ClangFormatGlobalConfigWidget(
|
|||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
|
QWidget *globalSettingsGroupBoxWidget = nullptr;
|
||||||
|
|
||||||
Group globalSettingsGroupBox {
|
Group globalSettingsGroupBox {
|
||||||
|
bindTo(&globalSettingsGroupBoxWidget),
|
||||||
title(Tr::tr("ClangFormat settings:")),
|
title(Tr::tr("ClangFormat settings:")),
|
||||||
Column {
|
Column {
|
||||||
m_useGlobalSettings,
|
m_useGlobalSettings,
|
||||||
@@ -73,7 +76,8 @@ ClangFormatGlobalConfigWidget::ClangFormatGlobalConfigWidget(
|
|||||||
m_useGlobalSettings->show();
|
m_useGlobalSettings->show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
globalSettingsGroupBox.widget->show();
|
|
||||||
|
globalSettingsGroupBoxWidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangFormatGlobalConfigWidget::~ClangFormatGlobalConfigWidget() = default;
|
ClangFormatGlobalConfigWidget::~ClangFormatGlobalConfigWidget() = default;
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|||||||
m_findEdit,
|
m_findEdit,
|
||||||
findButtonsWidget,
|
findButtonsWidget,
|
||||||
br,
|
br,
|
||||||
Column { m_replaceLabel, st }.setSpacing(0),
|
Column { spacing(0), m_replaceLabel, st },
|
||||||
Column { m_replaceEdit, st }.setSpacing(0),
|
Column { spacing(0), m_replaceEdit, st },
|
||||||
gridLayout,
|
gridLayout,
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ PasteView::PasteView(const QList<Protocol *> &protocols,
|
|||||||
}.attachTo(groupBox);
|
}.attachTo(groupBox);
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
spacing(2),
|
||||||
Form {
|
Form {
|
||||||
Tr::tr("Protocol:"), m_protocolBox, br,
|
Tr::tr("Protocol:"), m_protocolBox, br,
|
||||||
Tr::tr("&Expires after:"), m_expirySpinBox, br,
|
Tr::tr("&Expires after:"), m_expirySpinBox, br,
|
||||||
@@ -117,7 +118,7 @@ PasteView::PasteView(const QList<Protocol *> &protocols,
|
|||||||
m_uiComment,
|
m_uiComment,
|
||||||
m_stackedWidget,
|
m_stackedWidget,
|
||||||
buttonBox
|
buttonBox
|
||||||
}.setSpacing(2).attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
connect(m_uiPatchList, &QListWidget::itemChanged, this, &PasteView::contentChanged);
|
connect(m_uiPatchList, &QListWidget::itemChanged, this, &PasteView::contentChanged);
|
||||||
|
|
||||||
|
|||||||
@@ -175,8 +175,15 @@ public:
|
|||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
|
QWidget *contentGroupWidget = nullptr;
|
||||||
|
QWidget *bracesGroupWidget = nullptr;
|
||||||
|
QWidget *switchGroupWidget = nullptr;
|
||||||
|
QWidget *alignmentGroupWidget = nullptr;
|
||||||
|
QWidget *typesGroupWidget = nullptr;
|
||||||
|
|
||||||
const Group contentGroup {
|
const Group contentGroup {
|
||||||
title(Tr::tr("Indent")),
|
title(Tr::tr("Indent")),
|
||||||
|
bindTo(&contentGroupWidget),
|
||||||
Column {
|
Column {
|
||||||
m_indentAccessSpecifiers,
|
m_indentAccessSpecifiers,
|
||||||
m_indentDeclarationsRelativeToAccessSpecifiers,
|
m_indentDeclarationsRelativeToAccessSpecifiers,
|
||||||
@@ -189,6 +196,7 @@ public:
|
|||||||
|
|
||||||
const Group bracesGroup {
|
const Group bracesGroup {
|
||||||
title(Tr::tr("Indent Braces")),
|
title(Tr::tr("Indent Braces")),
|
||||||
|
bindTo(&bracesGroupWidget),
|
||||||
Column {
|
Column {
|
||||||
m_indentClassBraces,
|
m_indentClassBraces,
|
||||||
m_indentNamespaceBraces,
|
m_indentNamespaceBraces,
|
||||||
@@ -201,6 +209,7 @@ public:
|
|||||||
|
|
||||||
const Group switchGroup {
|
const Group switchGroup {
|
||||||
title(Tr::tr("Indent within \"switch\"")),
|
title(Tr::tr("Indent within \"switch\"")),
|
||||||
|
bindTo(&switchGroupWidget),
|
||||||
Column {
|
Column {
|
||||||
m_indentSwitchLabels,
|
m_indentSwitchLabels,
|
||||||
m_indentCaseStatements,
|
m_indentCaseStatements,
|
||||||
@@ -212,6 +221,7 @@ public:
|
|||||||
|
|
||||||
const Group alignmentGroup {
|
const Group alignmentGroup {
|
||||||
title(Tr::tr("Align")),
|
title(Tr::tr("Align")),
|
||||||
|
bindTo(&alignmentGroupWidget),
|
||||||
Column {
|
Column {
|
||||||
m_alignAssignments,
|
m_alignAssignments,
|
||||||
m_extraPaddingConditions,
|
m_extraPaddingConditions,
|
||||||
@@ -221,6 +231,7 @@ public:
|
|||||||
|
|
||||||
const Group typesGroup {
|
const Group typesGroup {
|
||||||
title(Tr::tr("Bind '*' and '&&' in types/declarations to")),
|
title(Tr::tr("Bind '*' and '&&' in types/declarations to")),
|
||||||
|
bindTo(&typesGroupWidget),
|
||||||
Column {
|
Column {
|
||||||
m_bindStarToIdentifier,
|
m_bindStarToIdentifier,
|
||||||
m_bindStarToTypeName,
|
m_bindStarToTypeName,
|
||||||
@@ -247,11 +258,11 @@ public:
|
|||||||
m_categoryTab->setProperty("_q_custom_style_disabled", true);
|
m_categoryTab->setProperty("_q_custom_style_disabled", true);
|
||||||
|
|
||||||
m_controllers.append(m_tabSettingsWidget);
|
m_controllers.append(m_tabSettingsWidget);
|
||||||
m_controllers.append(contentGroup.widget);
|
m_controllers.append(contentGroupWidget);
|
||||||
m_controllers.append(bracesGroup.widget);
|
m_controllers.append(bracesGroupWidget);
|
||||||
m_controllers.append(switchGroup.widget);
|
m_controllers.append(switchGroupWidget);
|
||||||
m_controllers.append(alignmentGroup.widget);
|
m_controllers.append(alignmentGroupWidget);
|
||||||
m_controllers.append(typesGroup.widget);
|
m_controllers.append(typesGroupWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
QCheckBox *createCheckBox(const QString &text, const QString &toolTip = {})
|
QCheckBox *createCheckBox(const QString &text, const QString &toolTip = {})
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ void SourcePathMapAspect::addToLayout(Layouting::LayoutBuilder &builder)
|
|||||||
QTC_CHECK(!d->m_widget);
|
QTC_CHECK(!d->m_widget);
|
||||||
d->m_widget = createSubWidget<DebuggerSourcePathMappingWidget>();
|
d->m_widget = createSubWidget<DebuggerSourcePathMappingWidget>();
|
||||||
d->m_widget->setSourcePathMap(value());
|
d->m_widget->setSourcePathMap(value());
|
||||||
builder.addRow({d->m_widget.data()});
|
builder.addItem(d->m_widget.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SourcePathMapAspect::volatileValue() const
|
QVariant SourcePathMapAspect::volatileValue() const
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ MesonBuildSettingsWidget::MesonBuildSettingsWidget(MesonBuildConfiguration *buil
|
|||||||
Row { configureButton, wipeButton, }
|
Row { configureButton, wipeButton, }
|
||||||
}.attachTo(this, WithoutMargins);
|
}.attachTo(this, WithoutMargins);
|
||||||
|
|
||||||
Form buildDirWBuilder;
|
Form {
|
||||||
buildCfg->buildDirectoryAspect()->addToLayout(buildDirWBuilder);
|
buildCfg->buildDirectoryAspect(),
|
||||||
buildDirWBuilder.attachTo(buildDirWidget, WithoutMargins);
|
}.attachTo(buildDirWidget, WithoutMargins);
|
||||||
|
|
||||||
parametersLineEdit->setText(buildCfg->parameters());
|
parametersLineEdit->setText(buildCfg->parameters());
|
||||||
optionsFilterLineEdit->setFiltering(true);
|
optionsFilterLineEdit->setFiltering(true);
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ void BuildDirectoryAspect::addToLayout(Layouting::LayoutBuilder &builder)
|
|||||||
StringAspect::addToLayout(builder);
|
StringAspect::addToLayout(builder);
|
||||||
d->problemLabel = new InfoLabel({}, InfoLabel::Warning);
|
d->problemLabel = new InfoLabel({}, InfoLabel::Warning);
|
||||||
d->problemLabel->setElideMode(Qt::ElideNone);
|
d->problemLabel->setElideMode(Qt::ElideNone);
|
||||||
builder.addRow({{}, d->problemLabel.data()});
|
builder.addItems({{}, d->problemLabel.data()});
|
||||||
updateProblemLabel();
|
updateProblemLabel();
|
||||||
if (!d->sourceDir.isEmpty()) {
|
if (!d->sourceDir.isEmpty()) {
|
||||||
connect(this, &StringAspect::checkedChanged, this, [this] {
|
connect(this, &StringAspect::checkedChanged, this, [this] {
|
||||||
|
|||||||
@@ -322,12 +322,12 @@ NamedWidget *BuildConfiguration::createConfigWidget()
|
|||||||
widget = named;
|
widget = named;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layouting::Form builder;
|
Layouting::Form form;
|
||||||
for (BaseAspect *aspect : aspects()) {
|
for (BaseAspect *aspect : aspects()) {
|
||||||
if (aspect->isVisible())
|
if (aspect->isVisible())
|
||||||
aspect->addToLayout(builder.finishRow());
|
form.addItem(aspect);
|
||||||
}
|
}
|
||||||
builder.attachTo(widget, Layouting::WithoutMargins);
|
form.attachTo(widget, Layouting::WithoutMargins);
|
||||||
|
|
||||||
return named;
|
return named;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,12 +160,12 @@ QWidget *BuildStep::doCreateConfigWidget()
|
|||||||
|
|
||||||
QWidget *BuildStep::createConfigWidget()
|
QWidget *BuildStep::createConfigWidget()
|
||||||
{
|
{
|
||||||
Layouting::Form builder;
|
Layouting::Form form;
|
||||||
for (BaseAspect *aspect : std::as_const(m_aspects)) {
|
for (BaseAspect *aspect : std::as_const(m_aspects)) {
|
||||||
if (aspect->isVisible())
|
if (aspect->isVisible())
|
||||||
aspect->addToLayout(builder.finishRow());
|
form.addItem(aspect);
|
||||||
}
|
}
|
||||||
auto widget = builder.emerge(Layouting::WithoutMargins);
|
auto widget = form.emerge(Layouting::WithoutMargins);
|
||||||
|
|
||||||
if (m_addMacroExpander)
|
if (m_addMacroExpander)
|
||||||
VariableChooser::addSupportForChildWidgets(widget, macroExpander());
|
VariableChooser::addSupportForChildWidgets(widget, macroExpander());
|
||||||
|
|||||||
@@ -757,8 +757,7 @@ void KitAspectWidget::addToLayoutWithLabel(QWidget *parent)
|
|||||||
});
|
});
|
||||||
|
|
||||||
Layouting::LayoutExtender builder(parent->layout(), Layouting::WithFormAlignment);
|
Layouting::LayoutExtender builder(parent->layout(), Layouting::WithFormAlignment);
|
||||||
builder.finishRow();
|
builder.addItems({label, Layouting::br});
|
||||||
builder.addItem(label);
|
|
||||||
addToLayout(builder);
|
addToLayout(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -551,6 +551,11 @@ int SelectorView::padding()
|
|||||||
/////////
|
/////////
|
||||||
// KitAreaWidget
|
// KitAreaWidget
|
||||||
/////////
|
/////////
|
||||||
|
void doLayout(KitAspectWidget *widget, Layouting::LayoutBuilder &builder)
|
||||||
|
{
|
||||||
|
widget->addToLayout(builder);
|
||||||
|
}
|
||||||
|
|
||||||
class KitAreaWidget : public QWidget
|
class KitAreaWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -573,18 +578,15 @@ public:
|
|||||||
|
|
||||||
delete layout();
|
delete layout();
|
||||||
|
|
||||||
Layouting::LayoutBuilder builder(Layouting::LayoutBuilder::GridLayout);
|
Layouting::Grid grid;
|
||||||
for (KitAspect *aspect : KitManager::kitAspects()) {
|
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
if (k && k->isMutable(aspect->id())) {
|
if (k && k->isMutable(aspect->id())) {
|
||||||
KitAspectWidget *widget = aspect->createConfigWidget(k);
|
KitAspectWidget *widget = aspect->createConfigWidget(k);
|
||||||
m_widgets << widget;
|
m_widgets << widget;
|
||||||
QLabel *label = new QLabel(aspect->displayName());
|
grid.addItems({aspect->displayName(), widget, Layouting::br});
|
||||||
builder.addItem(label);
|
|
||||||
widget->addToLayout(builder);
|
|
||||||
builder.finishRow();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder.attachTo(this);
|
grid.attachTo(this);
|
||||||
layout()->setContentsMargins(3, 3, 3, 3);
|
layout()->setContentsMargins(3, 3, 3, 3);
|
||||||
|
|
||||||
m_kit = k;
|
m_kit = k;
|
||||||
|
|||||||
@@ -216,13 +216,13 @@ bool RunConfiguration::isEnabled() const
|
|||||||
|
|
||||||
QWidget *RunConfiguration::createConfigurationWidget()
|
QWidget *RunConfiguration::createConfigurationWidget()
|
||||||
{
|
{
|
||||||
Layouting::Form builder;
|
Layouting::Form form;
|
||||||
for (BaseAspect *aspect : std::as_const(m_aspects)) {
|
for (BaseAspect *aspect : std::as_const(m_aspects)) {
|
||||||
if (aspect->isVisible())
|
if (aspect->isVisible())
|
||||||
aspect->addToLayout(builder.finishRow());
|
form.addItem(aspect);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto widget = builder.emerge(Layouting::WithoutMargins);
|
auto widget = form.emerge(Layouting::WithoutMargins);
|
||||||
|
|
||||||
VariableChooser::addSupportForChildWidgets(widget, &m_expander);
|
VariableChooser::addSupportForChildWidgets(widget, &m_expander);
|
||||||
|
|
||||||
|
|||||||
@@ -634,9 +634,9 @@ FilePath ExecutableAspect::executable() const
|
|||||||
*/
|
*/
|
||||||
void ExecutableAspect::addToLayout(LayoutBuilder &builder)
|
void ExecutableAspect::addToLayout(LayoutBuilder &builder)
|
||||||
{
|
{
|
||||||
m_executable.addToLayout(builder);
|
builder.addItem(m_executable);
|
||||||
if (m_alternativeExecutable)
|
if (m_alternativeExecutable)
|
||||||
m_alternativeExecutable->addToLayout(builder.finishRow());
|
builder.addItems({br, m_alternativeExecutable});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -658,25 +658,26 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step)
|
|||||||
installDirChooser = new PathChooser(this);
|
installDirChooser = new PathChooser(this);
|
||||||
installDirChooser->setExpectedKind(PathChooser::Directory);
|
installDirChooser->setExpectedKind(PathChooser::Directory);
|
||||||
|
|
||||||
Layouting::Form builder;
|
using namespace Layouting;
|
||||||
builder.addRow({m_qbsStep->m_buildVariant});
|
Form {
|
||||||
builder.addRow({m_qbsStep->m_selectedAbis});
|
m_qbsStep->m_buildVariant, br,
|
||||||
builder.addRow({m_qbsStep->m_maxJobCount});
|
m_qbsStep->m_selectedAbis, br,
|
||||||
builder.addRow({QbsProjectManager::Tr::tr("Properties:"), propertyEdit});
|
m_qbsStep->m_maxJobCount, br,
|
||||||
|
QbsProjectManager::Tr::tr("Properties:"), propertyEdit, br,
|
||||||
|
|
||||||
builder.addRow({QbsProjectManager::Tr::tr("Flags:")});
|
QbsProjectManager::Tr::tr("Flags:"),
|
||||||
m_qbsStep->m_keepGoing->addToLayout(builder);
|
m_qbsStep->m_keepGoing,
|
||||||
m_qbsStep->m_showCommandLines->addToLayout(builder);
|
m_qbsStep->m_showCommandLines,
|
||||||
m_qbsStep->m_forceProbes->addToLayout(builder);
|
m_qbsStep->m_forceProbes, br,
|
||||||
|
|
||||||
builder.addRow({QbsProjectManager::Tr::tr("Installation flags:")});
|
QbsProjectManager::Tr::tr("Installation flags:"),
|
||||||
m_qbsStep->m_install->addToLayout(builder);
|
m_qbsStep->m_install,
|
||||||
m_qbsStep->m_cleanInstallDir->addToLayout(builder);
|
m_qbsStep->m_cleanInstallDir,
|
||||||
builder.addItem(defaultInstallDirCheckBox);
|
defaultInstallDirCheckBox, br,
|
||||||
|
|
||||||
builder.addRow({QbsProjectManager::Tr::tr("Installation directory:"), installDirChooser});
|
QbsProjectManager::Tr::tr("Installation directory:"), installDirChooser, br,
|
||||||
builder.addRow({m_qbsStep->m_commandLine});
|
m_qbsStep->m_commandLine, br,
|
||||||
builder.attachTo(this, Layouting::WithoutMargins);
|
}.attachTo(this, Layouting::WithoutMargins);
|
||||||
|
|
||||||
propertyEdit->setToolTip(QbsProjectManager::Tr::tr("Properties to pass to the project."));
|
propertyEdit->setToolTip(QbsProjectManager::Tr::tr("Properties to pass to the project."));
|
||||||
defaultInstallDirCheckBox->setText(QbsProjectManager::Tr::tr("Use default location"));
|
defaultInstallDirCheckBox->setText(QbsProjectManager::Tr::tr("Use default location"));
|
||||||
|
|||||||
@@ -172,15 +172,12 @@ QWidget *QbsInstallStep::createConfigWidget()
|
|||||||
commandLineTextEdit->setTextInteractionFlags(Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse);
|
commandLineTextEdit->setTextInteractionFlags(Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse);
|
||||||
commandLineTextEdit->setMinimumHeight(QFontMetrics(widget->font()).height() * 8);
|
commandLineTextEdit->setMinimumHeight(QFontMetrics(widget->font()).height() * 8);
|
||||||
|
|
||||||
Layouting::Form builder;
|
using namespace Layouting;
|
||||||
builder.addRow({Tr::tr("Install root:"), installRootValueLabel});
|
Form {
|
||||||
builder.addRow({Tr::tr("Flags:")});
|
Tr::tr("Install root:"), installRootValueLabel, br,
|
||||||
m_dryRun->addToLayout(builder);
|
Tr::tr("Flags:"), m_dryRun, m_keepGoing, m_cleanInstallRoot, br,
|
||||||
m_keepGoing->addToLayout(builder);
|
commandLineKeyLabel, commandLineTextEdit
|
||||||
m_cleanInstallRoot->addToLayout(builder);
|
}.attachTo(widget);
|
||||||
|
|
||||||
builder.addRow({commandLineKeyLabel, commandLineTextEdit});
|
|
||||||
builder.attachTo(widget);
|
|
||||||
|
|
||||||
const auto updateState = [this, commandLineTextEdit, installRootValueLabel] {
|
const auto updateState = [this, commandLineTextEdit, installRootValueLabel] {
|
||||||
installRootValueLabel->setText(installRoot().toUserOutput());
|
installRootValueLabel->setText(installRoot().toUserOutput());
|
||||||
|
|||||||
@@ -246,10 +246,13 @@ public:
|
|||||||
QObject::connect(useQmlls, &QCheckBox::stateChanged, this, [this](int checked) {
|
QObject::connect(useQmlls, &QCheckBox::stateChanged, this, [this](int checked) {
|
||||||
useLatestQmlls->setEnabled(checked != Qt::Unchecked);
|
useLatestQmlls->setEnabled(checked != Qt::Unchecked);
|
||||||
});
|
});
|
||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const auto formattingGroup =
|
QWidget *formattingGroup = nullptr;
|
||||||
|
Column {
|
||||||
Group {
|
Group {
|
||||||
|
bindTo(&formattingGroup),
|
||||||
title(Tr::tr("Automatic Formatting on File Save")),
|
title(Tr::tr("Automatic Formatting on File Save")),
|
||||||
Column {
|
Column {
|
||||||
autoFormatOnSave,
|
autoFormatOnSave,
|
||||||
@@ -260,10 +263,7 @@ public:
|
|||||||
formatCommandOptionsLabel, formatCommandOptions
|
formatCommandOptionsLabel, formatCommandOptions
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
|
|
||||||
Column {
|
|
||||||
formattingGroup,
|
|
||||||
Group {
|
Group {
|
||||||
title(Tr::tr("Qt Quick Toolbars")),
|
title(Tr::tr("Qt Quick Toolbars")),
|
||||||
Column { pinContextPane, enableContextPane },
|
Column { pinContextPane, enableContextPane },
|
||||||
@@ -283,7 +283,7 @@ public:
|
|||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
Utils::VariableChooser::addSupportForChildWidgets(formattingGroup.widget,
|
Utils::VariableChooser::addSupportForChildWidgets(formattingGroup,
|
||||||
Utils::globalMacroExpander());
|
Utils::globalMacroExpander());
|
||||||
|
|
||||||
const auto updateFormatCommandState = [&, formatCommandLabel, formatCommandOptionsLabel] {
|
const auto updateFormatCommandState = [&, formatCommandLabel, formatCommandOptionsLabel] {
|
||||||
|
|||||||
@@ -31,11 +31,12 @@ NavigatorSlider::NavigatorSlider(QWidget *parent)
|
|||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
Row {
|
Row {
|
||||||
|
spacing(0),
|
||||||
zoomOut,
|
zoomOut,
|
||||||
m_slider,
|
m_slider,
|
||||||
zoomIn,
|
zoomIn,
|
||||||
Space(20),
|
Space(20),
|
||||||
}.setSpacing(0).attachTo(this, WithoutMargins);
|
}.attachTo(this, WithoutMargins);
|
||||||
|
|
||||||
connect(zoomOut, &QToolButton::clicked, this, &NavigatorSlider::zoomOut);
|
connect(zoomOut, &QToolButton::clicked, this, &NavigatorSlider::zoomOut);
|
||||||
connect(zoomIn, &QToolButton::clicked, this, &NavigatorSlider::zoomIn);
|
connect(zoomIn, &QToolButton::clicked, this, &NavigatorSlider::zoomIn);
|
||||||
|
|||||||
@@ -47,9 +47,10 @@ Search::Search(QWidget *parent)
|
|||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
Column {
|
Column {
|
||||||
|
spacing(0),
|
||||||
m_searchEdit,
|
m_searchEdit,
|
||||||
m_searchView,
|
m_searchView,
|
||||||
}.setSpacing(0).attachTo(this, WithoutMargins);
|
}.attachTo(this, WithoutMargins);
|
||||||
|
|
||||||
connect(m_searchEdit, &Utils::FancyLineEdit::textChanged, this, &Search::setSearchText);
|
connect(m_searchEdit, &Utils::FancyLineEdit::textChanged, this, &Search::setSearchText);
|
||||||
connect(m_searchView, &TableView::pressed, this, &Search::rowActivated);
|
connect(m_searchView, &TableView::pressed, this, &Search::rowActivated);
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ ShapesToolbox::ShapesToolbox(QWidget *parent)
|
|||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
Column {
|
Column {
|
||||||
|
spacing(0),
|
||||||
scrollArea,
|
scrollArea,
|
||||||
}.setSpacing(0).attachTo(this, WithoutMargins);
|
}.attachTo(this, WithoutMargins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapesToolbox::setUIFactory(ScxmlEditor::PluginInterface::ScxmlUiFactory *factory)
|
void ShapesToolbox::setUIFactory(ScxmlEditor::PluginInterface::ScxmlUiFactory *factory)
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ StateView::StateView(StateItem *state, QWidget *parent)
|
|||||||
}.attachTo(titleBar, WithoutMargins);
|
}.attachTo(titleBar, WithoutMargins);
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
titleBar, m_graphicsView
|
spacing(0),
|
||||||
}.setSpacing(0).attachTo(this, WithoutMargins);
|
titleBar,
|
||||||
|
m_graphicsView
|
||||||
|
}.attachTo(this, WithoutMargins);
|
||||||
|
|
||||||
initScene();
|
initScene();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
return app.exec(argc, argv);
|
||||||
ApplicationWindow w;
|
|
||||||
w.show();
|
|
||||||
return a.exec();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,14 @@
|
|||||||
|
|
||||||
#include "layoutbuilder.h"
|
#include "layoutbuilder.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QApplication>
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
class ApplicationWindow : public QWidget
|
Application app
|
||||||
{
|
{
|
||||||
public:
|
resize(600, 400),
|
||||||
ApplicationWindow()
|
title("Hello World"),
|
||||||
{
|
|
||||||
resize(600, 400);
|
|
||||||
setWindowTitle("Hello World");
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
TextEdit {
|
TextEdit {
|
||||||
@@ -22,8 +18,7 @@ public:
|
|||||||
|
|
||||||
PushButton {
|
PushButton {
|
||||||
text("Quit"),
|
text("Quit"),
|
||||||
onClicked([] { QCoreApplication::quit(); })
|
onClicked([] { QApplication::quit(); })
|
||||||
}
|
}
|
||||||
}.attachTo(this);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import QtQuick
|
|||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow
|
||||||
|
{
|
||||||
width: 640
|
width: 640
|
||||||
height: 480
|
height: 480
|
||||||
visible: true
|
visible: true
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ public:
|
|||||||
l->addWidget(pushButton);
|
l->addWidget(pushButton);
|
||||||
|
|
||||||
connect(pushButton, &QPushButton::clicked,
|
connect(pushButton, &QPushButton::clicked,
|
||||||
qApp, &QCoreApplication::quit);
|
qApp, &QApplication::quit);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -184,11 +184,8 @@ Tasking::WorkflowPolicy GroupWidget::workflowPolicy() const
|
|||||||
return m_workflowPolicy;
|
return m_workflowPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createItem(Layouting::LayoutItem *item, const TaskGroup &taskGroup)
|
||||||
void doLayout(const TaskGroup &taskGroup, LayoutBuilder &builder)
|
|
||||||
{
|
{
|
||||||
builder.addItem(taskGroup.group);
|
item->addItems({taskGroup.group, Group { taskGroup.items }, br});
|
||||||
builder.addItem(Group { taskGroup.items });
|
|
||||||
builder.finishRow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,4 +83,4 @@ public:
|
|||||||
Layouting::Column items;
|
Layouting::Column items;
|
||||||
};
|
};
|
||||||
|
|
||||||
void doLayout(const TaskGroup &taskGroup, Layouting::LayoutBuilder &builder);
|
void createItem(Layouting::LayoutItem *item, const TaskGroup &taskGroup);
|
||||||
|
|||||||
Reference in New Issue
Block a user