r21887 by jghali - add tooltips for colors in "Colors and Fills" dialog
scribus-commit
scribus-commit at lists.scribus.net
Wed Apr 12 10:11:50 UTC 2017
Author: jghali
Date: Wed Apr 12 10:11:49 2017
New Revision: 21887
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21887
Log:
add tooltips for colors in "Colors and Fills" dialog
Modified:
trunk/Scribus/scribus/ui/paintmanager.cpp
trunk/Scribus/scribus/ui/paintmanager.h
Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21887&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Wed Apr 12 10:11:49 2017
@@ -284,13 +284,15 @@
QMap<QString, QString>::Iterator itc;
for (itc = sortMap.begin(); itc != sortMap.end(); ++itc)
{
+ const ScColor& color = m_colorList[itc.value()];
QTreeWidgetItem *item = new QTreeWidgetItem(colorItems);
item->setText(0, itc.value());
if (itc.value() == addedName)
ret = item;
- QPixmap* pPixmap = getFancyPixmap(m_colorList[itc.value()], m_doc);
+ QPixmap* pPixmap = getFancyPixmap(color, m_doc);
item->setIcon(0, *pPixmap);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ item->setData(0, Qt::ToolTipRole, getColorTooltip(color));
}
}
else
@@ -298,13 +300,15 @@
ColorList::Iterator it;
for (it = m_colorList.begin(); it != m_colorList.end(); ++it)
{
+ const ScColor& color = it.value();
QTreeWidgetItem *item = new QTreeWidgetItem(colorItems);
item->setText(0, it.key());
if (it.key() == addedName)
ret = item;
- QPixmap* pPixmap = getFancyPixmap(it.value(), m_doc);
+ QPixmap* pPixmap = getFancyPixmap(color, m_doc);
item->setIcon(0, *pPixmap);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ item->setData(0, Qt::ToolTipRole, getColorTooltip(color));
}
}
return ret;
@@ -1416,6 +1420,30 @@
return false;
}
+QString PaintManagerDialog::getColorTooltip(const ScColor& color)
+{
+ QString tooltip;
+ if (color.getColorModel() == colorModelRGB)
+ {
+ int r, g, b;
+ color.getRawRGBColor(&r, &g, &b);
+ tooltip = tr("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);
+ tooltip = tr("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);
+ tooltip = tr("L: %1 a: %2 b: %3").arg(L, 0, 'f', 2).arg(a, 0, 'f', 2).arg(b, 0, 'f', 2);
+ }
+ return tooltip;
+}
+
ColorList PaintManagerDialog::getGradientColors()
{
ColorList colorList;
Modified: trunk/Scribus/scribus/ui/paintmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21887&path=/trunk/Scribus/scribus/ui/paintmanager.h
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.h (original)
+++ trunk/Scribus/scribus/ui/paintmanager.h Wed Apr 12 10:11:49 2017
@@ -25,6 +25,7 @@
***************************************************************************/
#ifndef PAINTMANAGER_H
#define PAINTMANAGER_H
+
#include "ui_paintmanagerbase.h"
#include "colorsetmanager.h"
#include "sccolor.h"
@@ -71,6 +72,7 @@
QMap<QString,QString> replaceMapPatterns;
QMap<QString,QString> origNamesPatterns;
QStringList origPatterns;
+
private slots:
void leaveDialog();
void slotRightClick(QPoint p);
@@ -85,11 +87,13 @@
void importColorItems();
void loadDefaults(QTreeWidgetItem* item);
void saveDefaults();
+
protected:
QTreeWidgetItem* updatePatternList(QString addedName = "");
QTreeWidgetItem* updateGradientList(QString addedName = "");
QTreeWidgetItem* updateColorList(QString addedName = "");
ColorList getGradientColors();
+ QString getColorTooltip(const ScColor& color);
bool isMandatoryColor(QString colorName);
void loadPatternDir();
void loadVectors(QString data);
More information about the scribus-commit
mailing list