diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml index c326cc08f1d..3d17883c544 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml @@ -94,27 +94,33 @@ QtObject { readonly property string fontStyleItalic: "\u0057" readonly property string fontStyleStrikethrough: "\u0058" readonly property string fontStyleUnderline: "\u0059" - readonly property string mergeCells: "\u005A" - readonly property string redo: "\u005B" - readonly property string splitColumns: "\u005C" - readonly property string splitRows: "\u005D" - readonly property string startNode: "\u005E" - readonly property string testIcon: "\u005F" - readonly property string textAlignBottom: "\u0060" - readonly property string textAlignCenter: "\u0061" - readonly property string textAlignLeft: "\u0062" - readonly property string textAlignMiddle: "\u0063" - readonly property string textAlignRight: "\u0064" - readonly property string textAlignTop: "\u0065" - readonly property string textBulletList: "\u0066" - readonly property string textFullJustification: "\u0067" - readonly property string textNumberedList: "\u0068" - readonly property string tickIcon: "\u0069" - readonly property string triState: "\u006A" - readonly property string undo: "\u006B" - readonly property string upDownIcon: "\u006C" - readonly property string upDownSquare2: "\u006D" - readonly property string wildcard: "\u006E" + readonly property string idAliasOff: "\u005A" + readonly property string idAliasOn: "\u005B" + readonly property string mergeCells: "\u005C" + readonly property string redo: "\u005D" + readonly property string splitColumns: "\u005E" + readonly property string splitRows: "\u005F" + readonly property string startNode: "\u0060" + readonly property string testIcon: "\u0061" + readonly property string textAlignBottom: "\u0062" + readonly property string textAlignCenter: "\u0063" + readonly property string textAlignLeft: "\u0064" + readonly property string textAlignMiddle: "\u0065" + readonly property string textAlignRight: "\u0066" + readonly property string textAlignTop: "\u0067" + readonly property string textBulletList: "\u0068" + readonly property string textFullJustification: "\u0069" + readonly property string textNumberedList: "\u006A" + readonly property string tickIcon: "\u006B" + readonly property string triState: "\u006C" + readonly property string undo: "\u006D" + readonly property string upDownIcon: "\u006E" + readonly property string upDownSquare2: "\u006F" + readonly property string wildcard: "\u0070" + readonly property string zoomAll: "\u0071" + readonly property string zoomIn: "\u0072" + readonly property string zoomOut: "\u0073" + readonly property string zoomSelection: "\u0074" readonly property font iconFont: Qt.font({ "family": controlIcons.name, diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf index 47becb68731..46a677784ac 100644 Binary files a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf and b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf differ diff --git a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h index a8db25f4176..806da7f4286 100644 --- a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h +++ b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h @@ -83,8 +83,6 @@ const char decreaseIndexOfStackedContainerCommandId[] = "DecreaseIndexOfStackedC const char flowAssignEffectCommandId[] = "AssignFlowEffect"; const char flowAssignCustomEffectCommandId[] = "AssignFlowCustomEffect"; const char addToGroupItemCommandId[] = "AddToGroupItem"; -const char fitRootToScreenCommandId[] = "FitRootToScreen"; -const char fitSelectionToScreenCommandId[] = "FitSelectionToScreen"; const char selectionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Selection"); const char flowConnectionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Connect"); @@ -157,9 +155,6 @@ const char layoutFillHeightDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContext const char flowAssignEffectDisplayName[] = "Assign FlowEffect "; const char flowAssignCustomEffectDisplayName[] = "Assign Custom FlowEffect "; -const char fitRootToScreenDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fit root to screen"); -const char fitSelectionToScreenDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fit selection to screen"); - const char raiseToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Raise selected item."); const char lowerToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Lower selected item."); @@ -178,9 +173,6 @@ const char decreaseIndexOfStackedContainerToolTip[] = QT_TRANSLATE_NOOP("QmlDesi const char addItemToStackedContainerToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add item to stacked container."); const char addFlowActionToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add flow action."); -const char fitRootToScreenToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fit the root element inside the available space."); -const char fitSelectionToScreenToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fit the selected elements inside the available space."); - const char editListModelDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit List Model..."); diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 73abc4ea296..8ccdef7acd2 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -883,27 +883,6 @@ void DesignerActionManager::createDefaultDesignerActions() &resetSize, &selectionNotEmptyAndHasWidthOrHeightProperty)); - addDesignerAction(new ModelNodeAction( - fitRootToScreenCommandId, - fitRootToScreenDisplayName, - Utils::Icon({{":/utils/images/fittoview.png", Utils::Theme::IconsBaseColor}}).icon(), - fitRootToScreenToolTip, - genericToolBarCategory, - QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_0), - 182, - &fitRootToScreen)); - - addDesignerAction(new ModelNodeAction( - fitSelectionToScreenCommandId, - fitSelectionToScreenDisplayName, - Utils::Icon({{":/utils/images/fittoview.png", Utils::Theme::IconsBaseColor}}).icon(), - fitSelectionToScreenToolTip, - genericToolBarCategory, - QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_I), - 183, - &fitSelectionToScreen, - &selectionNotEmpty)); - addDesignerAction(new SeperatorDesignerAction(editCategory, 170)); addDesignerAction(new VisiblityModelNodeAction( diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp index da77f26af7e..98148b7bd3f 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp @@ -329,23 +329,6 @@ void resetPosition(const SelectionContext &selectionState) }); } -void fitRootToScreen(const SelectionContext &selectionState) -{ - if (!selectionState.view()) - return; - - selectionState.view()->emitCustomNotification(QStringLiteral("fit root to screen")); -} - -void fitSelectionToScreen(const SelectionContext &selectionState) -{ - if (!selectionState.view()) - return; - - selectionState.view()->emitCustomNotification(QStringLiteral("fit selection to screen"), - selectionState.selectedModelNodes()); -} - void goIntoComponentOperation(const SelectionContext &selectionState) { goIntoComponent(selectionState.currentSingleSelectedNode()); diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h index 0a8e094a7e1..afd8416bf9f 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h @@ -49,8 +49,6 @@ void setFillWidth(const SelectionContext &selectionState); void setFillHeight(const SelectionContext &selectionState); void resetSize(const SelectionContext &selectionState); void resetPosition(const SelectionContext &selectionState); -void fitRootToScreen(const SelectionContext &selectionState); -void fitSelectionToScreen(const SelectionContext &selectionState); void goIntoComponentOperation(const SelectionContext &selectionState); void setId(const SelectionContext &selectionState); void resetZ(const SelectionContext &selectionState); diff --git a/src/plugins/qmldesigner/components/componentcore/theme.h b/src/plugins/qmldesigner/components/componentcore/theme.h index 4cc4deb2983..880a1d05caa 100644 --- a/src/plugins/qmldesigner/components/componentcore/theme.h +++ b/src/plugins/qmldesigner/components/componentcore/theme.h @@ -66,19 +66,21 @@ public: alignRight, alignTo, alignTop, - assign, anchorBaseline, anchorBottom, anchorFill, anchorLeft, anchorRight, anchorTop, + animatedProperty, annotationBubble, annotationDecal, + assign, centerHorizontal, centerVertical, - curveEditor, closeCross, + curveDesigner, + curveEditor, decisionNode, deleteColumn, deleteRow, @@ -101,6 +103,8 @@ public: fontStyleItalic, fontStyleStrikethrough, fontStyleUnderline, + idAliasOff, + idAliasOn, mergeCells, redo, splitColumns, @@ -121,7 +125,11 @@ public: undo, upDownIcon, upDownSquare2, - wildcard + wildcard, + zoomAll, + zoomIn, + zoomOut, + zoomSelection }; static Theme *instance(); diff --git a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp index 4f1d1c3da90..c59c1ffe836 100644 --- a/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp +++ b/src/plugins/qmldesigner/components/componentcore/zoomaction.cpp @@ -47,14 +47,14 @@ float ZoomAction::zoomLevel() const void ZoomAction::zoomIn() { - if (m_currentComboBoxIndex > 0) - emit indexChanged(m_currentComboBoxIndex - 1); + if (m_currentComboBoxIndex < (m_comboBoxModel->rowCount() - 1)) + emit indexChanged(m_currentComboBoxIndex + 1); } void ZoomAction::zoomOut() { - if (m_currentComboBoxIndex < (m_comboBoxModel->rowCount() - 1)) - emit indexChanged(m_currentComboBoxIndex + 1); + if (m_currentComboBoxIndex > 0) + emit indexChanged(m_currentComboBoxIndex - 1); } void ZoomAction::resetZoomLevel() diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index f64b45f3517..6eec3f933c4 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -384,6 +384,11 @@ void FormEditorView::selectedNodesChanged(const QList &selectedNodeLi m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeListKeppInvalid(selectedNodeList))); m_scene->update(); + + if (selectedNodeList.empty()) + m_formEditorWidget->zoomSelectionAction()->setEnabled(false); + else + m_formEditorWidget->zoomSelectionAction()->setEnabled(true); } void FormEditorView::variantPropertiesChanged(const QList &propertyList, @@ -448,7 +453,7 @@ void FormEditorView::customNotification(const AbstractView * /*view*/, const QSt m_dragTool->clearMoveDelay(); if (identifier == QLatin1String("reset QmlPuppet")) temporaryBlockView(); - if (identifier == QLatin1String("fit root to screen")) { + if (identifier == QLatin1String("zoom all")) { if (QmlItemNode(rootModelNode()).isFlowView()) { QRectF boundingRect; for (QGraphicsItem *item : scene()->items()) { @@ -469,7 +474,7 @@ void FormEditorView::customNotification(const AbstractView * /*view*/, const QSt float zoomLevel = ZoomAction::getClosestZoomLevel(scaleFactor); m_formEditorWidget->zoomAction()->forceZoomLevel(zoomLevel); } - if (identifier == QLatin1String("fit selection to screen")) { + if (identifier == QLatin1String("zoom selection")) { if (nodeList.isEmpty()) return; @@ -485,6 +490,10 @@ void FormEditorView::customNotification(const AbstractView * /*view*/, const QSt float zoomLevel = ZoomAction::getClosestZoomLevel(scaleFactor); m_formEditorWidget->zoomAction()->forceZoomLevel(zoomLevel); } + if (identifier == QLatin1String("zoom in")) + m_formEditorWidget->zoomAction()->zoomIn(); + if (identifier == QLatin1String("zoom out")) + m_formEditorWidget->zoomAction()->zoomOut(); } AbstractFormEditorTool *FormEditorView::currentTool() const diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp index 0380db2b081..303c79ea965 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -144,6 +145,46 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) : upperActions.append(m_backgroundAction.data()); m_toolBox->addRightSideAction(m_backgroundAction.data()); + // Zoom actions + const QString fontName = "qtds_propertyIconFont.ttf"; + QColor buttonColor(Theme::getColor(Theme::QmlDesigner_TabLight)); + const QIcon zoomAllIcon = Utils::StyleHelper::getIconFromIconFont(fontName, + Theme::getIconUnicode(Theme::Icon::zoomAll), + 28, 28, buttonColor); + const QIcon zoomSelectionIcon = Utils::StyleHelper::getIconFromIconFont(fontName, + Theme::getIconUnicode(Theme::Icon::zoomSelection), + 28, 28, buttonColor); + const QIcon zoomInIcon = Utils::StyleHelper::getIconFromIconFont(fontName, + Theme::getIconUnicode(Theme::Icon::zoomIn), + 28, 28, buttonColor); + const QIcon zoomOutIcon = Utils::StyleHelper::getIconFromIconFont(fontName, + Theme::getIconUnicode(Theme::Icon::zoomOut), + 28, 28, buttonColor); + + m_zoomInAction = new QAction(zoomInIcon, tr("Zoom in"), this); + m_zoomInAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Plus)); + connect(m_zoomInAction.data(), &QAction::triggered, this, [this] { + if (!m_formEditorView) + return; + + m_formEditorView->emitCustomNotification(QStringLiteral("zoom in")); + }); + addAction(m_zoomInAction.data()); + upperActions.append(m_zoomInAction.data()); + m_toolBox->addRightSideAction(m_zoomInAction.data()); + + m_zoomOutAction = new QAction(zoomOutIcon, tr("Zoom out"), this); + m_zoomOutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Minus)); + connect(m_zoomOutAction.data(), &QAction::triggered, this, [this] { + if (!m_formEditorView) + return; + + m_formEditorView->emitCustomNotification(QStringLiteral("zoom out")); + }); + addAction(m_zoomOutAction.data()); + upperActions.append(m_zoomOutAction.data()); + m_toolBox->addRightSideAction(m_zoomOutAction.data()); + m_zoomAction = new ZoomAction(m_toolActionGroup.data()); connect(m_zoomAction.data(), &ZoomAction::zoomLevelChanged, this, &FormEditorWidget::setZoomLevel); @@ -151,6 +192,31 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) : upperActions.append(m_zoomAction.data()); m_toolBox->addRightSideAction(m_zoomAction.data()); + m_zoomAllAction = new QAction(zoomAllIcon, tr("Zoom screen to fit all content"), this); + m_zoomAllAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_0)); + connect(m_zoomAllAction.data(), &QAction::triggered, this, [this] { + if (!m_formEditorView) + return; + + m_formEditorView->emitCustomNotification(QStringLiteral("zoom all")); + }); + addAction(m_zoomAllAction.data()); + upperActions.append(m_zoomAllAction.data()); + m_toolBox->addRightSideAction(m_zoomAllAction.data()); + + m_zoomSelectionAction = new QAction(zoomSelectionIcon, tr("Zoom screen to fit current selection"), this); + m_zoomSelectionAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_I)); + connect(m_zoomSelectionAction.data(), &QAction::triggered, this, [this] { + if (!m_formEditorView) + return; + + m_formEditorView->emitCustomNotification(QStringLiteral("zoom selection"), + m_formEditorView->selectedModelNodes()); + }); + addAction(m_zoomSelectionAction.data()); + upperActions.append(m_zoomSelectionAction.data()); + m_toolBox->addRightSideAction(m_zoomSelectionAction.data()); + m_resetAction = new QAction(Utils::Icons::RESET_TOOLBAR.icon(), tr("Reset View"), this); registerActionAsCommand(m_resetAction, Constants::FORMEDITOR_REFRESH, QKeySequence(Qt::Key_R)); @@ -218,9 +284,9 @@ void FormEditorWidget::wheelEvent(QWheelEvent *event) { if (event->modifiers().testFlag(Qt::ControlModifier)) { if (event->angleDelta().y() > 0) - zoomAction()->zoomOut(); - else zoomAction()->zoomIn(); + else + zoomAction()->zoomOut(); event->accept(); } else { @@ -304,6 +370,11 @@ ZoomAction *FormEditorWidget::zoomAction() const return m_zoomAction.data(); } +QAction *FormEditorWidget::zoomSelectionAction() const +{ + return m_zoomSelectionAction.data(); +} + QAction *FormEditorWidget::resetAction() const { return m_resetAction.data(); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h index eb01611682f..b2f50de6c0f 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h @@ -53,6 +53,7 @@ public: FormEditorWidget(FormEditorView *view); ZoomAction *zoomAction() const; + QAction *zoomSelectionAction() const; QAction *showBoundingRectAction() const; QAction *snappingAction() const; QAction *snappingAndAnchoringAction() const; @@ -112,6 +113,10 @@ private: QPointer m_rootHeightAction; QPointer m_backgroundAction; QPointer m_resetAction; + QPointer m_zoomAllAction; + QPointer m_zoomSelectionAction; + QPointer m_zoomInAction; + QPointer m_zoomOutAction; QPointer m_documentErrorWidget; Core::IContext *m_context = nullptr; };