Beispiel #1
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

//! [0]
    QTextBrowser browser;
    QColor linkColor(Qt::red);
    QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
    browser.document()->setDefaultStyleSheet(sheet);
//! [0]
    browser.setSource(QUrl("../../../html/index.html"));
    browser.resize(800, 600);
    browser.show();

    return app.exec();
}
Beispiel #2
0
Color TextLinkColors::colorFromPrimitiveValue(const CSSPrimitiveValue* value, Color currentColor, bool forVisitedLink) const
{
    if (value->isRGBColor())
        return Color(value->getRGBA32Value());

    CSSValueID valueID = value->getValueID();
    switch (valueID) {
    case 0:
        return Color();
    case CSSValueWebkitText:
        return textColor();
    case CSSValueWebkitLink:
        return forVisitedLink ? visitedLinkColor() : linkColor();
    case CSSValueWebkitActivelink:
        return activeLinkColor();
    case CSSValueWebkitFocusRingColor:
        return RenderTheme::focusRingColor();
    case CSSValueCurrentcolor:
        return currentColor;
    default:
        return colorForCSSValue(valueID);
    }
}
Color TextLinkColors::colorFromCSSValue(const CSSValue& value, Color currentColor, bool forVisitedLink) const
{
    if (value.isColorValue())
        return toCSSColorValue(value).value();

    CSSValueID valueID = toCSSPrimitiveValue(value).getValueID();
    switch (valueID) {
    case 0:
        return Color();
    case CSSValueWebkitText:
        return textColor();
    case CSSValueWebkitLink:
        return forVisitedLink ? visitedLinkColor() : linkColor();
    case CSSValueWebkitActivelink:
        return activeLinkColor();
    case CSSValueWebkitFocusRingColor:
        return LayoutTheme::theme().focusRingColor();
    case CSSValueInvert: // We don't support outline-color: invert
    case CSSValueCurrentcolor:
        return currentColor;
    default:
        return StyleColor::colorFromKeyword(valueID);
    }
}