src/linetypes/metacommand.cpp

Wed, 25 May 2022 20:36:34 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 20:36:34 +0300
changeset 199
6988973515d2
parent 177
f69d53c053df
permissions
-rw-r--r--

Fix pick() picking from weird places on the screen with high DPI scaling

glReadPixels reads data from the frame buffer, which contains data after
high DPI scaling, so any reads to that need to take this scaling into account

#include "metacommand.h"

ldraw::MetaCommand::MetaCommand(QStringView text) :
	Object{},
	storedText{text.toString()} {}

QVariant ldraw::MetaCommand::getProperty(Property property) const
{
	switch (property)
	{
	case Property::Text:
		return storedText;
	default:
		return Object::getProperty(property);
	}
}

void ldraw::MetaCommand::setProperty(ldraw::Object::SetPropertyResult* result, const PropertyKeyValue& pair)
{
	LDRAW_OBJECT_HANDLE_SET_PROPERTY(Text, {this->storedText = value;});
	BaseClass::setProperty(result, pair);
}

QString ldraw::MetaCommand::textRepresentation() const
{
	return this->storedText;
}

ldraw::Object::Type ldraw::MetaCommand::typeIdentifier() const
{
	return Type::MetaCommand;
}

/**
 * @brief @overload ldraw::Object::serialize
 * @param stream
 * @return stream
 */
QDataStream& ldraw::MetaCommand::serialize(QDataStream& stream) const
{
	return ldraw::Object::serialize(stream) << this->storedText;
}

/**
 * @brief @overload ldraw::Object::deserialize
 * @param stream
 * @return stream
 */
QDataStream& ldraw::MetaCommand::deserialize(QDataStream& stream)
{
	return ldraw::Object::deserialize(stream) >> this->storedText;
}

QString ldraw::MetaCommand::toLDrawCode() const
{
	return "0 " + this->storedText;
}

QString ldraw::MetaCommand::iconName() const
{
	return ":/icons/chatbubble-ellipses-outline.png";
}

QString ldraw::MetaCommand::typeName() const
{
	return QObject::tr("comment");
}

mercurial