forked from qt-creator/qt-creator
Utils: Make contents margins handling less special
Change-Id: I985419bbb213aba899c83efb49b376e0f3338bd5 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -73,7 +73,7 @@ ModelTreeFilter::ModelTreeFilter(QWidget *parent) :
|
|||||||
},
|
},
|
||||||
d->relationsCheckBox,
|
d->relationsCheckBox,
|
||||||
d->diagramElementsCheckBox,
|
d->diagramElementsCheckBox,
|
||||||
customMargin({margin, 0, margin, 0}),
|
customMargins(margin, 0, margin, 0),
|
||||||
},
|
},
|
||||||
Space(10),
|
Space(10),
|
||||||
line(),
|
line(),
|
||||||
@@ -88,11 +88,11 @@ ModelTreeFilter::ModelTreeFilter(QWidget *parent) :
|
|||||||
Tr::tr("Name:"), d->nameLineEdit, br,
|
Tr::tr("Name:"), d->nameLineEdit, br,
|
||||||
Tr::tr("Direction:"), d->directionComboBox, br,
|
Tr::tr("Direction:"), d->directionComboBox, br,
|
||||||
},
|
},
|
||||||
customMargin({margin, 0, margin, 0}),
|
customMargins(margin, 0, margin, 0),
|
||||||
},
|
},
|
||||||
st,
|
st,
|
||||||
line(),
|
line(),
|
||||||
customMargin({0, margin, 0, 0}),
|
customMargins(0, margin, 0, 0),
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
connect(d->resetViewButton, &QPushButton::clicked, this, &ModelTreeFilter::resetView);
|
connect(d->resetViewButton, &QPushButton::clicked, this, &ModelTreeFilter::resetView);
|
||||||
|
@@ -341,17 +341,17 @@ void Layout::span(int cols, int rows)
|
|||||||
|
|
||||||
void Layout::setNoMargins()
|
void Layout::setNoMargins()
|
||||||
{
|
{
|
||||||
setContentMargins({});
|
setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::setNormalMargins()
|
void Layout::setNormalMargins()
|
||||||
{
|
{
|
||||||
setContentMargins({9, 9, 9, 9});
|
setContentsMargins(9, 9, 9, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::setContentMargins(const QMargins &margin)
|
void Layout::setContentsMargins(int left, int top, int right, int bottom)
|
||||||
{
|
{
|
||||||
access(this)->setContentsMargins(margin);
|
access(this)->setContentsMargins(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -726,17 +726,17 @@ void Widget::show()
|
|||||||
|
|
||||||
void Widget::setNoMargins(int)
|
void Widget::setNoMargins(int)
|
||||||
{
|
{
|
||||||
setContentMargins({});
|
setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setNormalMargins(int)
|
void Widget::setNormalMargins(int)
|
||||||
{
|
{
|
||||||
setContentMargins({9, 9, 9, 9});
|
setContentsMargins(9, 9, 9, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setContentMargins(const QMargins &margins)
|
void Widget::setContentsMargins(int left, int top, int right, int bottom)
|
||||||
{
|
{
|
||||||
access(this)->setContentsMargins(margins);
|
access(this)->setContentsMargins(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *Widget::emerge() const
|
QWidget *Widget::emerge() const
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMargins>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -26,7 +25,6 @@ class QGroupBox;
|
|||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLayout;
|
class QLayout;
|
||||||
class QMargins;
|
|
||||||
class QObject;
|
class QObject;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QSpinBox;
|
class QSpinBox;
|
||||||
@@ -52,6 +50,15 @@ public:
|
|||||||
const T2 arg; // FIXME: Could be const &, but this would currently break bindTo().
|
const T2 arg; // FIXME: Could be const &, but this would currently break bindTo().
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
struct Arg2 { const T1 p1; const T2 p2; };
|
||||||
|
|
||||||
|
template <typename T1, typename T2, typename T3>
|
||||||
|
struct Arg3 { const T1 p1; const T2 p2; const T3 p3; };
|
||||||
|
|
||||||
|
template <typename T1, typename T2, typename T3, typename T4>
|
||||||
|
struct Arg4 { const T1 p1; const T2 p2; const T3 p3; const T4 p4; };
|
||||||
|
|
||||||
// The main dispatcher
|
// The main dispatcher
|
||||||
|
|
||||||
void doit(auto x, auto id, auto p);
|
void doit(auto x, auto id, auto p);
|
||||||
@@ -142,7 +149,7 @@ public:
|
|||||||
|
|
||||||
void setNoMargins();
|
void setNoMargins();
|
||||||
void setNormalMargins();
|
void setNormalMargins();
|
||||||
void setContentMargins(const QMargins &margin);
|
void setContentsMargins(int left, int top, int right, int bottom);
|
||||||
void setColumnStretch(int cols, int rows);
|
void setColumnStretch(int cols, int rows);
|
||||||
void setSpacing(int space);
|
void setSpacing(int space);
|
||||||
void setFieldGrowthPolicy(int policy);
|
void setFieldGrowthPolicy(int policy);
|
||||||
@@ -268,7 +275,7 @@ public:
|
|||||||
void setToolTip(const QString &);
|
void setToolTip(const QString &);
|
||||||
void setNoMargins(int = 0);
|
void setNoMargins(int = 0);
|
||||||
void setNormalMargins(int = 0);
|
void setNormalMargins(int = 0);
|
||||||
void setContentMargins(const QMargins &);
|
void setContentsMargins(int left, int top, int right, int bottom);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Label : public Widget
|
class QTCREATOR_UTILS_EXPORT Label : public Widget
|
||||||
@@ -448,13 +455,18 @@ void doit(Interface *x, IdId, auto p)
|
|||||||
|
|
||||||
#define QTCREATOR_SETTER2(name, setter) \
|
#define QTCREATOR_SETTER2(name, setter) \
|
||||||
class name##_TAG {}; \
|
class name##_TAG {}; \
|
||||||
inline auto name(auto p1, auto p2) { return IdAndArg{name##_TAG{}, std::pair{p1, p2}}; } \
|
inline auto name(auto p1, auto p2) { return IdAndArg{name##_TAG{}, Arg2{p1, p2}}; } \
|
||||||
inline void doit(auto x, name##_TAG, auto p) { x->setter(p.first, p.second); }
|
inline void doit(auto x, name##_TAG, auto p) { x->setter(p.p1, p.p2); }
|
||||||
|
|
||||||
#define QTCREATOR_TYPED_SETTER(name, setter, type) \
|
#define QTCREATOR_SETTER3(name, setter) \
|
||||||
class name##_TAG {}; \
|
class name##_TAG {}; \
|
||||||
inline auto name(type p) { return IdAndArg{name##_TAG{}, p}; } \
|
inline auto name(auto p1, auto p2, auto p3) { return IdAndArg{name##_TAG{}, Arg4{p1, p2, p3}}; } \
|
||||||
inline void doit(auto x, name##_TAG, auto p) { x->setter(p); }
|
inline void doit(auto x, name##_TAG, auto p) { x->setter(p.p1, p.p2, p.p3); }
|
||||||
|
|
||||||
|
#define QTCREATOR_SETTER4(name, setter) \
|
||||||
|
class name##_TAG {}; \
|
||||||
|
inline auto name(auto p1, auto p2, auto p3, auto p4) { return IdAndArg{name##_TAG{}, Arg4{p1, p2, p3, p4}}; } \
|
||||||
|
inline void doit(auto x, name##_TAG, auto p) { x->setter(p.p1, p.p2, p.p3, p.p4); }
|
||||||
|
|
||||||
QTCREATOR_SETTER(fieldGrowthPolicy, setFieldGrowthPolicy);
|
QTCREATOR_SETTER(fieldGrowthPolicy, setFieldGrowthPolicy);
|
||||||
QTCREATOR_SETTER(groupChecker, setGroupChecker);
|
QTCREATOR_SETTER(groupChecker, setGroupChecker);
|
||||||
@@ -471,8 +483,7 @@ QTCREATOR_SETTER2(columnStretch, setColumnStretch);
|
|||||||
QTCREATOR_SETTER2(onClicked, onClicked);
|
QTCREATOR_SETTER2(onClicked, onClicked);
|
||||||
QTCREATOR_SETTER2(onLinkHovered, onLinkHovered);
|
QTCREATOR_SETTER2(onLinkHovered, onLinkHovered);
|
||||||
QTCREATOR_SETTER2(onTextChanged, onTextChanged);
|
QTCREATOR_SETTER2(onTextChanged, onTextChanged);
|
||||||
|
QTCREATOR_SETTER4(customMargins, setContentsMargins);
|
||||||
QTCREATOR_TYPED_SETTER(customMargin, setContentMargins, const QMargins &);
|
|
||||||
|
|
||||||
// Nesting dispatchers
|
// Nesting dispatchers
|
||||||
|
|
||||||
|
@@ -258,7 +258,7 @@ SourceEditorWidget::SourceEditorWidget(const std::shared_ptr<SourceSettings> &se
|
|||||||
settings->languageId,
|
settings->languageId,
|
||||||
addCompilerButton,
|
addCompilerButton,
|
||||||
removeSourceButton,
|
removeSourceButton,
|
||||||
customMargin({6, 0, 0, 0}), spacing(0),
|
customMargins(6, 0, 0, 0), spacing(0),
|
||||||
}.attachTo(toolBar);
|
}.attachTo(toolBar);
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -403,7 +403,7 @@ CompilerWidget::CompilerWidget(const std::shared_ptr<SourceSettings> &sourceSett
|
|||||||
m_compilerSettings->compiler,
|
m_compilerSettings->compiler,
|
||||||
advButton,
|
advButton,
|
||||||
removeCompilerBtn,
|
removeCompilerBtn,
|
||||||
customMargin({6, 0, 0, 0}), spacing(0),
|
customMargins(6, 0, 0, 0), spacing(0),
|
||||||
}.attachTo(toolBar);
|
}.attachTo(toolBar);
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
@@ -421,7 +421,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
|||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
spacing(creatorTheme()->flag(Theme::FlatToolBars) ? 9 : 4), customMargin({5, 0, 0, 0}),
|
spacing(creatorTheme()->flag(Theme::FlatToolBars) ? 9 : 4), customMargins(5, 0, 0, 0),
|
||||||
}.attachTo(m_buttonsWidget);
|
}.attachTo(m_buttonsWidget);
|
||||||
|
|
||||||
StatusBarManager::addStatusBarWidget(m_buttonsWidget, StatusBarManager::Second);
|
StatusBarManager::addStatusBarWidget(m_buttonsWidget, StatusBarManager::Second);
|
||||||
|
@@ -1203,7 +1203,7 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QList<Lis
|
|||||||
st,
|
st,
|
||||||
seeAllLink,
|
seeAllLink,
|
||||||
Space(ExVPaddingGapXl),
|
Space(ExVPaddingGapXl),
|
||||||
customMargin({0, ExPaddingGapL, 0, VPaddingL}),
|
customMargins(0, ExPaddingGapL, 0, VPaddingL),
|
||||||
}.emerge();
|
}.emerge();
|
||||||
m_sectionLabels.append(sectionLabel);
|
m_sectionLabels.append(sectionLabel);
|
||||||
auto scrollArea = qobject_cast<QScrollArea *>(widget(0));
|
auto scrollArea = qobject_cast<QScrollArea *>(widget(0));
|
||||||
@@ -1274,7 +1274,7 @@ void SectionedGridView::zoomInSection(const Section §ion)
|
|||||||
st,
|
st,
|
||||||
backLink,
|
backLink,
|
||||||
Space(ExVPaddingGapXl),
|
Space(ExVPaddingGapXl),
|
||||||
customMargin({0, ExPaddingGapL, 0, VPaddingL}),
|
customMargins(0, ExPaddingGapL, 0, VPaddingL),
|
||||||
}.emerge();
|
}.emerge();
|
||||||
|
|
||||||
auto gridView = new GridView(zoomedInWidget);
|
auto gridView = new GridView(zoomedInWidget);
|
||||||
|
@@ -62,11 +62,11 @@ public:
|
|||||||
Column {
|
Column {
|
||||||
Row {
|
Row {
|
||||||
m_searcher,
|
m_searcher,
|
||||||
customMargin({0, 0, ExVPaddingGapXl, 0}),
|
customMargins(0, 0, ExVPaddingGapXl, 0),
|
||||||
},
|
},
|
||||||
m_sectionedProducts,
|
m_sectionedProducts,
|
||||||
spacing(VPaddingL),
|
spacing(VPaddingL),
|
||||||
customMargin({ExVPaddingGapXl, ExVPaddingGapXl, 0, 0}),
|
customMargins(ExVPaddingGapXl, ExVPaddingGapXl, 0, 0),
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
connect(m_sectionedProducts, &SectionedProducts::toggleProgressIndicator,
|
connect(m_sectionedProducts, &SectionedProducts::toggleProgressIndicator,
|
||||||
|
@@ -799,11 +799,11 @@ public:
|
|||||||
sessionsLabel,
|
sessionsLabel,
|
||||||
st,
|
st,
|
||||||
manageSessionsButton,
|
manageSessionsButton,
|
||||||
customMargin({HPaddingS, 0, sessionScrollBarGap, 0}),
|
customMargins(HPaddingS, 0, sessionScrollBarGap, 0),
|
||||||
},
|
},
|
||||||
sessionsList,
|
sessionsList,
|
||||||
spacing(ExPaddingGapL),
|
spacing(ExPaddingGapL),
|
||||||
customMargin({ExVPaddingGapXl, ExVPaddingGapXl, 0, 0}),
|
customMargins(ExVPaddingGapXl, ExVPaddingGapXl, 0, 0),
|
||||||
}.attachTo(sessions);
|
}.attachTo(sessions);
|
||||||
connect(manageSessionsButton, &Button::clicked,
|
connect(manageSessionsButton, &Button::clicked,
|
||||||
this, &SessionManager::showSessionManager);
|
this, &SessionManager::showSessionManager);
|
||||||
@@ -823,11 +823,11 @@ public:
|
|||||||
Column {
|
Column {
|
||||||
Row {
|
Row {
|
||||||
projectsLabel,
|
projectsLabel,
|
||||||
customMargin({HPaddingS, 0, 0, 0}),
|
customMargins(HPaddingS, 0, 0, 0),
|
||||||
},
|
},
|
||||||
projectsList,
|
projectsList,
|
||||||
spacing(ExPaddingGapL),
|
spacing(ExPaddingGapL),
|
||||||
customMargin({ExVPaddingGapXl - sessionScrollBarGap, ExVPaddingGapXl, 0, 0}),
|
customMargins(ExVPaddingGapXl - sessionScrollBarGap, ExVPaddingGapXl, 0, 0),
|
||||||
}.attachTo(projects);
|
}.attachTo(projects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -279,7 +279,7 @@ public:
|
|||||||
|
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
Row titleRow {
|
Row titleRow {
|
||||||
customMargin({0, 0, ExVPaddingGapXl, 0}),
|
customMargins(0, 0, ExVPaddingGapXl, 0),
|
||||||
spacing(ExVPaddingGapXl),
|
spacing(ExVPaddingGapXl),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ public:
|
|||||||
titleRow,
|
titleRow,
|
||||||
gridView,
|
gridView,
|
||||||
spacing(ExVPaddingGapXl),
|
spacing(ExVPaddingGapXl),
|
||||||
customMargin({ExVPaddingGapXl, ExVPaddingGapXl, 0, 0}),
|
customMargins(ExVPaddingGapXl, ExVPaddingGapXl, 0, 0),
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
connect(&m_exampleDelegate, &ExampleDelegate::tagClicked,
|
connect(&m_exampleDelegate, &ExampleDelegate::tagClicked,
|
||||||
|
@@ -162,7 +162,7 @@ public:
|
|||||||
welcomeLabel,
|
welcomeLabel,
|
||||||
st,
|
st,
|
||||||
spacing(ExVPaddingGapXl),
|
spacing(ExVPaddingGapXl),
|
||||||
customMargin({HPaddingM, VPaddingM, HPaddingM, VPaddingM}),
|
customMargins(HPaddingM, VPaddingM, HPaddingM, VPaddingM),
|
||||||
},
|
},
|
||||||
createRule(Qt::Horizontal),
|
createRule(Qt::Horizontal),
|
||||||
noMargin, spacing(0),
|
noMargin, spacing(0),
|
||||||
@@ -188,7 +188,7 @@ public:
|
|||||||
|
|
||||||
Column mainColumn {
|
Column mainColumn {
|
||||||
spacing(0),
|
spacing(0),
|
||||||
customMargin({ExVPaddingGapXl, 0, ExVPaddingGapXl, 0}),
|
customMargins(ExVPaddingGapXl, 0, ExVPaddingGapXl, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
m_essentials = new QWidget;
|
m_essentials = new QWidget;
|
||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
newButton,
|
newButton,
|
||||||
openButton,
|
openButton,
|
||||||
spacing(ExPaddingGapL),
|
spacing(ExPaddingGapL),
|
||||||
customMargin({0, ExVPaddingGapXl, 0, ExVPaddingGapXl}),
|
customMargins(0, ExVPaddingGapXl, 0, ExVPaddingGapXl),
|
||||||
};
|
};
|
||||||
|
|
||||||
essentials.addItem(projectButtons);
|
essentials.addItem(projectButtons);
|
||||||
@@ -238,7 +238,7 @@ public:
|
|||||||
Column linksLayout {
|
Column linksLayout {
|
||||||
label,
|
label,
|
||||||
spacing(VGapS),
|
spacing(VGapS),
|
||||||
customMargin({0, VGapL, 0, ExVPaddingGapXl}),
|
customMargins(0, VGapL, 0, ExVPaddingGapXl),
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct {
|
const struct {
|
||||||
|
Reference in New Issue
Block a user