65void Spacer::paintEvent(QPaintEvent *)
68 if (m_formWindow !=
nullptr && m_formWindow->currentTool() != 0)
73 const int w = width();
74 const int h = height();
78 if (w <= m_SizeOffset.width() || h <= m_SizeOffset.height()) {
81 switch (m_orientation) {
83 p.drawLine(0, 0, 0, lh);
84 p.drawLine(lw, 0, lw, lh);
87 p.drawLine(0, 0, lw, 0);
88 p.drawLine(0, lh, lw, lh);
93 if (m_orientation == Qt::Horizontal) {
95 const int amplitude = qMin(3, h / 3);
96 const int base = h / 2;
99 for (i = 0; i < w / 3 +2; ++i)
100 p.drawLine(i * dist, base - amplitude, i * dist + dist / 2, base + amplitude);
102 for (i = 0; i < w / 3 +2; ++i)
103 p.drawLine(i * dist + dist / 2, base + amplitude, i * dist + dist, base - amplitude);
105 p.drawLine(0, y-10, 0, y+10);
106 p.drawLine(w - 1, y-10, w - 1, y+10);
109 const int amplitude = qMin(3, w / 3);
110 const int base = w / 2;
113 for (i = 0; i < h / 3 +2; ++i)
114 p.drawLine(base - amplitude, i * dist, base + amplitude,i * dist + dist / 2);
116 for (i = 0; i < h / 3 +2; ++i)
117 p.drawLine(base + amplitude, i * dist + dist / 2, base - amplitude, i * dist + dist);
119 p.drawLine(x-10, 0, x+10, 0);
120 p.drawLine(x-10, h - 1, x+10, h - 1);
124void Spacer::resizeEvent(QResizeEvent* e)
126 QWidget::resizeEvent(e);
130 const QSize oldSize = e->oldSize();
131 if (oldSize.isNull() || oldSize.width() <= m_SizeOffset.width() || oldSize.height() <= m_SizeOffset.height())
132 if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(),
this))
133 sheet->setChanged(sheet->indexOf(u"sizeHint"_s),
true);
142 const QSize currentSize = size();
143 if (currentSize.width() >= m_SizeOffset.width() && currentSize.height() >= m_SizeOffset.height())
144 m_sizeHint = currentSize - m_SizeOffset;
148void Spacer::updateMask()
151 const int w = width();
152 const int h = height();
153 if (w > 1 && h > 1) {
154 if (m_orientation == Qt::Horizontal) {
155 const int amplitude = qMin(3, h / 3);
156 const int base = h / 2;
157 r = r.subtracted(QRect(1, 0, w - 2, base - amplitude));
158 r = r.subtracted(QRect(1, base + amplitude, w - 2, h - base - amplitude));
160 const int amplitude = qMin(3, w / 3);
161 const int base = w / 2;
162 r = r.subtracted(QRect(0, 1, base - amplitude, h - 2));
163 r = r.subtracted(QRect(base + amplitude, 1, w - base - amplitude, h - 2));
212void Spacer::setOrientation(Qt::Orientation o)
214 if (m_orientation == o)
217 const QSizePolicy::Policy st = sizeType();
222 m_sizeHint = QSize(m_sizeHint.height(), m_sizeHint.width());
224 resize(m_sizeHint + m_SizeOffset);