diff options
-rw-r--r-- | src/gui/mainmenu.cpp | 6 | ||||
-rw-r--r-- | src/gui/mainmenu.h | 1 | ||||
-rw-r--r-- | src/gui/mainmenu.ui | 15 | ||||
-rw-r--r-- | src/gui/nodeitem.cpp | 8 | ||||
-rw-r--r-- | src/gui/tikzscene.cpp | 11 | ||||
-rw-r--r-- | src/gui/tikzscene.h | 4 |
6 files changed, 44 insertions, 1 deletions
diff --git a/src/gui/mainmenu.cpp b/src/gui/mainmenu.cpp index 35ab736..fe291a2 100644 --- a/src/gui/mainmenu.cpp +++ b/src/gui/mainmenu.cpp @@ -301,6 +301,12 @@ void MainMenu::on_actionZoom_Out_triggered() if (tikzit->activeWindow() != 0) tikzit->activeWindow()->tikzView()->zoomOut(); } +void MainMenu::on_actionShow_Node_Labels_triggered() +{ + tikzit->activeWindow()->tikzScene()->setDrawNodeLabels(ui.actionShow_Node_Labels->isChecked()); + tikzit->activeWindow()->tikzScene()->invalidate(); +} + void MainMenu::on_actionAbout_triggered() { QMessageBox::about(this, diff --git a/src/gui/mainmenu.h b/src/gui/mainmenu.h index 51d7d3c..220e3bd 100644 --- a/src/gui/mainmenu.h +++ b/src/gui/mainmenu.h @@ -78,6 +78,7 @@ public slots: // View void on_actionZoom_In_triggered(); void on_actionZoom_Out_triggered(); + void on_actionShow_Node_Labels_triggered(); // Help void on_actionAbout_triggered(); diff --git a/src/gui/mainmenu.ui b/src/gui/mainmenu.ui index 692f82e..eb3bed3 100644 --- a/src/gui/mainmenu.ui +++ b/src/gui/mainmenu.ui @@ -92,6 +92,7 @@ </property> <addaction name="actionZoom_In"/> <addaction name="actionZoom_Out"/> + <addaction name="actionShow_Node_Labels"/> </widget> <widget class="QMenu" name="menuHelp"> <property name="title"> @@ -383,6 +384,20 @@ <string>Ctrl+M</string> </property> </action> + <action name="actionShow_Node_Labels"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Node Labels</string> + </property> + <property name="shortcut"> + <string>Ctrl+Shift+L</string> + </property> + </action> <addaction name="menuFile"/> <addaction name="menuEdit"/> <addaction name="menuView"/> diff --git a/src/gui/nodeitem.cpp b/src/gui/nodeitem.cpp index 82692f2..7ae4c4a 100644 --- a/src/gui/nodeitem.cpp +++ b/src/gui/nodeitem.cpp @@ -91,7 +91,13 @@ void NodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge painter->drawPath(shape()); } - if (_node->label() != "") { + bool drawLabel = _node->label() != ""; + if (scene()) { + TikzScene *sc = static_cast<TikzScene*>(scene()); + drawLabel= drawLabel && sc->drawNodeLabels(); + } + + if (drawLabel) { QRectF rect = labelRect(); QPen pen(QColor(200,0,0,120)); QVector<qreal> d; diff --git a/src/gui/tikzscene.cpp b/src/gui/tikzscene.cpp index 4577981..969a355 100644 --- a/src/gui/tikzscene.cpp +++ b/src/gui/tikzscene.cpp @@ -38,6 +38,7 @@ TikzScene::TikzScene(TikzDocument *tikzDocument, ToolPalette *tools, { _modifyEdgeItem = nullptr; _edgeStartNodeItem = nullptr; + _drawNodeLabels = true; _drawEdgeItem = new QGraphicsLineItem(); _rubberBandItem = new QGraphicsRectItem(); _enabled = true; @@ -907,6 +908,16 @@ void TikzScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) } } +bool TikzScene::drawNodeLabels() const +{ + return _drawNodeLabels; +} + +void TikzScene::setDrawNodeLabels(bool drawNodeLabels) +{ + _drawNodeLabels = drawNodeLabels; +} + bool TikzScene::highlightTails() const { return _highlightTails && getSelectedNodes().isEmpty(); diff --git a/src/gui/tikzscene.h b/src/gui/tikzscene.h index f8dc7ec..1edd50a 100644 --- a/src/gui/tikzscene.h +++ b/src/gui/tikzscene.h @@ -90,6 +90,9 @@ public: bool highlightHeads() const; bool highlightTails() const; + bool drawNodeLabels() const; + void setDrawNodeLabels(bool drawNodeLabels); + public slots: void graphReplaced(); void refreshZIndices(); @@ -115,6 +118,7 @@ private: bool _firstControlPoint; QPointF _mouseDownPos; bool _draggingNodes; + bool _drawNodeLabels; QMap<Node*,QPointF> _oldNodePositions; qreal _oldWeight; |