Fix regression in QAbstractScrollArea
The style hint SH_ScrollView_FrameOnlyAroundContents was currently
being ignored by QAbstractScrollArea. This looks like an accidental
regression following 10c6f015f4.
This code path does not execute on mac so it should have no impact
on that patch.
Change-Id: I78ca0a6b87dfdd7d426acbb3ef49480390211af2
Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
bb10
parent
e92313bf7e
commit
fe966e5f48
|
|
@ -407,7 +407,7 @@ void QAbstractScrollAreaPrivate::layoutChildren()
|
|||
if ((frameStyle != QFrame::NoFrame) &&
|
||||
q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
|
||||
controlsRect = widgetRect;
|
||||
const int extra = scrollOverlap;
|
||||
const int extra = scrollOverlap + q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q);
|
||||
const QPoint cornerExtra(needv ? extra : 0, needh ? extra : 0);
|
||||
QRect frameRect = widgetRect;
|
||||
frameRect.adjust(0, 0, -cornerOffset.x() - cornerExtra.x(), -cornerOffset.y() - cornerExtra.y());
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@
|
|||
#include <qradiobutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qmdiarea.h>
|
||||
#include <qscrollarea.h>
|
||||
|
||||
#include <QCleanlooksStyle>
|
||||
|
||||
|
|
@ -148,6 +149,7 @@ private slots:
|
|||
#endif
|
||||
void defaultFont();
|
||||
void testDrawingShortcuts();
|
||||
void testFrameOnlyAroundContents();
|
||||
private:
|
||||
void lineUpLayoutTest(QStyle *);
|
||||
QWidget *testWidget;
|
||||
|
|
@ -763,6 +765,7 @@ public:
|
|||
int alignment;
|
||||
};
|
||||
|
||||
|
||||
void tst_QStyle::testDrawingShortcuts()
|
||||
{
|
||||
{
|
||||
|
|
@ -796,5 +799,41 @@ void tst_QStyle::testDrawingShortcuts()
|
|||
}
|
||||
}
|
||||
|
||||
#define SCROLLBAR_SPACING 33
|
||||
|
||||
class FrameTestStyle : public QWindowsStyle {
|
||||
int styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const {
|
||||
if (hint == QStyle::SH_ScrollView_FrameOnlyAroundContents)
|
||||
return 1;
|
||||
return QWindowsStyle ::styleHint(hint, opt, widget, returnData);
|
||||
}
|
||||
|
||||
int pixelMetric(PixelMetric pm, const QStyleOption *option, const QWidget *widget) const {
|
||||
if (pm == QStyle::PM_ScrollView_ScrollBarSpacing)
|
||||
return SCROLLBAR_SPACING;
|
||||
return QWindowsStyle ::pixelMetric(pm, option ,widget);
|
||||
}
|
||||
};
|
||||
|
||||
void tst_QStyle::testFrameOnlyAroundContents()
|
||||
{
|
||||
QScrollArea area;
|
||||
area.setGeometry(0, 0, 200, 200);
|
||||
QWindowsStyle winStyle;
|
||||
FrameTestStyle frameStyle;
|
||||
QWidget *widget = new QWidget(&area);
|
||||
widget->setGeometry(0, 0, 400, 400);
|
||||
area.setStyle(&winStyle);
|
||||
area.verticalScrollBar()->setStyle(&winStyle);
|
||||
area.setWidget(widget);
|
||||
area.setVisible(true);
|
||||
int viewPortWidth = area.viewport()->width();
|
||||
area.verticalScrollBar()->setStyle(&frameStyle);
|
||||
area.setStyle(&frameStyle);
|
||||
// Test that we reserve space for scrollbar spacing
|
||||
QVERIFY(viewPortWidth == area.viewport()->width() + SCROLLBAR_SPACING);
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(tst_QStyle)
|
||||
#include "tst_qstyle.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue