src/tools/selecttool.cpp

Sun, 29 Aug 2021 20:39:55 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 29 Aug 2021 20:39:55 +0300
changeset 125
f127982d3412
parent 121
000781318c36
child 126
a7c720aff97c
permissions
-rw-r--r--

Move tools under Document instead of MainWindow

#include "selecttool.h"

SelectTool::SelectTool(QObject* parent) :
	BaseTool{parent} {}

QString SelectTool::name() const
{
	static const QString result = tr("Select");
	return result;
}

QString SelectTool::toolTip() const
{
	static const QString result = tr("Select elements from the model.");
	return result;
}

bool SelectTool::mouseClick(Document* document, Canvas* canvas, QMouseEvent* event)
{
	if (event->button() == Qt::LeftButton)
	{
		static_cast<void>(document);
		const ldraw::id_t highlighted = canvas->getHighlightedObject();
		canvas->clearSelection();
		if (highlighted != ldraw::NULL_ID)
		{
			canvas->addToSelection(highlighted);
		}
		return true;
	}
	else
	{
		return false;
	}
}

mercurial