⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qplastiquestyle.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    "..  ..  ..",    ".+  .+  .+",    "          ",    "          ",    "..  ..  ..",    ".+  .+  .+",    "          ",    "          ",    "..  ..  ..",    ".+  .+  .+"};static const char * const qt_scrollbar_slider_pattern_horizontal[] = {    "18 10 3 1",    "   c None",    ".  c #BFBFBF",    "+  c #979797",    "..  ..  ..  ..  ..",    ".+  .+  .+  .+  .+",    "                  ",    "                  ",    "..  ..  ..  ..  ..",    ".+  .+  .+  .+  .+",    "                  ",    "                  ",    "..  ..  ..  ..  ..",    ".+  .+  .+  .+  .+"};static const char * const qt_toolbarhandle[] = {    "6 6 4 1",    "       c None",    ".      c #C5C5C5",    "+      c #EEEEEE",    "@      c #FAFAFA",    "..    ",    ".+@   ",    " @@   ",    "   .. ",    "   .+@",    "    @@"};static const char * const qt_simple_toolbarhandle[] = {    "3 3 4 1",    "       c None",    ".      c #C5C5C5",    "+      c #EEEEEE",    "@      c #FAFAFA",    ".. ",    ".+@",    " @@"};static const char * const qt_titlebar_context_help[] = {"27 27 5 1","  c None",". c #0A0C12","+ c #1B202D","@ c #293144","# c #3C435D","                           ","                           ","                           ","                           ","                           ","                           ","                           ","                           ","           +@##@+          ","         .@@@.+@@..        ","         .##+  +@@+.       ","         .##@  @#@+.       ","         ....  +@+..       ","            .@+@@..        ","            +#@@+          ","            .##.           ","            .++.           ","            .++.           ","            +##+           ","            .@@.           ","                           ","                           ","                           ","                           ","                           ","                           ","                           "};#define BEGIN_PLASTIQUE_PIXMAPCACHE(a) \    QRect rect = button->rect; \    QPixmap cache; \    QPainter *p = painter; \    QString unique = uniqueName((a), option, option->rect.size()); \    if (UsePixmapCache) { \        if (!QPixmapCache::find(unique, cache)) { \            rect.setRect(0, 0, option->rect.width(), option->rect.height()); \            cache = QPixmap(option->rect.size()); \            cache.fill(Qt::transparent); \            p = new QPainter(&cache); \        } else { \            painter->drawPixmap(button->rect.topLeft(), cache); \            break; \        } \    }#define END_PLASTIQUE_PIXMAPCACHE \    if (p != painter) { \        p->end(); \        delete p; \        painter->drawPixmap(option->rect.topLeft(), cache); \        QPixmapCache::insert(unique, cache); \    }static QLinearGradient qMapGradientToRect(const QLinearGradient &gradient, const QRectF &rect){    QLinearGradient tmpGrad(rect.center().x(), rect.top(),                            rect.center().x(), rect.bottom());    tmpGrad.setStops(gradient.stops());    return tmpGrad;}static QBrush qMapBrushToRect(const QBrush &brush, const QRectF &rect){    if (!brush.gradient())        return brush;    // ### Ugly assumption that it's a linear gradient    QBrush tmp(qMapGradientToRect(*static_cast<const QLinearGradient *>(brush.gradient()), rect));    return tmp;}static void qBrushSetAlphaF(QBrush *brush, qreal alpha){    if (const QGradient *gradient = brush->gradient()) {        // Use the gradient. Call QColor::setAlphaF() on all color stops.        QGradientStops stops = gradient->stops();        QMutableVectorIterator<QGradientStop> it(stops);        QColor tmpColor;        while (it.hasNext()) {            it.next();            tmpColor = it.value().second;            tmpColor.setAlphaF(alpha * tmpColor.alphaF());            it.setValue(QPair<qreal, QColor>(it.value().first, tmpColor));        }        switch (gradient->type()) {        case QGradient::RadialGradient: {            QRadialGradient grad = *static_cast<const QRadialGradient *>(gradient);            grad.setStops(stops);            *brush = QBrush(grad);            break;        }        case QGradient::ConicalGradient: {            QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient);            grad.setStops(stops);            *brush = QBrush(grad);            break;        }        default:            qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type"                     " - falling back to QLinearGradient");        case QGradient::LinearGradient: {            QLinearGradient grad = *static_cast<const QLinearGradient *>(gradient);            grad.setStops(stops);            *brush = QBrush(grad);            break;        }        }    } else if (!brush->texture().isNull()) {        // Modify the texture - ridiculously expensive.        QPixmap texture = brush->texture();        QPixmap pixmap;        QString name = QString::fromLatin1("qbrushtexture-alpha-%1-%2").arg(alpha).arg(texture.cacheKey());        if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) {            QImage image = texture.toImage();            QRgb *rgb = reinterpret_cast<QRgb *>(image.bits());            int pixels = image.width() * image.height();            QColor tmpColor;            while (pixels--) {                tmpColor.setRgb(*rgb);                tmpColor.setAlphaF(alpha * tmpColor.alphaF());                *rgb++ = tmpColor.rgba();            }            pixmap = QPixmap::fromImage(image);            QPixmapCache::insert(name, pixmap);        }        brush->setTexture(pixmap);    } else {        // Use the color        QColor tmpColor = brush->color();        tmpColor.setAlphaF(alpha * tmpColor.alphaF());        brush->setColor(tmpColor);    }}static QBrush qBrushLight(QBrush brush, int light){    if (const QGradient *gradient = brush.gradient()) {        // Use the gradient. Call QColor::lighter() on all color stops.        QGradientStops stops = gradient->stops();        QMutableVectorIterator<QGradientStop> it(stops);        while (it.hasNext()) {            it.next();            it.setValue(QPair<qreal, QColor>(it.value().first, it.value().second.lighter(light)));        }        switch (gradient->type()) {        case QGradient::RadialGradient: {            QRadialGradient grad = *static_cast<const QRadialGradient *>(gradient);            grad.setStops(stops);            brush = QBrush(grad);            break;        }        case QGradient::ConicalGradient: {            QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient);            grad.setStops(stops);            brush = QBrush(grad);            break;        }        default:            qWarning("QPlastiqueStyle::qBrushLight() - unknown gradient type"                     " - falling back to QLinearGradient");        case QGradient::LinearGradient: {            QLinearGradient grad = *static_cast<const QLinearGradient *>(gradient);            grad.setStops(stops);            brush = QBrush(grad);            break;        }        }    } else if (!brush.texture().isNull()) {        // Modify the texture - ridiculously expensive.        QPixmap texture = brush.texture();        QPixmap pixmap;        QString name = QString::fromLatin1("qbrushtexture-light-%1-%2").arg(light).arg(texture.cacheKey());        if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) {            QImage image = texture.toImage();            QRgb *rgb = reinterpret_cast<QRgb *>(image.bits());            int pixels = image.width() * image.height();            QColor tmpColor;            while (pixels--) {                tmpColor.setRgb(*rgb);                *rgb++ = tmpColor.lighter(light).rgba();            }            pixmap = QPixmap::fromImage(image);            QPixmapCache::insert(name, pixmap);        }        brush.setTexture(pixmap);    } else {        // Use the color        brush.setColor(brush.color().lighter(light));    }    return brush;}static QBrush qBrushDark(QBrush brush, int dark){    if (const QGradient *gradient = brush.gradient()) {        // Use the gradient. Call QColor::darker() on all color stops.        QGradientStops stops = gradient->stops();        QMutableVectorIterator<QGradientStop> it(stops);        while (it.hasNext()) {            it.next();            it.setValue(QPair<qreal, QColor>(it.value().first, it.value().second.darker(dark)));        }        switch (gradient->type()) {        case QGradient::RadialGradient: {            QRadialGradient grad = *static_cast<const QRadialGradient *>(gradient);            grad.setStops(stops);            brush = QBrush(grad);            break;        }        case QGradient::ConicalGradient: {            QConicalGradient grad = *static_cast<const QConicalGradient *>(gradient);            grad.setStops(stops);            brush = QBrush(grad);            break;        }        default:            qWarning("QPlastiqueStyle::qBrushDark() - unknown gradient type"                     " - falling back to QLinearGradient");        case QGradient::LinearGradient: {            QLinearGradient grad = *static_cast<const QLinearGradient *>(gradient);            grad.setStops(stops);            brush = QBrush(grad);            break;        }        }    } else if (!brush.texture().isNull()) {        // Modify the texture - ridiculously expensive.        QPixmap texture = brush.texture();        QPixmap pixmap;        QString name = QString::fromLatin1("qbrushtexture-dark-%1-%2").arg(dark).arg(brush.texture().cacheKey());        if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) {            QImage image = texture.toImage();            QRgb *rgb = reinterpret_cast<QRgb *>(image.bits());            int pixels = image.width() * image.height();            QColor tmpColor;            while (pixels--) {                tmpColor.setRgb(*rgb);                *rgb++ = tmpColor.darker(dark).rgba();            }            pixmap = QPixmap::fromImage(image);            QPixmapCache::insert(name, pixmap);        }        brush.setTexture(pixmap);    } else {        // Use the color        brush.setColor(brush.color().darker(dark));    }    return brush;}/*    Draws a rounded frame using the provided brush for 1, and adds 0.5 alpha    for 0.     0111111110    01        10    1          1    1          1    1          1    01        10     0111111110*/static void qt_plastique_draw_frame(QPainter *painter, const QRect &rect, const QStyleOption *option,                                    QFrame::Shadow shadow = QFrame::Plain){    QPen oldPen = painter->pen();    QBrush border;    QBrush corner;    QBrush innerTopLeft;    QBrush innerBottomRight;    if (shadow != QFrame::Plain && (option->state & QStyle::State_HasFocus)) {        border = option->palette.highlight();        qBrushSetAlphaF(&border, 0.8);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -