diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 77cd00d7fa2..6f3f19b2490 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -27,6 +27,7 @@ #include "changestyleaction.h" #include "designeractionmanagerview.h" +#include "designermcumanager.h" #include "formatoperation.h" #include "modelnodecontextmenu_helper.h" #include "qmldesignerconstants.h" @@ -633,6 +634,11 @@ bool selectionCanBeLayoutedAndQtQuickLayoutPossible(const SelectionContext &cont return selectionCanBeLayouted(context) && context.view()->majorQtQuickVersion() > 1; } +bool selectionCanBeLayoutedAndQtQuickLayoutPossibleAndNotMCU(const SelectionContext &context) +{ + return selectionCanBeLayoutedAndQtQuickLayoutPossible(context) && !DesignerMcuManager::instance().isMCUProject(); +} + bool selectionNotEmptyAndHasZProperty(const SelectionContext &context) { return selectionNotEmpty(context) && selectionHasProperty(context, zProperty); @@ -1360,7 +1366,7 @@ void DesignerActionManager::createDefaultDesignerActions() QKeySequence("shift+g"), 60, &layoutGridLayout, - &selectionCanBeLayoutedAndQtQuickLayoutPossible)); + &selectionCanBeLayoutedAndQtQuickLayoutPossibleAndNotMCU)); addDesignerAction(new SeperatorDesignerAction(layoutCategory, 50)); diff --git a/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp b/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp index e106fc93579..f55f4807d91 100644 --- a/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp +++ b/src/plugins/qmldesigner/components/componentcore/layoutingridlayout.cpp @@ -325,8 +325,10 @@ void LayoutInGridLayout::calculateGridOffsets() removeSimilarValues(m_yTopOffsets, heightTolerance); //The first offset is not important, because it just defines the beginning of the layout - m_xTopOffsets.removeFirst(); - m_yTopOffsets.removeFirst(); + if (!m_xTopOffsets.isEmpty()) + m_xTopOffsets.removeFirst(); + if (!m_yTopOffsets.isEmpty()) + m_yTopOffsets.removeFirst(); } void LayoutInGridLayout::removeEmtpyRowsAndColumns() diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp index 84ea59531bc..81066504de9 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include @@ -88,6 +88,7 @@ #include #include #include +#include #include @@ -187,7 +188,7 @@ void toFront(const SelectionContext &selectionState) if (index != lastIndex) parentProperty.slide(index, lastIndex); } - } catch (const RewritingException &e) { //better save then sorry + } catch (const RewritingException &e) { //better safe than sorry e.showException(); } } @@ -208,7 +209,7 @@ void toBack(const SelectionContext &selectionState) parentProperty.slide(index, 0); } - } catch (const RewritingException &e) { //better save then sorry + } catch (const RewritingException &e) { //better safe than sorry e.showException(); } } @@ -272,7 +273,7 @@ void setVisible(const SelectionContext &selectionState) try { selectionState.selectedModelNodes().constFirst().variantProperty("visible").setValue(selectionState.toggled()); - } catch (const RewritingException &e) { //better save then sorry + } catch (const RewritingException &e) { //better safe than sorry e.showException(); } } @@ -285,7 +286,7 @@ void setFillWidth(const SelectionContext &selectionState) try { selectionState.firstSelectedModelNode().variantProperty("Layout.fillWidth").setValue(selectionState.toggled()); - } catch (const RewritingException &e) { //better save then sorry + } catch (const RewritingException &e) { //better safe than sorry e.showException(); } } @@ -298,7 +299,7 @@ void setFillHeight(const SelectionContext &selectionState) try { selectionState.firstSelectedModelNode().variantProperty("Layout.fillHeight").setValue(selectionState.toggled()); - } catch (const RewritingException &e) { //better save then sorry + } catch (const RewritingException &e) { //better safe than sorry e.showException(); } } @@ -522,9 +523,14 @@ void layoutFlowPositioner(const SelectionContext &selectionContext) void layoutRowLayout(const SelectionContext &selectionContext) { try { - LayoutInGridLayout::ensureLayoutImport(selectionContext); - layoutHelperFunction(selectionContext, "QtQuick.Layouts.RowLayout", compareByX); - } catch (RewritingException &e) { //better save then sorry + if (DesignerMcuManager::instance().isMCUProject()) { + layoutHelperFunction(selectionContext, "QtQuick.Row", compareByX); + } + else { + LayoutInGridLayout::ensureLayoutImport(selectionContext); + layoutHelperFunction(selectionContext, "QtQuick.Layouts.RowLayout", compareByX); + } + } catch (RewritingException &e) { //better safe than sorry e.showException(); } } @@ -532,9 +538,14 @@ void layoutRowLayout(const SelectionContext &selectionContext) void layoutColumnLayout(const SelectionContext &selectionContext) { try { - LayoutInGridLayout::ensureLayoutImport(selectionContext); - layoutHelperFunction(selectionContext, "QtQuick.Layouts.ColumnLayout", compareByY); - } catch (RewritingException &e) { //better save then sorry + if (DesignerMcuManager::instance().isMCUProject()) { + layoutHelperFunction(selectionContext, "QtQuick.Column", compareByX); + } + else { + LayoutInGridLayout::ensureLayoutImport(selectionContext); + layoutHelperFunction(selectionContext, "QtQuick.Layouts.ColumnLayout", compareByY); + } + } catch (RewritingException &e) { //better safe than sorry e.showException(); } } @@ -542,9 +553,16 @@ void layoutColumnLayout(const SelectionContext &selectionContext) void layoutGridLayout(const SelectionContext &selectionContext) { try { - LayoutInGridLayout::ensureLayoutImport(selectionContext); - LayoutInGridLayout::layout(selectionContext); - } catch (RewritingException &e) { //better save then sorry + Q_ASSERT(!DesignerMcuManager::instance().isMCUProject()); //remove this line when grids are finally supported + + if (DesignerMcuManager::instance().isMCUProject()) { + //qt for mcu doesn't support any grids yet + } + else { + LayoutInGridLayout::ensureLayoutImport(selectionContext); + LayoutInGridLayout::layout(selectionContext); + } + } catch (RewritingException &e) { //better safe than sorry e.showException(); } }