Skip to content

Commit

Permalink
[qt4] more size tweak, more friendly for narrow scrollbars, #7. Cherr…
Browse files Browse the repository at this point in the history
…y picked from QtCurve/qtcurve
  • Loading branch information
yuyichao committed Oct 8, 2013
1 parent 8889ee3 commit bc45093
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions qt4/style/qtcurve.cpp
Expand Up @@ -755,6 +755,9 @@ inline int numButtons(EScrollbar type)
}

// TODO make this better.
// Port to Qt5 and gtk2
// Check if this breaks anything
// document
static inline int
sizeNumButtons(EScrollbar type)
{
Expand Down Expand Up @@ -3366,7 +3369,11 @@ int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWi
case PM_ToolBarHandleExtent:
return LINE_1DOT==opts.handles ? 7 : 8;
case PM_ScrollBarSliderMin:
return opts.sliderWidth+1;
// TODO make this better.
// Check if this breaks anything
// Port to Qt5 and gtk2
// document
return qMax(opts.sliderWidth, 20) + 1;
case PM_SliderThickness:
return (SLIDER_CIRCULAR==opts.sliderStyle
? CIRCULAR_SLIDER_SIZE+6
Expand Down Expand Up @@ -9701,11 +9708,19 @@ QSize Style::sizeFromContents(ContentsType type, const QStyleOption *option, con
{
int scrollBarExtent(pixelMetric(PM_ScrollBarExtent, option, widget)),
scrollBarSliderMinimum(pixelMetric(PM_ScrollBarSliderMin, option, widget));

if (scrollBar->orientation == Qt::Horizontal)
newSize = QSize(scrollBarExtent * sizeNumButtons(opts.scrollbarType) + scrollBarSliderMinimum, scrollBarExtent);
else
newSize = QSize(scrollBarExtent, scrollBarExtent * sizeNumButtons(opts.scrollbarType) + scrollBarSliderMinimum);
// TODO: document this
// Check if this breaks anything
// Port to qt5 and gtk2
int scrollBarLen =
(qMax(scrollBarExtent, 13) *
sizeNumButtons(opts.scrollbarType) +
scrollBarSliderMinimum);

if (scrollBar->orientation == Qt::Horizontal) {
newSize = QSize(scrollBarLen, scrollBarExtent);
} else {
newSize = QSize(scrollBarExtent, scrollBarLen);
}
}
break;
case CT_LineEdit:
Expand Down

0 comments on commit bc45093

Please sign in to comment.