📄 qplastiquestyle.cpp
字号:
static const char * const qt_scrollbar_button_arrow_right[] = { "4 7 2 1", " c None", "* c #BFBFBF", "* ", "** ", "*** ", "****", "*** ", "** ", "* "};static const char * const qt_scrollbar_button_arrow_up[] = { "7 4 2 1", " c None", "* c #BFBFBF", " * ", " *** ", " ***** ", "*******"};static const char * const qt_scrollbar_button_arrow_down[] = { "7 4 2 1", " c None", "* c #BFBFBF", "*******", " ***** ", " *** ", " * "};static const char * const qt_scrollbar_button_left[] = { "16 16 6 1", " c None", ". c #BFBFBF", "+ c #979797", "# c #FAFAFA", "< c #FAFAFA", "* c #FAFAFA", " .+++++++++++++.", ".+#############+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", ".+<<<<<<<<<<<<<+", " .+++++++++++++."};static const char * const qt_scrollbar_button_right[] = { "16 16 6 1", " c None", ". c #BFBFBF", "+ c #979797", "# c #FAFAFA", "< c #FAFAFA", "* c #FAFAFA", ".+++++++++++++. ", "+#############+.", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+<<<<<<<<<<<<<+.", ".+++++++++++++. "};static const char * const qt_scrollbar_button_up[] = { "16 16 6 1", " c None", ". c #BFBFBF", "+ c #979797", "# c #FAFAFA", "< c #FAFAFA", "* c #FAFAFA", " .++++++++++++. ", ".+############+.", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+<<<<<<<<<<<<<<+", ".++++++++++++++."};static const char * const qt_scrollbar_button_down[] = { "16 16 6 1", " c None", ". c #BFBFBF", "+ c #979797", "# c #FAFAFA", "< c #FAFAFA", "* c #FAFAFA", "++++++++++++++++", "+##############+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", "+# <+", ".+<<<<<<<<<<<<+.", " .++++++++++++. "};static const char * const qt_scrollbar_slider_pattern_vertical[] = { "10 18 3 1", " c None", ". c #BFBFBF", "+ c #979797", ".. .. ..", ".+ .+ .+", " ", " ", ".. .. ..", ".+ .+ .+", " ", " ", ".. .. ..", ".+ .+ .+", " ", " ", ".. .. ..", ".+ .+ .+", " ", " ", ".. .. ..", ".+ .+ .+"};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"," "," "," "," "," "," "," "," "," +@##@+ "," .@@@.+@@.. "," .##+ +@@+. "," .##@ @#@+. "," .... +@+.. "," .@+@@.. "," +#@@+ "," .##. "," .++. "," .++. "," +##+ "," .@@. "," "," "," "," "," "," "," "};static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50){ const int maxFactor = 100; QColor tmp = colorA; tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor); tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor); tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor); return tmp;}static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size){ QString tmp; const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); tmp.sprintf("%s-%d-%d-%d-%dx%d", key.toLatin1().constData(), uint(option->state), complexOption ? uint(complexOption->activeSubControls) : uint(0), option->palette.serialNumber(), size.width(), size.height()); return tmp;}static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientStop){ QString gradientName; gradientName.sprintf("%dx%d-%x-%x", rect.width(), rect.height(), gradientStart.rgba(), gradientStop.rgba()); QPixmap cache; if (!UsePixmapCache || !QPixmapCache::find(gradientName, cache)) { cache = QPixmap(rect.size()); cache.fill(Qt::white); QPainter cachePainter(&cache); QRect pixmapRect(0, 0, rect.width(), rect.height()); int x = pixmapRect.center().x(); QLinearGradient gradient(x, pixmapRect.top(), x, pixmapRect.bottom()); gradient.setColorAt(0, gradientStart); gradient.setColorAt(1, gradientStop); cachePainter.fillRect(pixmapRect, gradient); cachePainter.end(); if (UsePixmapCache) QPixmapCache::insert(gradientName, cache); } painter->drawPixmap(rect, cache);}static void qt_plastique_drawFrame(QPainter *painter, const QStyleOption *option, const QWidget *widget){ QRect rect = option->rect; QPen oldPen = painter->pen(); QColor borderColor = option->palette.background().color().dark(178); QColor gradientStartColor = option->palette.button().color().light(104); QColor gradientStopColor = option->palette.button().color().dark(105); QColor alphaCornerColor; if (widget) { // ### backgroundrole/foregroundrole should be part of the style option alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor); } else { alphaCornerColor = mergedColors(option->palette.background().color(), borderColor); } // outline / border painter->setPen(borderColor); painter->drawLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); painter->drawLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); painter->drawLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); painter->drawLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); painter->drawPoint(rect.left() + 1, rect.top() + 1); painter->drawPoint(rect.right() - 1, rect.top() + 1); painter->drawPoint(rect.left() + 1, rect.bottom() - 1); painter->drawPoint(rect.right() - 1, rect.bottom() - 1); painter->setPen(alphaCornerColor); painter->drawPoint(rect.left() + 1, rect.top()); painter->drawPoint(rect.right() - 1, rect.top()); painter->drawPoint(rect.left() + 1, rect.bottom()); painter->drawPoint(rect.right() - 1, rect.bottom()); painter->drawPoint(rect.left(), rect.top() + 1); painter->drawPoint(rect.right(), rect.top() + 1); painter->drawPoint(rect.left(), rect.bottom() - 1); painter->drawPoint(rect.right(), rect.bottom() - 1); // inner border if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) painter->setPen(option->palette.button().color().dark(118)); else painter->setPen(gradientStartColor); painter->drawLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, option->rect.top() + 1); painter->drawLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, option->rect.bottom() - 2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -