r21881 by jghali - display color values as tooltip in color list widget

scribus-commit scribus-commit at lists.scribus.net
Tue Apr 11 11:03:22 UTC 2017


Author: jghali
Date: Tue Apr 11 11:03:22 2017
New Revision: 21881

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21881
Log:
display color values as tooltip in color list widget

Modified:
    trunk/Scribus/scribus/ui/colorlistmodel.cpp

Modified: trunk/Scribus/scribus/ui/colorlistmodel.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21881&path=/trunk/Scribus/scribus/ui/colorlistmodel.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistmodel.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorlistmodel.cpp	Tue Apr 11 11:03:22 2017
@@ -45,6 +45,30 @@
 		if (pColorValue->m_name == CommonStrings::None)
 			return CommonStrings::tr_NoneColor;
 		return pColorValue->m_name;
+	}
+
+	if (role == Qt::ToolTipRole)
+	{
+		const ScColor& color = pColorValue->m_color;
+		if (color.getColorModel() == colorModelRGB)
+		{
+			int r, g, b;
+			color.getRawRGBColor(&r, &g, &b);
+			return QString("R:%1 G:%2 B:%3").arg(r).arg(g).arg(b);
+		}
+		else if (color.getColorModel() == colorModelCMYK)
+		{
+			int c, m, y, k;
+			color.getCMYK(&c, &m, &y, &k);
+			return QString("C:%1% M:%2% Y:%3% K:%4%").arg(qRound(c / 2.55)).arg(qRound(m / 2.55)).arg(qRound(y / 2.55)).arg(qRound(k / 2.55));
+		}
+		else if (color.getColorModel() == colorModelLab)
+		{
+			double L, a, b;
+			color.getLab(&L, &a, &b);
+			return QString("L:%1% a:%2% b:%3%").arg(L, 0, 'f', 2).arg(a, 0, 'f', 2).arg(b, 0, 'f', 2);
+		}
+		return QVariant();
 	}
 
 	if (role == Qt::UserRole)




More information about the scribus-commit mailing list