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->diagramElementsCheckBox,
|
||||
customMargin({margin, 0, margin, 0}),
|
||||
customMargins(margin, 0, margin, 0),
|
||||
},
|
||||
Space(10),
|
||||
line(),
|
||||
@@ -88,11 +88,11 @@ ModelTreeFilter::ModelTreeFilter(QWidget *parent) :
|
||||
Tr::tr("Name:"), d->nameLineEdit, br,
|
||||
Tr::tr("Direction:"), d->directionComboBox, br,
|
||||
},
|
||||
customMargin({margin, 0, margin, 0}),
|
||||
customMargins(margin, 0, margin, 0),
|
||||
},
|
||||
st,
|
||||
line(),
|
||||
customMargin({0, margin, 0, 0}),
|
||||
customMargins(0, margin, 0, 0),
|
||||
}.attachTo(this);
|
||||
|
||||
connect(d->resetViewButton, &QPushButton::clicked, this, &ModelTreeFilter::resetView);
|
||||
|
@@ -341,17 +341,17 @@ void Layout::span(int cols, int rows)
|
||||
|
||||
void Layout::setNoMargins()
|
||||
{
|
||||
setContentMargins({});
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
setContentMargins({});
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
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
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMargins>
|
||||
#include <QString>
|
||||
|
||||
#include <functional>
|
||||
@@ -26,7 +25,6 @@ class QGroupBox;
|
||||
class QHBoxLayout;
|
||||
class QLabel;
|
||||
class QLayout;
|
||||
class QMargins;
|
||||
class QObject;
|
||||
class QPushButton;
|
||||
class QSpinBox;
|
||||
@@ -52,6 +50,15 @@ public:
|
||||
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
|
||||
|
||||
void doit(auto x, auto id, auto p);
|
||||
@@ -142,7 +149,7 @@ public:
|
||||
|
||||
void setNoMargins();
|
||||
void setNormalMargins();
|
||||
void setContentMargins(const QMargins &margin);
|
||||
void setContentsMargins(int left, int top, int right, int bottom);
|
||||
void setColumnStretch(int cols, int rows);
|
||||
void setSpacing(int space);
|
||||
void setFieldGrowthPolicy(int policy);
|
||||
@@ -268,7 +275,7 @@ public:
|
||||
void setToolTip(const QString &);
|
||||
void setNoMargins(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
|
||||
@@ -448,13 +455,18 @@ void doit(Interface *x, IdId, auto p)
|
||||
|
||||
#define QTCREATOR_SETTER2(name, setter) \
|
||||
class name##_TAG {}; \
|
||||
inline auto name(auto p1, auto p2) { return IdAndArg{name##_TAG{}, std::pair{p1, p2}}; } \
|
||||
inline void doit(auto x, name##_TAG, auto p) { x->setter(p.first, p.second); }
|
||||
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.p1, p.p2); }
|
||||
|
||||
#define QTCREATOR_TYPED_SETTER(name, setter, type) \
|
||||
#define QTCREATOR_SETTER3(name, setter) \
|
||||
class name##_TAG {}; \
|
||||
inline auto name(type p) { return IdAndArg{name##_TAG{}, p}; } \
|
||||
inline void doit(auto x, name##_TAG, auto p) { x->setter(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.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(groupChecker, setGroupChecker);
|
||||
@@ -471,8 +483,7 @@ QTCREATOR_SETTER2(columnStretch, setColumnStretch);
|
||||
QTCREATOR_SETTER2(onClicked, onClicked);
|
||||
QTCREATOR_SETTER2(onLinkHovered, onLinkHovered);
|
||||
QTCREATOR_SETTER2(onTextChanged, onTextChanged);
|
||||
|
||||
QTCREATOR_TYPED_SETTER(customMargin, setContentMargins, const QMargins &);
|
||||
QTCREATOR_SETTER4(customMargins, setContentsMargins);
|
||||
|
||||
// Nesting dispatchers
|
||||
|
||||
|
@@ -258,7 +258,7 @@ SourceEditorWidget::SourceEditorWidget(const std::shared_ptr<SourceSettings> &se
|
||||
settings->languageId,
|
||||
addCompilerButton,
|
||||
removeSourceButton,
|
||||
customMargin({6, 0, 0, 0}), spacing(0),
|
||||
customMargins(6, 0, 0, 0), spacing(0),
|
||||
}.attachTo(toolBar);
|
||||
|
||||
Column {
|
||||
@@ -403,7 +403,7 @@ CompilerWidget::CompilerWidget(const std::shared_ptr<SourceSettings> &sourceSett
|
||||
m_compilerSettings->compiler,
|
||||
advButton,
|
||||
removeCompilerBtn,
|
||||
customMargin({6, 0, 0, 0}), spacing(0),
|
||||
customMargins(6, 0, 0, 0), spacing(0),
|
||||
}.attachTo(toolBar);
|
||||
|
||||
Column {
|
||||
|
@@ -421,7 +421,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
||||
}.attachTo(this);
|
||||
|
||||
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);
|
||||
|
||||
StatusBarManager::addStatusBarWidget(m_buttonsWidget, StatusBarManager::Second);
|
||||
|
@@ -1203,7 +1203,7 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QList<Lis
|
||||
st,
|
||||
seeAllLink,
|
||||
Space(ExVPaddingGapXl),
|
||||
customMargin({0, ExPaddingGapL, 0, VPaddingL}),
|
||||
customMargins(0, ExPaddingGapL, 0, VPaddingL),
|
||||
}.emerge();
|
||||
m_sectionLabels.append(sectionLabel);
|
||||
auto scrollArea = qobject_cast<QScrollArea *>(widget(0));
|
||||
@@ -1274,7 +1274,7 @@ void SectionedGridView::zoomInSection(const Section §ion)
|
||||
st,
|
||||
backLink,
|
||||
Space(ExVPaddingGapXl),
|
||||
customMargin({0, ExPaddingGapL, 0, VPaddingL}),
|
||||
customMargins(0, ExPaddingGapL, 0, VPaddingL),
|
||||
}.emerge();
|
||||
|
||||
auto gridView = new GridView(zoomedInWidget);
|
||||
|
@@ -62,11 +62,11 @@ public:
|
||||
Column {
|
||||
Row {
|
||||
m_searcher,
|
||||
customMargin({0, 0, ExVPaddingGapXl, 0}),
|
||||
customMargins(0, 0, ExVPaddingGapXl, 0),
|
||||
},
|
||||
m_sectionedProducts,
|
||||
spacing(VPaddingL),
|
||||
customMargin({ExVPaddingGapXl, ExVPaddingGapXl, 0, 0}),
|
||||
customMargins(ExVPaddingGapXl, ExVPaddingGapXl, 0, 0),
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_sectionedProducts, &SectionedProducts::toggleProgressIndicator,
|
||||
|
@@ -799,11 +799,11 @@ public:
|
||||
sessionsLabel,
|
||||
st,
|
||||
manageSessionsButton,
|
||||
customMargin({HPaddingS, 0, sessionScrollBarGap, 0}),
|
||||
customMargins(HPaddingS, 0, sessionScrollBarGap, 0),
|
||||
},
|
||||
sessionsList,
|
||||
spacing(ExPaddingGapL),
|
||||
customMargin({ExVPaddingGapXl, ExVPaddingGapXl, 0, 0}),
|
||||
customMargins(ExVPaddingGapXl, ExVPaddingGapXl, 0, 0),
|
||||
}.attachTo(sessions);
|
||||
connect(manageSessionsButton, &Button::clicked,
|
||||
this, &SessionManager::showSessionManager);
|
||||
@@ -823,11 +823,11 @@ public:
|
||||
Column {
|
||||
Row {
|
||||
projectsLabel,
|
||||
customMargin({HPaddingS, 0, 0, 0}),
|
||||
customMargins(HPaddingS, 0, 0, 0),
|
||||
},
|
||||
projectsList,
|
||||
spacing(ExPaddingGapL),
|
||||
customMargin({ExVPaddingGapXl - sessionScrollBarGap, ExVPaddingGapXl, 0, 0}),
|
||||
customMargins(ExVPaddingGapXl - sessionScrollBarGap, ExVPaddingGapXl, 0, 0),
|
||||
}.attachTo(projects);
|
||||
}
|
||||
|
||||
|
@@ -279,7 +279,7 @@ public:
|
||||
|
||||
using namespace Layouting;
|
||||
Row titleRow {
|
||||
customMargin({0, 0, ExVPaddingGapXl, 0}),
|
||||
customMargins(0, 0, ExVPaddingGapXl, 0),
|
||||
spacing(ExVPaddingGapXl),
|
||||
};
|
||||
|
||||
@@ -317,7 +317,7 @@ public:
|
||||
titleRow,
|
||||
gridView,
|
||||
spacing(ExVPaddingGapXl),
|
||||
customMargin({ExVPaddingGapXl, ExVPaddingGapXl, 0, 0}),
|
||||
customMargins(ExVPaddingGapXl, ExVPaddingGapXl, 0, 0),
|
||||
}.attachTo(this);
|
||||
|
||||
connect(&m_exampleDelegate, &ExampleDelegate::tagClicked,
|
||||
|
@@ -162,7 +162,7 @@ public:
|
||||
welcomeLabel,
|
||||
st,
|
||||
spacing(ExVPaddingGapXl),
|
||||
customMargin({HPaddingM, VPaddingM, HPaddingM, VPaddingM}),
|
||||
customMargins(HPaddingM, VPaddingM, HPaddingM, VPaddingM),
|
||||
},
|
||||
createRule(Qt::Horizontal),
|
||||
noMargin, spacing(0),
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
|
||||
Column mainColumn {
|
||||
spacing(0),
|
||||
customMargin({ExVPaddingGapXl, 0, ExVPaddingGapXl, 0}),
|
||||
customMargins(ExVPaddingGapXl, 0, ExVPaddingGapXl, 0),
|
||||
};
|
||||
|
||||
m_essentials = new QWidget;
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
newButton,
|
||||
openButton,
|
||||
spacing(ExPaddingGapL),
|
||||
customMargin({0, ExVPaddingGapXl, 0, ExVPaddingGapXl}),
|
||||
customMargins(0, ExVPaddingGapXl, 0, ExVPaddingGapXl),
|
||||
};
|
||||
|
||||
essentials.addItem(projectButtons);
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
Column linksLayout {
|
||||
label,
|
||||
spacing(VGapS),
|
||||
customMargin({0, VGapL, 0, ExVPaddingGapXl}),
|
||||
customMargins(0, VGapL, 0, ExVPaddingGapXl),
|
||||
};
|
||||
|
||||
const struct {
|
||||
|
Reference in New Issue
Block a user