source/util/Util.cpp
/**
 * Converst a QString into QColor. The expected format is "|caarrggbb". |c is the start.
 * "aa" is the alpha value. "rr", "gg" and "bb" are the red, green and blue
 * hexadezimal color values respictively. Examples: |cffff0000 is red and |cff0000ff is blue.
 *
 * @param colorString The string containing the color code.
 * @return QColor
 */


@param colorString The string containing the color code.
@param colorString The string containing the color code .
QColor Util::toColor (const QString& colorString)
{
    QRegExp colorCodeRegExp = QRegExp("\\|c([a-f]|[0-9]){8}");
    colorCodeRegExp.setCaseSensitivity(Qt::CaseInsensitive);
    int alpha, red, green, blue; 
    if (colorString.indexOf(colorCodeRegExp) == 0)
    {
        alpha = colorString.mid(2, 2).toInt(Q_NULLPTR, 16);
        red = colorString.mid(4, 2).toInt(Q_NULLPTR, 16);
        green = colorString.mid(6, 2).toInt(Q_NULLPTR, 16);
        blue = colorString.mid(8, 2).toInt(Q_NULLPTR, 16);
        return QColor(red, green, blue, 255);
    }
    else
    {
        return QColor::Invalid;
    }
}
QColor Util :: toColor ( const QString & colorString ) { QRegExp colorCodeRegExp = QRegExp ( " \\ " ) ; colorCodeRegExp . setCaseSensitivity ( Qt :: CaseInsensitive ) ; int alpha , red , green , blue ; if ( colorString . indexOf ( colorCodeRegExp ) == 0 ) { alpha = colorString . mid ( 2 , 2 ) . toInt ( Q_NULLPTR , 16 ) ; red = colorString . mid ( 4 , 2 ) . toInt ( Q_NULLPTR , 16 ) ; green = colorString . mid ( 6 , 2 ) . toInt ( Q_NULLPTR , 16 ) ; blue = colorString . mid ( 8 , 2 ) . toInt ( Q_NULLPTR , 16 ) ; return QColor ( red , green , blue , 255 ) ; } else { return QColor :: Invalid ; } }
Converst a QString into QColor.
Converst a QString into QColor .
// Color values.
