diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2010-01-18 20:15:49 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@nokia.com> | 2010-01-18 20:15:49 +0100 |
commit | 29b7594b38f3545bb6a5d5ff08542c0e71a30197 (patch) | |
tree | 6fa6453e96e6da9aa67e723ff08e604a1581ae4f /src | |
parent | 7b9e8b314b37193d6ef6e830cc44e60177e247cc (diff) | |
download | qt-creator-29b7594b38f3545bb6a5d5ff08542c0e71a30197.tar.gz |
Add toogle button for bounding rects
Diffstat (limited to 'src')
8 files changed, 38 insertions, 3 deletions
diff --git a/src/plugins/qmldesigner/components/formeditor/boundingrect.png b/src/plugins/qmldesigner/components/formeditor/boundingrect.png Binary files differnew file mode 100644 index 0000000000..cba76cac66 --- /dev/null +++ b/src/plugins/qmldesigner/components/formeditor/boundingrect.png diff --git a/src/plugins/qmldesigner/components/formeditor/formeditor.qrc b/src/plugins/qmldesigner/components/formeditor/formeditor.qrc index 14e0dbd0fb..12ad311853 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditor.qrc +++ b/src/plugins/qmldesigner/components/formeditor/formeditor.qrc @@ -8,5 +8,6 @@ </qresource> <qresource prefix="/icon/layout"> <file>snapping.png</file> + <file>boundingrect.png</file> </qresource> </RCC> diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp index a6d7db612c..9918b67ba9 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp @@ -231,7 +231,9 @@ void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, qmlItemNode().paintInstance(painter); painter->setRenderHint(QPainter::Antialiasing, false); - paintBoundingRect(painter); + + if (scene()->showBoundingRects()) + paintBoundingRect(painter); painter->restore(); } diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp index 9c7c69d67a..c521d1935c 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp @@ -58,8 +58,8 @@ FormEditorScene::FormEditorScene(FormEditorWidget *view, FormEditorView *editorV m_editorView(editorView), m_formLayerItem(new LayerItem(this)), m_manipulatorLayerItem(new LayerItem(this)), - m_paintMode(NormalMode) - + m_paintMode(NormalMode), + m_showBoundingRects(true) { setSceneRect(0, 0, 1, 1); // prevent automatic calculation (causing a recursion), right size will be set later @@ -360,5 +360,16 @@ void FormEditorScene::clearFormEditorItems() } } +void FormEditorScene::setShowBoundingRects(bool show) +{ + m_showBoundingRects = show; + updateAllFormEditorItems(); +} + +bool FormEditorScene::showBoundingRects() const +{ + return m_showBoundingRects; +} + } diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.h b/src/plugins/qmldesigner/components/formeditor/formeditorscene.h index 89098ba7ab..bc521fb02e 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.h @@ -93,6 +93,10 @@ public: void clearFormEditorItems(); +public slots: + void setShowBoundingRects(bool show); + bool showBoundingRects() const; + protected: void dropEvent(QGraphicsSceneDragDropEvent * event); void dragEnterEvent(QGraphicsSceneDragDropEvent * event); @@ -123,6 +127,7 @@ private: QWeakPointer<LayerItem> m_manipulatorLayerItem; ModelNode m_dragNode; PaintMode m_paintMode; + bool m_showBoundingRects; }; diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index 3c0d540bd5..c1a941e46f 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -67,6 +67,7 @@ FormEditorView::FormEditorView(QObject *parent) m_currentTool(m_selectionTool) { connect(widget()->zoomAction(), SIGNAL(zoomLevelChanged(double)), SLOT(updateGraphicsIndicators())); + connect(widget()->showBoundingRectAction(), SIGNAL(toggled(bool)), scene(), SLOT(setShowBoundingRects(bool))); } FormEditorScene* FormEditorView::scene() const diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp index 5217711fa4..6c5eddde2f 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp @@ -90,6 +90,14 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) m_snappingToolAction->setIcon(QPixmap(":/icon/layout/snapping.png")); connect(m_snappingToolAction.data(), SIGNAL(triggered(bool)), SLOT(changeSnappingTool(bool))); + m_showBoundingRectAction = layoutActionGroup->addAction("Toogle Bounding Rectangles (Press Key R)"); + m_showBoundingRectAction->setShortcut(Qt::Key_R); + m_showBoundingRectAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); + m_showBoundingRectAction->setCheckable(true); + m_showBoundingRectAction->setChecked(true); + m_showBoundingRectAction->setIcon(QPixmap(":/icon/layout/boundingrect.png")); + + m_snappingMarginAction = new NumberSeriesAction(layoutActionGroup); m_snappingMarginAction->addEntry("no margins (0)", 0); m_snappingMarginAction->addEntry("small margin (2)", 2); @@ -179,6 +187,11 @@ QAction *FormEditorWidget::transformToolAction() const return m_transformToolAction.data(); } +QAction *FormEditorWidget::showBoundingRectAction() const +{ + return m_showBoundingRectAction.data(); +} + void FormEditorWidget::setZoomLevel(double zoomLevel) { m_graphicsView->resetTransform(); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h index 2a718507f8..2f9089b865 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h @@ -53,6 +53,7 @@ public: ZoomAction *zoomAction() const; QAction *anchorToolAction() const; QAction *transformToolAction() const; + QAction *showBoundingRectAction() const; void setScene(FormEditorScene *scene); ToolBox *toolBox() const; @@ -83,6 +84,7 @@ private: QWeakPointer<QAction> m_snappingToolAction; QWeakPointer<NumberSeriesAction> m_snappingMarginAction; QWeakPointer<NumberSeriesAction> m_snappingSpacingAction; + QWeakPointer<QAction> m_showBoundingRectAction; }; |