QColor TColor::XSL_FO_ColorName::color( const QString colorchunk ) { QString wandedcolor = colorchunk; QString fcol = wandedcolor.trimmed().toLower(); if (COLORNAME.contains(fcol)) { return avaiablelist[fcol]; } if (fcol.size() < 2) { return QColor( 0, 0, 0,255); } if (fcol.startsWith("rgb(")) { QString grep = fcol.mid(4,fcol.size() - 5); grep = grep.replace(")",""); QStringList v = grep.split(","); if (v.size() == 3) { const int R1 = v.at(0).toInt(); const int R2 = v.at(1).toInt(); const int R3 = v.at(2).toInt(); return QColor(R1,R2,R3,255); } else if(v.size() >= 4) { const int Rt1 = v.at(0).toInt(); const int Rt2 = v.at(1).toInt(); const int Rt3 = v.at(2).toInt(); const int Ralph = v.at(3).toInt(); QColor cctra(Rt1,Rt2,Rt3); cctra.setAlpha(Ralph); return cctra; } else { return QColor( 0, 0, 0,255); } } if (fcol.startsWith("#")) { return QColor(fcol); } return QColor( 0, 0, 0,255); }
QColor FopLeader::ColorFromFoString( QString focolor ) { QString fcol = focolor.trimmed().toLower(); if (fcol.size() < 2) { return QColor(Qt::transparent); } if (fcol.startsWith("rgb(")) { QString grep = fcol.mid(4,fcol.size() - 5); grep = grep.replace(")",""); QStringList v = grep.split(","); if (v.size() == 3) { const int R1 = v.at(0).toInt(); const int R2 = v.at(1).toInt(); const int R3 = v.at(2).toInt(); return QColor(R1,R2,R3,255); } else if(v.size() >= 4) { const int Rt1 = v.at(0).toInt(); const int Rt2 = v.at(1).toInt(); const int Rt3 = v.at(2).toInt(); const int Ralph = v.at(3).toInt(); QColor cctra(Rt1,Rt2,Rt3); cctra.setAlpha(Ralph); return cctra; } else { return QColor(Qt::darkBlue); } } else if (fcol.startsWith("#")) { return QColor(fcol); } else { QColor fasi(Imagename(fcol)); if (fasi.isValid () ) { return fasi; } else { return QColor(Qt::black); } } return QColor(Qt::transparent); }