kstyle: make spinbox buttons consistently widthed

Now their width doesn't change when the height changes.

BUG: 441036
FIXED-IN: 5.23
wilder-5.24
Jan Blackquill 5 years ago
parent d59275df3b
commit fc30c11a4a
  1. 17
      kstyle/breezestyle.cpp

@ -2362,6 +2362,9 @@ namespace Breeze
if( !spinBoxOption ) return ParentStyleClass::subControlRect( CC_SpinBox, option, subControl, widget );
const bool flat( !spinBoxOption->frame );
const int frameWidth( pixelMetric( PM_SpinBoxFrameWidth, option, widget ) );
const int buttonSize( option->fontMetrics.height() + 2*frameWidth );
// copy rect
auto rect( option->rect );
@ -2372,30 +2375,31 @@ namespace Breeze
case SC_SpinBoxUp:
{
auto r = rect;
r.setLeft(r.width()-r.height());
r.setLeft(r.width()-buttonSize);
return r;
}
case SC_SpinBoxDown:
{
auto r = rect;
r.setRight(r.height());
r.setRight(buttonSize);
return r;
}
case SC_SpinBoxEditField:
{
const bool showButtons = spinBoxOption->buttonSymbols != QAbstractSpinBox::NoButtons;
const int frameWidth( pixelMetric( PM_SpinBoxFrameWidth, option, widget ) );
const int buttonSize( option->fontMetrics.height() + 2*frameWidth );
QRect r = rect;
if( showButtons ) {
auto w = r.width();
r.setLeft(r.height());
r.setRight(w-r.height());
r.setLeft(buttonSize);
r.setRight(w-buttonSize);
}
// remove right side line editor margins
const int frameWidth( pixelMetric( PM_SpinBoxFrameWidth, option, widget ) );
if( !flat && r.height() >= option->fontMetrics.height() + 2*frameWidth )
{ r.adjust( frameWidth, frameWidth, -frameWidth, -frameWidth ); }
@ -2695,7 +2699,8 @@ namespace Breeze
// add in the buttons, which are square w/ length of height, and we have two of them
const bool showButtons = spinBoxOption->buttonSymbols != QAbstractSpinBox::NoButtons;
if( showButtons ) size.rwidth() += size.height()*2;
const int buttonSize( option->fontMetrics.height() + 2*frameWidth );
if( showButtons ) size.rwidth() += buttonSize*2;
return size;

Loading…
Cancel
Save