本文整理汇总了C++中ScColor::setNamedColor方法的典型用法代码示例。如果您正苦于以下问题:C++ ScColor::setNamedColor方法的具体用法?C++ ScColor::setNamedColor怎么用?C++ ScColor::setNamedColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScColor
的用法示例。
在下文中一共展示了ScColor::setNamedColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseColor
void XfigPlug::parseColor(QString data)
{
if (data.isEmpty())
return;
int colorNum, dummy;
QString colorValues;
ScColor tmp;
ScTextStream Code(&data, QIODevice::ReadOnly);
Code >> dummy >> colorNum >> colorValues;
tmp.setNamedColor(colorValues);
tmp.setSpotColor(false);
tmp.setRegistrationColor(false);
QString namPrefix = "FromXfig%1-"+colorValues;
CustColors.insert(namPrefix.arg(colorNum), tmp);
importedColors.insert(colorNum, namPrefix.arg(colorNum));
}
示例2: if
CWDialog::CWDialog(QWidget* parent, ScribusDoc* doc, const char* name, bool modal)
: QDialog (parent),
m_Doc(doc)
{
setupUi(this);
setObjectName(name);
setModal(modal);
int h, s, v;
ScColor color;
QString colorName;
connectSlots(false);
// setup combobox
typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Monochromatic), colorWheel->Monochromatic);
typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Analogous), colorWheel->Analogous);
typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Complementary), colorWheel->Complementary);
typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Split), colorWheel->Split);
typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Triadic), colorWheel->Triadic);
typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Tetradic), colorWheel->Tetradic);
// defects
defectCombo->addItem(CommonStrings::trVisionNormal);
defectCombo->addItem(CommonStrings::trVisionProtanopia);
defectCombo->addItem(CommonStrings::trVisionDeuteranopia);
defectCombo->addItem(CommonStrings::trVisionTritanopia);
defectCombo->addItem(CommonStrings::trVisionFullColorBlind);
// document colors
documentColorList->updateBox(m_Doc->PageColors, ColorListBox::fancyPixmap);
// preferences
prefs = PrefsManager::instance()->prefsFile->getPluginContext("colorwheel");
typeCombo->setCurrentIndex(prefs->getInt("cw_type", 0));
angleSpin->setValue(prefs->getInt("cw_angle", 15));
colorWheel->currentDoc = m_Doc;
colorWheel->angle = angleSpin->value();
colorWheel->baseAngle = prefs->getInt("cw_baseangle", 0);
colorspaceTab->setCurrentIndex(prefs->getInt("cw_space", 0));
color.setNamedColor(prefs->get("cw_color", "#00000000"));
// Handle color previously selected in the document tab
if (colorspaceTab->currentWidget() == tabDocument)
{
colorName = prefs->get("cw_colorname", "");
if (!colorName.isEmpty() && m_Doc->PageColors.contains(colorName))
color = m_Doc->PageColors[colorName];
else
color.setColorRGB(0, 0, 0); //Trigger use of defaults
}
// Handle achromatic colors
QColor rgb = ScColorEngine::getRGBColor(color, m_Doc);
rgb.getHsv(&h, &s, &v);
if (h == -1)
{ // Reset to defaults
colorWheel->baseAngle = 0;
colorWheel->currentColorSpace = colorModelCMYK;
colorWheel->actualColor = colorWheel->colorByAngle(0);
colorspaceTab->setCurrentIndex(0);
}
else if (colorspaceTab->currentWidget() == tabDocument)
{
colorWheel->actualColor = color;
QList<QListWidgetItem*> results = documentColorList->findItems(colorName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
if (results.count() > 0)
documentColorList->setCurrentItem(results[0]);
}
else
colorWheel->actualColor = color;
resize(QSize(prefs->getInt("cw_width", 640),
prefs->getInt("cw_height", 480)).expandedTo(minimumSizeHint()));
previewLabel->resize(prefs->getInt("cw_samplex", 300), prefs->getInt("cw_sampley", 100));
// setup
colorspaceTab_currentChanged(colorspaceTab->currentIndex());
// signals and slots that cannot be in ui file
connect(colorWheel, SIGNAL(clicked(int, const QPoint&)),
this, SLOT(colorWheel_clicked(int, const QPoint&)));
connect(documentColorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(documentColorList_currentChanged(QListWidgetItem *)));
connect(colorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(colorList_currentChanged(QListWidgetItem *)));
connect(angleSpin, SIGNAL(valueChanged(int)),
this, SLOT(angleSpin_valueChanged(int)));
connect(colorspaceTab, SIGNAL(currentChanged(int)),
this, SLOT(colorspaceTab_currentChanged(int)));
connect(typeCombo, SIGNAL(activated(int)), this, SLOT(typeCombo_activated(int)));
connect(defectCombo, SIGNAL(activated(int)), this, SLOT(defectCombo_activated(int)));
connect(addButton, SIGNAL(clicked()), this, SLOT(addButton_clicked()));
connect(replaceButton, SIGNAL(clicked()), this, SLOT(replaceButton_clicked()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelButton_clicked()));
connectSlots(true);
}
示例3: initialiseDefaultPrefs
void ColorSetManager::initialiseDefaultPrefs(struct ApplicationPrefs& appPrefs)
{
QString defaultSwatch = ScPaths::instance().shareDir() + "swatches/" + "Scribus_Basic.xml";
QFile fiC(defaultSwatch);
if (!fiC.exists())
{
appPrefs.colorPrefs.DColors.insert("White", ScColor(0, 0, 0, 0));
appPrefs.colorPrefs.DColors.insert("Black", ScColor(0, 0, 0, 255));
ScColor cc = ScColor(255, 255, 255, 255);
cc.setRegistrationColor(true);
appPrefs.colorPrefs.DColors.insert("Registration", cc);
appPrefs.colorPrefs.DColors.insert("Blue", ScColor(255, 255, 0, 0));
appPrefs.colorPrefs.DColors.insert("Cyan", ScColor(255, 0, 0, 0));
appPrefs.colorPrefs.DColors.insert("Green", ScColor(255, 0, 255, 0));
appPrefs.colorPrefs.DColors.insert("Red", ScColor(0, 255, 255, 0));
appPrefs.colorPrefs.DColors.insert("Yellow", ScColor(0, 0, 255, 0));
appPrefs.colorPrefs.DColors.insert("Magenta", ScColor(0, 255, 0, 0));
appPrefs.colorPrefs.DColorSet = "Scribus_Small";
}
else
{
if (fiC.open(QIODevice::ReadOnly))
{
QString ColorEn, Cname;
int Rval, Gval, Bval;
QTextStream tsC(&fiC);
ColorEn = tsC.readLine();
if (ColorEn.startsWith("<?xml version="))
{
QByteArray docBytes("");
loadRawText(defaultSwatch, docBytes);
QString docText("");
docText = QString::fromUtf8(docBytes);
QDomDocument docu("scridoc");
docu.setContent(docText);
ScColor lf = ScColor();
QDomElement elem = docu.documentElement();
QDomNode PAGE = elem.firstChild();
while(!PAGE.isNull())
{
QDomElement pg = PAGE.toElement();
if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
{
if (pg.hasAttribute("CMYK"))
lf.setNamedColor(pg.attribute("CMYK"));
else
lf.fromQColor(QColor(pg.attribute("RGB")));
if (pg.hasAttribute("Spot"))
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
else
lf.setSpotColor(false);
if (pg.hasAttribute("Register"))
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
else
lf.setRegistrationColor(false);
appPrefs.colorPrefs.DColors.insert(pg.attribute("NAME"), lf);
}
PAGE=PAGE.nextSibling();
}
}
else
{
while (!tsC.atEnd())
{
ColorEn = tsC.readLine();
QTextStream CoE(&ColorEn, QIODevice::ReadOnly);
CoE >> Rval;
CoE >> Gval;
CoE >> Bval;
CoE >> Cname;
ScColor tmp;
tmp.setColorRGB(Rval, Gval, Bval);
appPrefs.colorPrefs.DColors.insert(Cname, tmp);
}
}
fiC.close();
}
appPrefs.colorPrefs.DColorSet = ScPaths::instance().shareDir() + "swatches/" + "Scribus Basic";
}
示例4: importColorsFromFile
//.........这里部分代码省略.........
QDomNode PAGE = elem.firstChild();
while (!PAGE.isNull())
{
QDomElement pg = PAGE.toElement();
if (pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
{
if (pg.hasAttribute("SPACE"))
{
QString space = pg.attribute("SPACE");
if (space == "CMYK")
{
double c = pg.attribute("C", "0").toDouble() / 100.0;
double m = pg.attribute("M", "0").toDouble() / 100.0;
double y = pg.attribute("Y", "0").toDouble() / 100.0;
double k = pg.attribute("K", "0").toDouble() / 100.0;
lf.setCmykColorF(c, m, y, k);
}
else if (space == "RGB")
{
double r = pg.attribute("R", "0").toDouble() / 255.0;
double g = pg.attribute("G", "0").toDouble() / 255.0;
double b = pg.attribute("B", "0").toDouble() / 255.0;
lf.setRgbColorF(r, g, b);
}
else if (space == "Lab")
{
double L = pg.attribute("L", "0").toDouble();
double a = pg.attribute("A", "0").toDouble();
double b = pg.attribute("B", "0").toDouble();
lf.setLabColor(L, a, b);
}
}
else if (pg.hasAttribute("CMYK"))
lf.setNamedColor(pg.attribute("CMYK"));
else if (pg.hasAttribute("RGB"))
lf.fromQColor(QColor(pg.attribute("RGB")));
else
{
double L = pg.attribute("L", "0").toDouble();
double a = pg.attribute("A", "0").toDouble();
double b = pg.attribute("B", "0").toDouble();
lf.setLabColor(L, a, b);
}
if (pg.hasAttribute("Spot"))
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
else
lf.setSpotColor(false);
if (pg.hasAttribute("Register"))
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
else
lf.setRegistrationColor(false);
EditColors.tryAddColor(pg.attribute("NAME"), lf);
}
else if (pg.tagName() == "Gradient")
{
if (dialogGradients != NULL)
{
VGradient gra = VGradient(VGradient::linear);
gra.clearStops();
QDomNode grad = pg.firstChild();
while (!grad.isNull())
{
QDomElement stop = grad.toElement();
QString name = stop.attribute("NAME");
double ramp = ScCLocale::toDoubleC(stop.attribute("RAMP"), 0.0);
int shade = stop.attribute("SHADE", "100").toInt();