fixed color handling

Sun, 18 Mar 2018 12:37:40 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 18 Mar 2018 12:37:40 +0200
changeset 1299
b692088dc1a6
parent 1298
dbc8bb2a4d84
child 1300
609b75b026c4

fixed color handling

src/dialogs/subfilereferenceeditor.cpp file | annotate | diff | comparison | revisions
src/linetypes/modelobject.cpp file | annotate | diff | comparison | revisions
src/linetypes/modelobject.h file | annotate | diff | comparison | revisions
--- a/src/dialogs/subfilereferenceeditor.cpp	Sun Mar 18 12:33:29 2018 +0200
+++ b/src/dialogs/subfilereferenceeditor.cpp	Sun Mar 18 12:37:40 2018 +0200
@@ -13,10 +13,10 @@
 	this->ui.setupUi(this);
 	this->ui.referenceName->setText(reference->referenceName());
 	this->color = reference->color();
+	::setColorButton(this->ui.colorButton, this->color);
 	this->ui.positionX->setValue(reference->position().x());
 	this->ui.positionY->setValue(reference->position().y());
 	this->ui.positionZ->setValue(reference->position().z());
-
 	connect(
 		this->ui.colorButton,
 		&QPushButton::clicked,
@@ -26,7 +26,6 @@
 				::setColorButton(this->ui.colorButton, this->color);
 		}
 	);
-
 	for (int i : {0, 1, 2})
 	for (int j : {0, 1, 2})
 	{
--- a/src/linetypes/modelobject.cpp	Sun Mar 18 12:33:29 2018 +0200
+++ b/src/linetypes/modelobject.cpp	Sun Mar 18 12:37:40 2018 +0200
@@ -271,7 +271,10 @@
 
 LDColor LDObject::color() const
 {
-	return m_color;
+	if (this->m_color.isValid())
+		return this->m_color;
+	else
+		return this->defaultColor();
 }
 
 QColor LDObject::randomColor() const
@@ -324,6 +327,9 @@
 //
 void LDObject::setColor (LDColor color)
 {
+	if (color == this->defaultColor())
+		color = LDColor::nullColor;
+
 	changeProperty(&m_color, color);
 }
 
--- a/src/linetypes/modelobject.h	Sun Mar 18 12:33:29 2018 +0200
+++ b/src/linetypes/modelobject.h	Sun Mar 18 12:37:40 2018 +0200
@@ -98,7 +98,7 @@
 private:
 	bool m_hasInvertNext = false;
 	bool m_isHidden;
-	LDColor m_color;
+	LDColor m_color = LDColor::nullColor;
 	QColor m_randomColor;
 	Vertex m_coords[4];
 };

mercurial