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

📄 qcleanlooksstyle.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            painter->setPen(QPen(dark.lighter(110), 0));            painter->drawRect(checkRect);            if (checkbox->state & (State_On | State_Sunken  | State_NoChange)) {                QImage image(qt_cleanlooks_checkbox_checked);                painter->drawImage(rect, image);                if (checkbox->state & State_NoChange) {                    QColor bgc = option->palette.background().color();                    bgc.setAlpha(127);                    painter->fillRect(checkRect.adjusted(1, 1, -1, -1), bgc);                }            }        }        painter->restore();        break;    case PE_IndicatorRadioButton:        painter->save();        {            painter->setRenderHint(QPainter::SmoothPixmapTransform);            QRect checkRect = rect.adjusted(0, 0, 0, 0);            if (state & (State_On )) {                painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));                painter->drawImage(checkRect, QImage(qt_cleanlooks_radiobutton_checked));            }            else if (state & State_Sunken) {                painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));                QColor bgc = buttonShadow;                painter->setRenderHint(QPainter::Antialiasing);                painter->setBrush(bgc);                painter->setPen(Qt::NoPen);                painter->drawEllipse(rect.adjusted(1, 1, -1, -1));                }            else {                painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));            }        }        painter->restore();    break;    case PE_IndicatorToolBarHandle:        painter->save();        if (option->state & State_Horizontal) {            for (int i = rect.height()/5; i <= 4*(rect.height()/5) ; ++i) {                int y = rect.topLeft().y() + i + 1;                int x1 = rect.topLeft().x() + 3;                int x2 = rect.topRight().x() - 2;                if (i % 2 == 0)                    painter->setPen(QPen(option->palette.light(), 0));                else                    painter->setPen(QPen(dark.lighter(110), 0));                painter->drawLine(x1, y, x2, y);            }        }        else { //vertical toolbar            for (int i = rect.width()/5; i <= 4*(rect.width()/5) ; ++i) {                int x = rect.topLeft().x() + i + 1;                int y1 = rect.topLeft().y() + 3;                int y2 = rect.topLeft().y() + 5;                if (i % 2 == 0)                    painter->setPen(QPen(option->palette.light(), 0));                else                    painter->setPen(QPen(dark.lighter(110), 0));                painter->drawLine(x, y1, x, y2);            }        }        painter->restore();        break;    case PE_FrameDefaultButton:        case PE_FrameFocusRect:        if (const QStyleOptionFocusRect *focusFrame = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {            if (!(focusFrame->state & State_KeyboardFocusChange))                return;            QRect rect = focusFrame->rect;            painter->save();            painter->setBackgroundMode(Qt::TransparentMode);            painter->setBrush(QBrush(dark.darker(120), Qt::Dense4Pattern));            painter->setBrushOrigin(rect.topLeft());            painter->setPen(Qt::NoPen);            painter->drawRect(rect.left(), rect.top(), rect.width(), 1);    // Top            painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1); // Bottom            painter->drawRect(rect.left(), rect.top(), 1, rect.height());   // Left            painter->drawRect(rect.right(), rect.top(), 1, rect.height());  // Right            painter->restore();        }        break;    case PE_PanelButtonCommand:        {            bool isDefault = false;            bool isFlat = false;            bool isDown = (option->state & State_Sunken) || (option->state & State_On);            QPen oldPen = painter->pen();            QBrush oldBrush = painter->brush();            QRect r;            if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option)) {                isDefault = (button->features & QStyleOptionButton::DefaultButton) && (button->state & State_Enabled);                isFlat = (button->features & QStyleOptionButton::Flat);            }            if (isFlat && !isDown) {                if (isDefault) {                    r = option->rect.adjusted(0, 1, 0, -1);                    painter->setPen(QPen(Qt::black, 0));                    painter->drawLine(QPoint(r.left() + 2, r.top()),                                    QPoint(r.right() - 2, r.top()));                    painter->drawLine(QPoint(r.left(), r.top() + 2),                                    QPoint(r.left(), r.bottom() - 2));                    painter->drawLine(QPoint(r.right(), r.top() + 2),                                    QPoint(r.right(), r.bottom() - 2));                    painter->drawLine(QPoint(r.left() + 2, r.bottom()),                                    QPoint(r.right() - 2, r.bottom()));                    painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));                    painter->drawPoint(QPoint(r.right() - 1, r.top() + 1));                    painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));                    painter->drawPoint(QPoint(r.left() + 1, r.top() + 1));                    painter->setPen(oldPen);                }                return;            }            BEGIN_CLEANLOOKS_PIXMAPCACHE(QString::fromLatin1("pushbutton-%1").arg(isDefault))            r = rect.adjusted(0, 1, 0, -1);            bool isEnabled = (option->state & State_Enabled);            QColor highlightedGradientStartColor = option->palette.button().color().lighter(107);            QColor highlightedGradientMidColor = option->palette.button().color().lighter(105);            QColor highlightedGradientStopColor = buttonShadow.lighter(107);            QColor gradientStartColor = option->palette.button().color().lighter(108);            QColor buttonColor = option->palette.button().color();            QColor gradientMidColor = option->palette.button().color();            QColor gradientStopColor;            gradientStopColor.setHsv(buttonColor.hue(),                                     CL_MIN(255, (int)(buttonColor.saturation()*1.9)),                                     CL_MIN(255, (int)(buttonColor.value()*0.93)));            QRect gradRect = rect.adjusted(1, 2, -1, -2);            // gradient fill            QRect innerBorder = r.adjusted(1, 1, -1, 0);            if (isDown) {                p->fillRect(gradRect, gradientStopColor.darker(110));                p->setPen(gradientStopColor.darker(125));                p->drawLine(innerBorder.topLeft(), innerBorder.topRight());                p->drawLine(innerBorder.topLeft(), innerBorder.bottomLeft());            } else {                if (isEnabled && option->state & State_MouseOver ) {                    qt_cleanlooks_draw_buttongradient(p, gradRect,                                                highlightedGradientStartColor,                                                highlightedGradientMidColor,                                                highlightedGradientStopColor, TopDown, option->palette.button());                } else {                    qt_cleanlooks_draw_buttongradient(p, gradRect,                                                gradientStartColor,                                                gradientMidColor,                                                gradientStopColor, TopDown, option->palette.button());                }            }            bool hasFocus = option->state & State_HasFocus;            if (!isEnabled)                p->setPen(QPen(dark.lighter(115)));            else if (isDefault)                p->setPen(QPen(Qt::black, 1));            else                p->setPen(QPen(darkOutline, 1));            p->drawLine(QPoint(r.left(), r.top() + 2),                              QPoint(r.left(), r.bottom() - 2));            p->drawLine(QPoint(r.right(), r.top() + 2),                              QPoint(r.right(), r.bottom() - 2));            p->drawLine(QPoint(r.left() + 2, r.bottom()),                              QPoint(r.right() - 2, r.bottom()));            p->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));            p->drawPoint(QPoint(r.right() - 1, r.top() + 1));            p->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));            p->drawPoint(QPoint(r.left() + 1, r.top() + 1));            if (!isDefault && !hasFocus && isEnabled)                p->setPen(QPen(darkOutline.darker(110), 0));            p->drawLine(QPoint(r.left() + 2, r.top()),                              QPoint(r.right() - 2, r.top()));            QColor highlight = Qt::white;            highlight.setAlpha(110);            p->setPen(highlight);            p->drawLine(QPoint(r.left() + 1, r.top() + 2),                              QPoint(r.left() + 1, r.bottom() - 2));            p->drawLine(QPoint(r.left() + 3, r.bottom() + 1),                              QPoint(r.right() - 3, r.bottom() + 1));            QColor topShadow = darkOutline;            topShadow.setAlpha(60);            p->setPen(topShadow);            p->drawPoint(QPoint(r.right(), r.top() + 1));            p->drawPoint(QPoint(r.right() - 1, r.top() ));            p->drawPoint(QPoint(r.right(), r.bottom() - 1));            p->drawPoint(QPoint(r.right() - 1, r.bottom() ));            p->drawPoint(QPoint(r.left() + 1, r.bottom()));            p->drawPoint(QPoint(r.left(), r.bottom() - 1));            p->drawPoint(QPoint(r.left() + 1, r.top()));            p->drawPoint(QPoint(r.left(), r.top() + 1));            topShadow.setAlpha(30);            p->setPen(topShadow);            p->drawLine(QPoint(r.right() - 1, r.top() + 2),                              QPoint(r.right() - 1, r.bottom() - 2));            p->drawLine(QPoint(r.left() + 2, r.top() - 1),                              QPoint(r.right() - 2, r.top() - 1));            if (isDefault) {                r.adjust(-1, -1, 1, 1);                p->setPen(buttonShadowAlpha.darker(120));                p->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0));                p->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0));                p->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3));                p->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3));                p->drawPoint(r.topRight() + QPoint(-2, 1));                p->drawPoint(r.topRight() + QPoint(-1, 2));                p->drawPoint(r.bottomRight() + QPoint(-1, -2));                p->drawPoint(r.bottomRight() + QPoint(-2, -1));                p->drawPoint(r.topLeft() + QPoint(1, 2));                p->drawPoint(r.topLeft() + QPoint(2, 1));                p->drawPoint(r.bottomLeft() + QPoint(1, -2));                p->drawPoint(r.bottomLeft() + QPoint(2, -1));            }            painter->setPen(oldPen);            painter->setBrush(oldBrush);            END_CLEANLOOKS_PIXMAPCACHE        }        break;#ifndef QT_NO_TABBAR        case PE_FrameTabWidget:            painter->save();        {            painter->fillRect(option->rect, tabFrameColor);        }#ifndef QT_NO_TABWIDGET        if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {            QColor borderColor = darkOutline.lighter(110);            QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color());            QColor innerShadow = mergedColors(borderColor, option->palette.base().color());            int borderThickness = pixelMetric(PM_TabBarBaseOverlap, twf, widget);            bool reverse = (twf->direction == Qt::RightToLeft);            QRect tabBarRect;            switch (twf->shape) {            case QTabBar::RoundedNorth:                if (reverse) {                    tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width()                                       - twf->tabBarSize.width() + 1,                                       twf->rect.top(),                                       twf->tabBarSize.width(), borderThickness);                } else {                    tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),                                       twf->rect.top(),                                       twf->tabBarSize.width(), borderThickness);                }                break ;            case QTabBar::RoundedWest:                tabBarRect = QRect(twf->rect.left(),                                   twf->rect.top() + twf->leftCornerWidgetSize.height(),                                   borderThickness,                                   twf->tabBarSize.height());                tabBarRect = tabBarRect; //adjust                break ;            case QTabBar::RoundedEast:                tabBarRect = QRect(twf->rect.right() - borderThickness + 1,                                   twf->rect.top()  + twf->leftCornerWidgetSize.height(),                                   0,                                   twf->tabBarSize.height());                break ;            case QTabBar::RoundedSouth:                if (reverse) {                    tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1,                                       twf->rect.bottom() + 1,                                       twf->tabBarSize.width(),                                       borderThickness);                } else {                    tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),                                       twf->rect.bottom() + 1,                                       twf->tabBarSize.width(),                                       borderThickness);                }                break;            default:                break;            }            QRegion region(twf->rect);            region -= tabBarRect;            painter->setClipRegion(region);            // Outer border            QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2));            QLine rightLine = QLine(twf->rect.topRight(), twf->rect.bottomRight() - QPoint(0, 2));            QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0));            QLine topLine = QLine(twf->rect.topLeft(), twf->rect.topRight());            painter->setPen(borderColor);            painter->drawLine(topLine);            // Inner border            QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0));            QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, -1), rightLine.p2() - QPoint(1, 0));            QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1));            QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(-1, 1));            // Rounded Corner            QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1));            QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1));            QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0));            QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1));            QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1));            QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0));            QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1));            QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1));            QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0));            painter->setPen(borderColor);            painter->drawLine(leftLine);            painter->drawLine(rightLine);            painter->drawLine(bottomLine);            painter->drawPoint(leftBottomOuterCorner);            painter->drawPoint(rightBottomOuterCorner);            painter->drawPoint(leftTopOuterCorner);            painter->setPen(option->palette.light().color());            painter->drawLine(innerLeftLine);            painter->drawLine(innerTopLine);            painter->setPen(buttonShadowAlpha);

⌨️ 快捷键说明

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