summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2019-01-11 12:03:36 +0100
committerAleks Kissinger <aleks0@gmail.com>2019-01-11 12:03:36 +0100
commit7b59b08aa0188daa485e088f6125bcc5c3a11f85 (patch)
treeb639aebe00af708ea639baca9bc9b93522bad35e
parent710fdcc3eefc8bd0c206f6f105d02381b0b0c9bd (diff)
smart tool
-rw-r--r--src/gui/tikzscene.cpp22
-rw-r--r--src/gui/tikzscene.h1
2 files changed, 22 insertions, 1 deletions
diff --git a/src/gui/tikzscene.cpp b/src/gui/tikzscene.cpp
index 8c1e853..47179f7 100644
--- a/src/gui/tikzscene.cpp
+++ b/src/gui/tikzscene.cpp
@@ -29,6 +29,7 @@
#include <QInputDialog>
#include <cmath>
#include <delimitedstringvalidator.h>
+#include <QSettings>
TikzScene::TikzScene(TikzDocument *tikzDocument, ToolPalette *tools,
@@ -227,6 +228,7 @@ void TikzScene::refreshZIndices()
void TikzScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
+ QSettings settings("tikzit", "tikzit");
if (!_enabled) return;
// current mouse position, in scene coordinates
@@ -238,7 +240,19 @@ void TikzScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
qreal cpR = GLOBAL_SCALEF * (0.1);
qreal cpR2 = cpR * cpR;
-
+ if (event->button() == Qt::RightButton &&
+ _tools->currentTool() == ToolPalette::SELECT &&
+ settings.value("smart-tool-enabled", true).toBool())
+ {
+ _smartTool = true;
+ if (!items(_mouseDownPos).isEmpty() &&
+ dynamic_cast<NodeItem*>(items(_mouseDownPos)[0]))
+ {
+ _tools->setCurrentTool(ToolPalette::EDGE);
+ } else {
+ _tools->setCurrentTool(ToolPalette::VERTEX);
+ }
+ }
switch (_tools->currentTool()) {
case ToolPalette::SELECT:
@@ -571,6 +585,12 @@ void TikzScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
break;
}
+ if (_smartTool) {
+ _tools->setCurrentTool(ToolPalette::SELECT);
+ }
+
+ _smartTool = false;
+
// clear artefacts from rubber band selection
invalidate(QRect(), QGraphicsScene::BackgroundLayer);
}
diff --git a/src/gui/tikzscene.h b/src/gui/tikzscene.h
index 3baa929..3e46f6d 100644
--- a/src/gui/tikzscene.h
+++ b/src/gui/tikzscene.h
@@ -121,6 +121,7 @@ private:
bool _highlightHeads;
bool _highlightTails;
+ bool _smartTool;
};
#endif // TIKZSCENE_H