-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtabbing.cpp
638 lines (584 loc) · 22.9 KB
/
tabbing.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/*
* Virtuality Style for Qt4 and Qt5
* Copyright 2009-2014 by Thomas Lübking <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QToolButton>
#include "draw.h"
#include "animator/hoverindex.h"
#include <QtDebug>
inline static bool
verticalTabs(QTabBar::Shape shape)
{
return shape == QTabBar::RoundedEast ||
shape == QTabBar::TriangularEast ||
shape == QTabBar::RoundedWest ||
shape == QTabBar::TriangularWest;
}
void
Style::drawTabWidget(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
ASSURE_OPTION(twf, TabWidgetFrame);
SAVE_PAINTER(Pen);
QStyleOptionTabBarBase tbb;
if (widget)
tbb.initFrom(widget);
else
tbb.QStyleOption::operator=(*twf);
tbb.shape = twf->shape; tbb.rect = twf->rect;
tbb.selectedTabRect = twf->selectedTabRect;
#if QT_VERSION >= 0x050000
#define VALID_TABBAR_RECT twf->tabBarRect.isValid()
#else
#define VALID_TABBAR_RECT false
#endif
#define SET_BASE_HEIGHT(_o_) \
baseHeight = (widget || VALID_TABBAR_RECT) ? twf->tabBarSize._o_() : -1; \
if (!baseHeight) { \
RESTORE_PAINTER; return; \
} /* no base -> no tabbing -> no bottom border either. period.*/\
if (baseHeight < 0) \
baseHeight = pixelMetric( PM_TabBarBaseHeight, option, widget )
int baseHeight;
painter->setPen(FRAME_PEN);
switch (twf->shape) {
case QTabBar::RoundedNorth: case QTabBar::TriangularNorth:
SET_BASE_HEIGHT(height);
tbb.rect.setHeight(baseHeight);
painter->drawLine(RECT.bottomLeft(), RECT.bottomRight());
break;
case QTabBar::RoundedSouth: case QTabBar::TriangularSouth:
SET_BASE_HEIGHT(height);
tbb.rect.setTop(tbb.rect.bottom()-baseHeight);
painter->drawLine(RECT.topLeft(), RECT.topRight());
break;
case QTabBar::RoundedEast: case QTabBar::TriangularEast:
SET_BASE_HEIGHT(width);
tbb.rect.setLeft(tbb.rect.right()-baseHeight);
painter->drawLine(RECT.topLeft(), RECT.bottomLeft());
break;
case QTabBar::RoundedWest: case QTabBar::TriangularWest:
SET_BASE_HEIGHT(width);
tbb.rect.setWidth(baseHeight);
painter->drawLine(RECT.topRight(), RECT.bottomRight());
break;
}
#undef SET_BASE_HEIGHT
// the "frame"
// the bar
drawTabBar(&tbb, painter, widget);
RESTORE_PAINTER
}
void
Style::drawTabBar(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
ASSURE_OPTION(tbb, TabBarBase);
if (!config.invert.headers) {
if (tbb->selectedTabRect.isEmpty())
return; // only paint tab shapes
if (tbb->documentMode)
return; // useless and adds confliciting horizintal lines
SAVE_PAINTER(Pen|Alias);
painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(QPen(FRAME_COLOR, FRAME_STROKE_WIDTH));
switch (tbb->shape) {
case QTabBar::RoundedNorth: case QTabBar::TriangularNorth:
painter->drawLine(RECT.x(), RECT.bottom(), tbb->selectedTabRect.x(), RECT.bottom());
painter->drawLine(tbb->selectedTabRect.right() + 1, RECT.bottom(), RECT.right(), RECT.bottom());
break;
case QTabBar::RoundedSouth: case QTabBar::TriangularSouth:
painter->drawLine(RECT.x(), RECT.top(), tbb->selectedTabRect.x(), RECT.top());
painter->drawLine(tbb->selectedTabRect.right() + 1, RECT.top(), RECT.right(), RECT.top());
break;
case QTabBar::RoundedEast: case QTabBar::TriangularEast:
painter->drawLine(RECT.x(), RECT.y(), RECT.x(), tbb->selectedTabRect.y());
painter->drawLine(RECT.x(), tbb->selectedTabRect.bottom() + 1, RECT.x(), RECT.bottom());
break;
case QTabBar::RoundedWest: case QTabBar::TriangularWest:
painter->drawLine(RECT.right(), RECT.y(), RECT.right(), tbb->selectedTabRect.y());
painter->drawLine(RECT.right(), tbb->selectedTabRect.bottom() + 1, RECT.right(), RECT.bottom());
break;
}
RESTORE_PAINTER
return;
}
QWidget *win = 0;
if (widget) {
if (widget->parentWidget() && qobject_cast<QTabWidget*>(widget->parentWidget())) {
if (widget->parentWidget()->style() == this) {
return; // otherwise it's a proxystyle like on konqueror / kdevelop...
}
} else if (qobject_cast<const QTabBar*>(widget) || (appType == KDevelop && widget->inherits("QLabel"))) {
return; // usually we alter the paintevent by eventfiltering
}
win = widget->window();
} else {
if (painter->device()->devType() == QInternal::Widget)
widget = static_cast<QWidget*>(painter->device());
else {
QPaintDevice *dev =
/*** @todo, this got canned - is the plain device ok?
QPainter::redirected(painter->device());
***/
painter->device();
if (dev && dev->devType() == QInternal::Widget)
widget = static_cast<QWidget*>(dev);
}
if ( widget )
win = widget->window();
}
QRect winRect;
if (win) {
winRect = win->rect();
winRect.moveTopLeft(widget->mapFrom(win, winRect.topLeft()));
}
// else
// winRect = tbb->tabBarRect; // we set this from the eventfilter QEvent::Paint
SAVE_PAINTER(Pen|Brush|Alias);
painter->setBrush(PAL.color(QPalette::Active, QPalette::WindowText));
painter->setPen(Qt::NoPen);
// TODO: half rounded rect?
if (RECT.x() == winRect.x() || RECT.y() == winRect.y() || RECT.right() == winRect.right() || RECT.bottom() == winRect.bottom()) {
painter->setRenderHint(QPainter::Antialiasing, false);
painter->drawRect(RECT);
} else {
painter->setRenderHint(QPainter::Antialiasing, true);
const int rnd = qMin(config.frame.roundness, verticalTabs(tbb->shape) ? RECT.width()/2 : RECT.height()/2);
painter->drawRoundedRect(RECT, rnd, rnd);
}
RESTORE_PAINTER
}
static int animStep = -1;
static bool customColor = false;
void
Style::calcAnimStep(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{ // animation stuff
OPT_ENABLED OPT_HOVER OPT_SUNKEN
sunken = sunken || (option->state & State_Selected);
animStep = 0;
if ( isEnabled )
{
Animator::IndexInfo *info = 0;
int index = -1, hoveredIndex = -1;
if (widget)
if (const QTabBar* tbar = qobject_cast<const QTabBar*>(widget))
{
// NOTICE: the index increment is IMPORTANT to make sure it's not "0"
index = tbar->tabAt(RECT.topLeft()) + 1; // is the action for this item!
// sometimes... MANY times devs just set the tabTextColor to QPalette::WindowText,
// because it's defined that it has to be this. Qt provides all these color roles just
// to waste space and time... ...
QPalette::ColorRole fgrole = QPalette::WindowText, bgrole = QPalette::Window;
if (widget && config.invert.headers) {
fgrole = QPalette::Window; bgrole = QPalette::WindowText;
}
const QColor &fgColor = tbar->tabTextColor(index - 1);
const QColor &stdFgColor = tbar->palette().color(fgrole);
if (fgColor.isValid() && fgColor != stdFgColor)
{
if (fgColor == tbar->palette().color(bgrole))
const_cast<QTabBar*>(tbar)->setTabTextColor(index - 1, stdFgColor); // fixed
else // nope, this is really a custom color that will likley contrast just enough with QPalette::Window...
{
customColor = true;
if (FX::haveContrast(tbar->palette().color(bgrole), fgColor))
painter->setPen(fgColor);
}
}
if (!tbar->documentMode() || tbar->drawBase()) {
if (hover)
hoveredIndex = index;
else if (widget->underMouse())
hoveredIndex = tbar->tabAt(tbar->mapFromGlobal(QCursor::pos())) + 1;
info = const_cast<Animator::IndexInfo*>(Animator::HoverIndex::info(widget, hoveredIndex));
}
}
if (info)
animStep = info->step(index);
if (hover && !animStep)
animStep = 6;
}
}
void
Style::drawTab(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
ASSURE_OPTION(tab, Tab);
// do we have to exclude the scrollers?
bool needRestore = false;
if (widget && qobject_cast<const QTabBar*>(widget))
{
QRegion clipRgn = painter->clipRegion();
if (clipRgn.isEmpty())
clipRgn = RECT;
QList<QToolButton*> buttons = widget->findChildren<QToolButton*>();
foreach (QToolButton* button, buttons)
{
if (button->isVisible())
clipRgn -= QRect(button->pos(), button->size());
}
if (!clipRgn.isEmpty())
{
painter->save();
needRestore = true;
painter->setClipRegion(clipRgn);
}
}
// paint shape and label
// NOTICE: workaround for e.g. konsole,
// which sets the tabs bg, but not the fg color to the palette, but just
// presets the painter and hopes for the best... tststs
// TODO: bug Konsole/Konqueror authors
QPalette origPal = tab->palette;
if (widget)
const_cast<QStyleOptionTab*>(tab)->palette = widget->palette();
if (!config.invert.headers) {
drawTabShape(tab, painter, widget);
}
drawTabLabel(tab, painter, widget);
customColor = false;
if (widget)
const_cast<QStyleOptionTab*>(tab)->palette = origPal;
if (needRestore)
painter->restore();
}
void
Style::drawTabShape(const QStyleOption *option, QPainter *painter, const QWidget *) const
{
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab*>(option);
if (tab && tab->documentMode)
return; // useless and adds confliciting horizintal lines resp. wrong colors
if (config.invert.headers) {
SAVE_PAINTER(Pen|Brush);
painter->setPen(Qt::NoPen);
painter->setBrush(FCOLOR(WindowText));
painter->drawRect(RECT);
RESTORE_PAINTER
} else if (!(option->state & State_Selected)) {
if (!tab)
return;
SAVE_PAINTER(Pen|Alias|Brush);
painter->setClipping(false);
painter->setPen(QPen(FRAME_COLOR, FRAME_STROKE_WIDTH));
painter->setRenderHint(QPainter::Antialiasing, false);
switch (tab->shape) {
case QTabBar::RoundedNorth: case QTabBar::TriangularNorth:
painter->drawLine(RECT.bottomLeft(), RECT.bottomRight());
break;
case QTabBar::RoundedSouth: case QTabBar::TriangularSouth:
painter->drawLine(RECT.topLeft(), RECT.topRight());
break;
case QTabBar::RoundedEast: case QTabBar::TriangularEast:
painter->drawLine(RECT.topLeft(), RECT.bottomLeft());
break;
case QTabBar::RoundedWest: case QTabBar::TriangularWest:
painter->drawLine(RECT.topRight(), RECT.bottomRight());
break;
}
#if 0
painter->setBrush(tab->selectedPosition == QStyleOptionTab::NextIsSelected ?
FRAME_COLOR : FCOLOR(Window));
painter->setRenderHint(QPainter::Antialiasing);
QRect r(0,0,F(8),F(8));
r.moveBottom(RECT.bottom() + F(4));
if (tab->position != QStyleOptionTab::End) {
r.moveRight(RECT.right());
painter->drawEllipse(r);
}
if (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected) {
r.moveLeft(RECT.left());
painter->setBrush(FRAME_COLOR);
painter->drawEllipse(r);
}
#endif
RESTORE_PAINTER
}
}
void
Style::drawTabLabel(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
ASSURE_OPTION(tab, Tab);
OPT_SUNKEN OPT_ENABLED OPT_SELECTED OPT_FOCUS
const bool inverted = widget && config.invert.headers; // inverted tabbars are atm. not possible w/ eg. QML
calcAnimStep( option, painter, widget );
if (tab->position == QStyleOptionTab::OnlyOneTab)
{ sunken = false; /*hover = false;*/ }
else
sunken = sunken || selected;
// if (sunken) hover = false;
painter->save();
QRect tr = RECT;
bool vertical = false;
bool east = false;
int alignment = BESPIN_MNEMONIC | Qt::AlignHCenter | Qt::AlignBottom;
switch (tab->shape) {
case QTabBar::RoundedSouth:
case QTabBar::TriangularSouth:
alignment &= ~Qt::AlignBottom;
alignment |= Qt::AlignTop;
break;
case QTabBar::RoundedEast:
case QTabBar::TriangularEast:
east = true; // fall through
case QTabBar::RoundedWest:
case QTabBar::TriangularWest:
vertical = true;
break;
default:
break;
}
if (selected && tab->documentMode) {
alignment &= ~(Qt::AlignBottom|Qt::AlignTop);
alignment |= Qt::AlignVCenter;
}
if (vertical) {
int newX, newY, newRot;
if (east)
{ newX = tr.width(); newY = tr.y(); newRot = 90; }
else
{ newX = 0; newY = tr.y() + tr.height(); newRot = -90; }
tr.setRect(0, 0, tr.height(), tr.width());
QTransform m; m.translate(newX, newY); m.rotate(newRot);
painter->setTransform(m, true);
}
if (!tab->icon.isNull()) {
QSize iconSize = tab->iconSize;
if (!iconSize.isValid()) {
if (const QTabBar* tabbar = qobject_cast<const QTabBar*>(widget)) {
iconSize = tabbar->iconSize();
} else {
const int iconExtent = pixelMetric(PM_TabBarIconSize);
iconSize = QSize(iconExtent, iconExtent);
}
}
QPixmap tabIcon = tab->icon.pixmap(iconSize, (isEnabled) ? QIcon::Normal : QIcon::Disabled);
if (tab->text.isEmpty()) {
if (animStep || sunken) {
#if 0
const int s = 1414*qMin(tr.width(), tr.height())/1000;
QRect gr(0,0,s,s);
gr.moveCenter(tr.center());
QRadialGradient rg(gr.center(), s/2.0f);
QColor bgc(inverted ? PAL.color(QPalette::Active, QPalette::WindowText) :
PAL.color(QPalette::Active, QPalette::Window));
QColor c(FCOLOR(Highlight));
int contrast = FX::contrastOf(bgc, c);
if (contrast < 16) { // Bad contrast between Highlight and background...
c = FX::blend(FCOLOR(Highlight), inverted ? FCOLOR(Window) : FCOLOR(WindowText), contrast, 8);
contrast = FX::contrastOf(bgc, c);
}
c.setAlpha(sunken ? 96 + 1024/contrast : 255*animStep/6);
rg.setColorAt(0, c);
c.setAlpha(0);
rg.setColorAt(1, c);
painter->setClipping(false);
painter->fillRect(gr, rg);
#else
if (sunken)
animStep = 12;
QColor c;
if (inverted)
c = FX::blend(PAL.color(QPalette::Active, QPalette::WindowText), FCOLOR(Window), 6-animStep/2, animStep/2);
else
c = FX::blend(PAL.color(QPalette::Active, QPalette::Window), FCOLOR(Highlight), 6-animStep/2, animStep/2);
painter->setPen(Qt::NoPen);
painter->setBrush(c);
painter->drawRect(tr);
#endif
}
painter->drawPixmap(tr.center() - QPoint(tabIcon.width(), tabIcon.height())/2, tabIcon);
} else {
painter->setPen(Qt::NoPen);
painter->setBrush(tabIcon);
QPoint pos(tr.left() + F(9), tr.center().y() - tabIcon.height() / 2);
painter->setBrushOrigin(pos);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawEllipse(QRect(pos, tabIcon.size()));
tr.setLeft(tr.left() + iconSize.width() + F(12));
alignment = (alignment & ~Qt::AlignHCenter) | Qt::AlignLeft;
}
}
if (tab->text.isEmpty()) {
painter->restore();
animStep = -1;
return;
}
if (tab) {
if (vertical) {
QSize lbs, rbs;
if (east) {
lbs = tab->leftButtonSize; rbs = tab->rightButtonSize;
} else {
rbs = tab->leftButtonSize; lbs = tab->rightButtonSize;
}
if (lbs.isValid())
tr.setLeft(tr.left() + lbs.height() + F(4));
if (rbs.isValid())
tr.setRight(tr.right() - (rbs.height() + F(4)));
} else {
if (tab->leftButtonSize.isValid())
tr.setLeft(tr.left() + tab->leftButtonSize.width() + F(4));
if (tab->rightButtonSize.isValid())
tr.setRight(tr.right() - (tab->rightButtonSize.width()+F(4)));
}
}
// color adjustment
bool elide(false);
QColor cF, cB;
if (hasFocus && selected && FX::haveContrast(FCOLOR(Highlight), FCOLOR(WindowText))) {
cF = FCOLOR(Highlight);
} else if (customColor) {
if (FX::haveContrast(inverted ? FCOLOR(WindowText) : FCOLOR(Window), painter->pen().color())) {
cF = painter->pen().color();
} else {
QFont fnt = painter->font();
fnt.setItalic(true);
painter->setFont(fnt);
}
} else {
cF = inverted ? FCOLOR(Window) : FCOLOR(WindowText);
}
cB = inverted ? FCOLOR(WindowText) : FCOLOR(Window);
if (selected) {
if (vertical) {
setBold(painter, tab->text, tr.width());
} else {
QFont fnt(painter->font());
if (!inverted)
fnt.setBold(true);
if (fnt.pointSize() > 0) {
fnt.setPointSize(16*fnt.pointSize()/10);
float w = QFontMetrics(fnt).horizontalAdvance(tab->text);
w = qMin(1.0f, tr.width()/w);
if (w < 0.8f) {
elide = true;
w = 0.8f;
}
fnt.setPointSize(w*fnt.pointSize());
}
painter->setFont(fnt);
}
} else if (animStep) {
cF = FX::blend(cB, cF, 1, animStep);
if (!sunken) {
QFont fnt(painter->font());
if (fnt.pointSize() > 0)
fnt.setPointSize(13*fnt.pointSize()/10);
painter->setFont(fnt);
}
} else {
cF = FX::blend(cB, cF, 1, 1);
}
painter->setPen(cF);
if (elide) {
drawItemText(painter, tr, alignment, PAL, isEnabled, painter->fontMetrics().elidedText(tab->text, Qt::ElideRight, tr.width()));
} else
drawItemText(painter, tr, alignment, PAL, isEnabled, tab->text);
painter->restore();
animStep = -1;
}
void
Style::drawTabCloser(const QStyleOption *option, QPainter *painter, const QWidget*) const
{
OPT_SUNKEN OPT_HOVER
SAVE_PAINTER(Pen|Brush|Alias);
if (sunken) hover = false;
QRect rect = RECT;
sunken ? rect.adjust(F(5),F(4),-F(4),-F(5)) :
hover ? rect.adjust(F(3),F(2),-F(2),-F(3)) :
rect.adjust(F(4),F(3),-F(3),-F(4));
painter->setRenderHint(QPainter::Antialiasing);
QColor c = FX::blend( FCOLOR(WindowText), FCOLOR(Window), 3, 1+hover );
painter->setPen( QPen( c, F(3) ) );
painter->setBrush(Qt::NoBrush);
painter->drawEllipse( rect );
// c = hover ? CCOLOR(tab.active, Fg) : FX::blend( CCOLOR(tab.active, Bg), CCOLOR(tab.active, Fg) );
// painter->setPen( QPen( c, F(2) ) );
// rect.adjust(F(2),F(2),-F(2),-F(2));
// painter->drawEllipse( rect );
RESTORE_PAINTER
}
void
Style::drawToolboxTab(const QStyleOption *option, QPainter *painter, const QWidget * widget) const
{
ASSURE_OPTION(tbt, ToolBox);
// color fix...
if (widget && widget->parentWidget())
const_cast<QStyleOption*>(option)->palette = widget->parentWidget()->palette();
drawToolboxTabShape(tbt, painter, widget);
QStyleOptionToolBox copy = *tbt;
copy.rect.adjust(F(2), F(2), -F(2), -F(2));
drawToolboxTabLabel(©, painter, widget);
}
void
Style::drawToolboxTabShape(const QStyleOption *option, QPainter *painter, const QWidget *) const
{
ASSURE_OPTION(tbt, ToolBox);
if (option->state & State_Selected) {
if (config.invert.headers) {
SAVE_PAINTER(Pen|Brush|Alias);
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(Qt::NoPen);
painter->setBrush(FCOLOR(WindowText));
const int rnd = qMin(config.frame.roundness, RECT.height()/2);
painter->drawRoundedRect(RECT, rnd, rnd);
RESTORE_PAINTER
}
} else {
OPT_SUNKEN
SAVE_PAINTER(Pen);
painter->setPen(sunken ? FOCUS_FRAME_PEN : FRAME_PEN);
QRect r = painter->fontMetrics().boundingRect(RECT, BESPIN_MNEMONIC|Qt::AlignCenter, tbt->text);
const int y = r.y() + r.height()/2;
const int d = (RECT.width() - r.width())/6 + F(6);
painter->drawLine(r.x() - d, y, r.x() - (sunken ? F(12) : F(6)), y);
painter->drawLine(r.right() + (sunken ? F(12) : F(6)), y, r.right() + d, y);
RESTORE_PAINTER
}
}
void
Style::drawToolboxTabLabel(const QStyleOption *option, QPainter *painter, const QWidget *) const
{
ASSURE_OPTION(tbt, ToolBox);
OPT_ENABLED OPT_SUNKEN OPT_HOVER OPT_SELECTED
SAVE_PAINTER(sunken||selected ? Font : 0);
uint tf = BESPIN_MNEMONIC;
QPalette::ColorRole role = QPalette::WindowText;
if (selected) {
tf |= Qt::AlignBottom;
if (config.invert.headers) {
role = QPalette::Window;
tf |= Qt::AlignHCenter;
} else {
tf |= Qt::AlignLeft;
}
QFont fnt(painter->font());
if (fnt.pointSize() > 0) {
fnt.setPointSize(15*fnt.pointSize()/10);
fnt.setBold(true);
}
painter->setFont(fnt);
} else {
if (hover || sunken)
role = QPalette::Highlight;
if (sunken) {
QFont fnt(painter->font());
fnt.setBold(true);
painter->setFont(fnt);
}
tf |= Qt::AlignCenter;
}
drawItemText(painter, RECT, tf, PAL, isEnabled, tbt->text, role);
RESTORE_PAINTER
}