Sun, 29 Aug 2021 20:05:24 +0300
esc with draw mode now clears the polygon
96 | 1 | #include "selecttool.h" |
2 | ||
3 | SelectTool::SelectTool(QObject* parent) : | |
4 | BaseTool{parent} {} | |
5 | ||
6 | QString SelectTool::name() const | |
7 | { | |
8 | static const QString result = tr("Select"); | |
9 | return result; | |
10 | } | |
11 | ||
12 | QString SelectTool::toolTip() const | |
13 | { | |
14 | static const QString result = tr("Select elements from the model."); | |
15 | return result; | |
16 | } | |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
17 | |
121
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
18 | bool SelectTool::mouseClick(Document* document, Canvas* canvas, QMouseEvent* event) |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
19 | { |
121
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
20 | if (event->button() == Qt::LeftButton) |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
21 | { |
121
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
22 | static_cast<void>(document); |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
23 | const ldraw::id_t highlighted = canvas->getHighlightedObject(); |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
24 | canvas->clearSelection(); |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
25 | if (highlighted != ldraw::NULL_ID) |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
26 | { |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
27 | canvas->addToSelection(highlighted); |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
28 | } |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
29 | return true; |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
30 | } |
121
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
31 | else |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
32 | { |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
33 | return false; |
000781318c36
added right click support for draw tool
Teemu Piippo <teemu@hecknology.net>
parents:
111
diff
changeset
|
34 | } |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
96
diff
changeset
|
35 | } |