Commit 29b7594b authored by Marco Bubke's avatar Marco Bubke

Add toogle button for bounding rects

parent 7b9e8b31
......@@ -8,5 +8,6 @@
</qresource>
<qresource prefix="/icon/layout">
<file>snapping.png</file>
<file>boundingrect.png</file>
</qresource>
</RCC>
......@@ -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();
}
......
......@@ -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;
}
}
......@@ -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;
};
......
......@@ -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
......
......@@ -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();
......
......@@ -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;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment