Skip to content

Commit c0065a7

Browse files
committed
Add support for indeterminate checkboxes in custom style
1 parent c7265b1 commit c0065a7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

qrenderdoc/Styles/RDStyle/RDStyle.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "RDStyle.h"
2626
#include <QAbstractItemView>
27+
#include <QBitmap>
2728
#include <QComboBox>
2829
#include <QCommonStyle>
2930
#include <QDebug>
@@ -130,6 +131,16 @@ void start(QAbstractAnimation *anim)
130131
RDStyle::RDStyle(ColorScheme scheme) : RDTweakedNativeStyle(new QCommonStyle())
131132
{
132133
m_Scheme = scheme;
134+
135+
const uchar bits[] = {
136+
0x19, // X..XX
137+
0x1C, // ..XXX
138+
0x0E, // .XXX.
139+
0x07, // XXX..
140+
0x13, // XX..X
141+
};
142+
143+
m_PartialCheckPattern = QBitmap::fromData(QSize(5, 5), bits);
133144
}
134145

135146
RDStyle::~RDStyle()
@@ -1271,7 +1282,15 @@ void RDStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *opt, Q
12711282
rect = rect.adjusted(2, 2, -1, -1);
12721283

12731284
if(opt->state & State_On)
1285+
{
12741286
p->fillRect(rect, opt->palette.brush(QPalette::ButtonText));
1287+
}
1288+
else if(opt->state & State_NoChange)
1289+
{
1290+
QBrush brush = opt->palette.brush(QPalette::ButtonText);
1291+
brush.setTexture(m_PartialCheckPattern);
1292+
p->fillRect(rect, brush);
1293+
}
12751294

12761295
p->restore();
12771296

@@ -1385,7 +1404,15 @@ void RDStyle::drawControl(ControlElement control, const QStyleOption *opt, QPain
13851404
rect = rect.adjusted(2, 2, -1, -1);
13861405

13871406
if(opt->state & State_On)
1407+
{
13881408
p->fillRect(rect, opt->palette.brush(QPalette::ButtonText));
1409+
}
1410+
else if(opt->state & State_NoChange)
1411+
{
1412+
QBrush brush = opt->palette.brush(QPalette::ButtonText);
1413+
brush.setTexture(m_PartialCheckPattern);
1414+
p->fillRect(rect, brush);
1415+
}
13891416

13901417
p->restore();
13911418

qrenderdoc/Styles/RDStyle/RDStyle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class RDStyle : public RDTweakedNativeStyle
8989
protected:
9090
ColorScheme m_Scheme = Light;
9191

92+
QBitmap m_PartialCheckPattern;
93+
9294
bool eventFilter(QObject *watched, QEvent *event) override;
9395

9496
const QBrush &outlineBrush(const QPalette &pal) const;

0 commit comments

Comments
 (0)