forked from qt-creator/qt-creator
Utils: Make Layouting::Title even less special
This goes a bit in the direction of property settigs for arbitrary layout items. Change-Id: I98500e213e3b22cc99038a1bcf688183588be248 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -460,13 +460,6 @@ LayoutBuilder::Space::Space(int space)
|
|||||||
specialValue = space;
|
specialValue = space;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutBuilder::Title::Title(const QString &title, BoolAspect *check)
|
|
||||||
{
|
|
||||||
specialType = SpecialType::Title;
|
|
||||||
specialValue = title;
|
|
||||||
aspect = check;
|
|
||||||
}
|
|
||||||
|
|
||||||
LayoutBuilder::Span::Span(int span_, const LayoutItem &item)
|
LayoutBuilder::Span::Span(int span_, const LayoutItem &item)
|
||||||
{
|
{
|
||||||
LayoutBuilder::LayoutItem::operator=(item);
|
LayoutBuilder::LayoutItem::operator=(item);
|
||||||
@@ -482,23 +475,38 @@ LayoutBuilder::AlignAsFormLabel::AlignAsFormLabel(const LayoutItem &item)
|
|||||||
namespace Layouting {
|
namespace Layouting {
|
||||||
|
|
||||||
Group::Group(const LayoutBuilder &innerLayout)
|
Group::Group(const LayoutBuilder &innerLayout)
|
||||||
: Group(Title({}), innerLayout)
|
: Group({}, innerLayout)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Group::Group(const LayoutBuilder::Title &title, const LayoutBuilder &innerLayout)
|
Group::Group(const LayoutBuilder::Setters &setters, const LayoutBuilder &innerLayout)
|
||||||
{
|
{
|
||||||
auto box = new QGroupBox;
|
auto box = new QGroupBox;
|
||||||
|
innerLayout.attachTo(box, true);
|
||||||
box->setTitle(title.specialValue.toString());
|
for (const LayoutBuilder::Setter &func : setters)
|
||||||
box->setObjectName(title.specialValue.toString());
|
func(box);
|
||||||
if (auto check = qobject_cast<BoolAspect *>(title.aspect)) {
|
widget = box;
|
||||||
box->setCheckable(true);
|
|
||||||
box->setChecked(check->value());
|
|
||||||
check->setHandlesGroup(box);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
innerLayout.attachTo(box, true);
|
LayoutBuilder::Setter Title(const QString &title, BoolAspect *checker)
|
||||||
widget = box;
|
{
|
||||||
|
return Layouting::title(title, checker);
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutBuilder::Setter title(const QString &title, BoolAspect *checker)
|
||||||
|
{
|
||||||
|
return [title, checker](QObject *target) {
|
||||||
|
if (auto groupBox = qobject_cast<QGroupBox *>(target)) {
|
||||||
|
groupBox->setTitle(title);
|
||||||
|
groupBox->setObjectName(title);
|
||||||
|
if (checker) {
|
||||||
|
groupBox->setCheckable(true);
|
||||||
|
groupBox->setChecked(checker->value());
|
||||||
|
checker->setHandlesGroup(groupBox);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Layouting
|
} // Layouting
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public:
|
|||||||
Space,
|
Space,
|
||||||
Stretch,
|
Stretch,
|
||||||
Break,
|
Break,
|
||||||
Title,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT LayoutItem
|
class QTCREATOR_UTILS_EXPORT LayoutItem
|
||||||
@@ -143,10 +142,13 @@ public:
|
|||||||
Break();
|
Break();
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Title : public LayoutItem
|
using Setter = std::function<void(QObject *target)>;
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT Setters : public std::vector<Setter>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Title(const QString &title, BoolAspect *check = nullptr);
|
using std::vector<Setter>::vector;
|
||||||
|
Setters(const Setter &setter) { push_back(setter); }
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -172,11 +174,17 @@ private:
|
|||||||
|
|
||||||
namespace Layouting {
|
namespace Layouting {
|
||||||
|
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutBuilder::Setter title(const QString &title,
|
||||||
|
BoolAspect *checker = nullptr);
|
||||||
|
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutBuilder::Setter Title(const QString &title,
|
||||||
|
BoolAspect *checker = nullptr); // FIXME: Remove
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Group : public LayoutBuilder::LayoutItem
|
class QTCREATOR_UTILS_EXPORT Group : public LayoutBuilder::LayoutItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Group(const LayoutBuilder &innerLayout);
|
explicit Group(const LayoutBuilder &innerLayout);
|
||||||
Group(const LayoutBuilder::Title &title, const LayoutBuilder &innerLayout);
|
Group(const LayoutBuilder::Setters &setters, const LayoutBuilder &innerLayout);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Column : public LayoutBuilder
|
class QTCREATOR_UTILS_EXPORT Column : public LayoutBuilder
|
||||||
@@ -212,7 +220,6 @@ using Space = LayoutBuilder::Space;
|
|||||||
using Span = LayoutBuilder::Span;
|
using Span = LayoutBuilder::Span;
|
||||||
using AlignAsFormLabel = LayoutBuilder::AlignAsFormLabel;
|
using AlignAsFormLabel = LayoutBuilder::AlignAsFormLabel;
|
||||||
using Break = LayoutBuilder::Break;
|
using Break = LayoutBuilder::Break;
|
||||||
using Title = LayoutBuilder::Title;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
DebuggerSettings &s = *debuggerSettings();
|
DebuggerSettings &s = *debuggerSettings();
|
||||||
|
|
||||||
Group general {
|
Group general {
|
||||||
Title { Tr::tr("General") },
|
title(Tr::tr("General")),
|
||||||
Column {
|
Column {
|
||||||
Row { s.gdbWatchdogTimeout, Stretch() },
|
Row { s.gdbWatchdogTimeout, Stretch() },
|
||||||
s.skipKnownFrames,
|
s.skipKnownFrames,
|
||||||
@@ -77,11 +77,11 @@ public:
|
|||||||
|
|
||||||
Column commands {
|
Column commands {
|
||||||
Group {
|
Group {
|
||||||
Title { Tr::tr("Additional Startup Commands") },
|
title(Tr::tr("Additional Startup Commands")),
|
||||||
Column { s.gdbStartupCommands }
|
Column { s.gdbStartupCommands }
|
||||||
},
|
},
|
||||||
Group {
|
Group {
|
||||||
Title { Tr::tr("Additional Attach Commands") },
|
title(Tr::tr("Additional Attach Commands")),
|
||||||
Column { s.gdbPostAttachCommands },
|
Column { s.gdbPostAttachCommands },
|
||||||
},
|
},
|
||||||
Stretch()
|
Stretch()
|
||||||
|
|||||||
Reference in New Issue
Block a user