63static QString
objName(
const QDesignerFormEditorInterface *core, QObject *object) {
66 Q_ASSERT(sheet !=
nullptr);
68 const int index = sheet->indexOf(u"objectName"_s);
69 const QVariant v = sheet->property(index);
70 if (v.canConvert<qdesigner_internal::PropertySheetStringValue>())
71 return v.value<qdesigner_internal::PropertySheetStringValue>().value();
91 m_editor(
new qdesigner_internal::TextPropertyEditor(
this, qdesigner_internal::TextPropertyEditor::EmbeddingNone,
104 QDialogButtonBox *buttonBox =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
141 enum Actions { HorizNone, Left, HorizCenter, Right, VerticalNone, Top, VerticalCenter, Bottom };
142 static QAction *createAction(
const QString &text,
int data, QMenu *menu, QActionGroup *ag);
144 QAction *m_subMenuAction;
145 QActionGroup *m_horizGroup;
146 QActionGroup *m_verticalGroup;
147 QAction *m_actions[Bottom + 1];
161 m_subMenuAction(
new QAction(QDesignerTaskMenu::tr(
"Layout Alignment"), parent)),
162 m_horizGroup(
new QActionGroup(parent)),
163 m_verticalGroup(
new QActionGroup(parent))
165 m_horizGroup->setExclusive(
true);
166 m_verticalGroup->setExclusive(
true);
167 connect(m_horizGroup, &QActionGroup::triggered,
this, &LayoutAlignmentMenu::changed);
168 connect(m_verticalGroup, &QActionGroup::triggered,
this, &LayoutAlignmentMenu::changed);
170 QMenu *menu =
new QMenu;
171 m_subMenuAction->setMenu(menu);
173 m_actions[HorizNone] = createAction(QDesignerTaskMenu::tr(
"No Horizontal Alignment"), 0, menu, m_horizGroup);
174 m_actions[Left] = createAction(QDesignerTaskMenu::tr(
"Left"), Qt::AlignLeft, menu, m_horizGroup);
175 m_actions[HorizCenter] = createAction(QDesignerTaskMenu::tr(
"Center Horizontally"), Qt::AlignHCenter, menu, m_horizGroup);
176 m_actions[Right] = createAction(QDesignerTaskMenu::tr(
"Right"), Qt::AlignRight, menu, m_horizGroup);
177 menu->addSeparator();
178 m_actions[VerticalNone] = createAction(QDesignerTaskMenu::tr(
"No Vertical Alignment"), 0, menu, m_verticalGroup);
179 m_actions[Top] = createAction(QDesignerTaskMenu::tr(
"Top"), Qt::AlignTop, menu, m_verticalGroup);
180 m_actions[VerticalCenter] = createAction(QDesignerTaskMenu::tr(
"Center Vertically"), Qt::AlignVCenter, menu, m_verticalGroup);
181 m_actions[Bottom] = createAction(QDesignerTaskMenu::tr(
"Bottom"), Qt::AlignBottom, menu, m_verticalGroup);
187 const Qt::Alignment alignment = LayoutAlignmentCommand::alignmentOf(core, w, &enabled);
188 m_subMenuAction->setEnabled(enabled);
190 m_actions[HorizNone]->setChecked(
true);
191 m_actions[VerticalNone]->setChecked(
true);
195 switch (alignment & Qt::AlignHorizontal_Mask) {
197 m_actions[Left]->setChecked(
true);
199 case Qt::AlignHCenter:
200 m_actions[HorizCenter]->setChecked(
true);
203 m_actions[Right]->setChecked(
true);
206 m_actions[HorizNone]->setChecked(
true);
209 switch (alignment & Qt::AlignVertical_Mask) {
211 m_actions[Top]->setChecked(
true);
213 case Qt::AlignVCenter:
214 m_actions[VerticalCenter]->setChecked(
true);
216 case Qt::AlignBottom:
217 m_actions[Bottom]->setChecked(
true);
220 m_actions[VerticalNone]->setChecked(
true);
228 Qt::Alignment alignment;
229 if (
const QAction *horizAction = m_horizGroup->checkedAction())
230 if (
const int horizAlign = horizAction->data().toInt())
231 alignment |=
static_cast<Qt::Alignment>(horizAlign);
232 if (
const QAction *vertAction = m_verticalGroup->checkedAction())
233 if (
const int vertAlign = vertAction->data().toInt())
234 alignment |=
static_cast<Qt::Alignment>(vertAlign);
300 QMenu *sizeMenu =
new QMenu;
302 QAction *sizeAction = m_sizeActionGroup->addAction(QDesignerTaskMenu::tr(
"Set Minimum Width"));
303 sizeAction->setData(ApplyMinimumWidth);
304 sizeMenu->addAction(sizeAction);
306 sizeAction = m_sizeActionGroup->addAction(QDesignerTaskMenu::tr(
"Set Minimum Height"));
307 sizeAction->setData(ApplyMinimumHeight);
308 sizeMenu->addAction(sizeAction);
310 sizeAction = m_sizeActionGroup->addAction(QDesignerTaskMenu::tr(
"Set Minimum Size"));
311 sizeAction->setData(ApplyMinimumWidth|ApplyMinimumHeight);
312 sizeMenu->addAction(sizeAction);
314 sizeMenu->addSeparator();
316 sizeAction = m_sizeActionGroup->addAction(QDesignerTaskMenu::tr(
"Set Maximum Width"));
317 sizeAction->setData(ApplyMaximumWidth);
318 sizeMenu->addAction(sizeAction);
320 sizeAction = m_sizeActionGroup->addAction(QDesignerTaskMenu::tr(
"Set Maximum Height"));
321 sizeAction->setData(ApplyMaximumHeight);
322 sizeMenu->addAction(sizeAction);
324 sizeAction = m_sizeActionGroup->addAction(QDesignerTaskMenu::tr(
"Set Maximum Size"));
325 sizeAction->setData(ApplyMaximumWidth|ApplyMaximumHeight);
326 sizeMenu->addAction(sizeAction);
624 const QSize size = w->size();
626 QSize minimumSize = w-> minimumSize();
628 minimumSize.setWidth(size.width());
630 minimumSize.setHeight(size.height());
631 SetPropertyCommand* cmd =
new SetPropertyCommand(fw);
632 cmd->init(w, u"minimumSize"_s, minimumSize);
633 fw->commandHistory()->push(cmd);
636 QSize maximumSize = w-> maximumSize();
638 maximumSize.setWidth(size.width());
640 maximumSize.setHeight(size.height());
641 SetPropertyCommand* cmd =
new SetPropertyCommand(fw);
642 cmd->init(w, u"maximumSize"_s, maximumSize);
643 fw->commandHistory()->push(cmd);
667 QDesignerTaskMenu::PropertyMode pm, Container *c)
670 c->push_back(current);
671 if (pm == QDesignerTaskMenu::CurrentWidgetMode)
673 QDesignerObjectInspector *designerObjectInspector = qobject_cast<QDesignerObjectInspector *>(fw->core()->objectInspector());
674 if (!designerObjectInspector)
678 designerObjectInspector->getSelection(s);
679 const QWidgetList &source = fw->isManaged(current) ? s.managed : s.unmanaged;
680 for (
auto *w : source) {