Skip to content

Commit 85670f8

Browse files
committed
QProgressBar: keep using deprecated QProgressBarOption::orientation option for Qt 5.15
It doesn't seem to be reliable to use only QStyle::state to properly get information whether QProgressBar should be horizontal or vertical
1 parent 8860bcb commit 85670f8

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/style/adwaitastyle.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,11 @@ QRect Style::progressBarGrooveRect(const QStyleOption *option, const QWidget *wi
17541754
bool busy(progressBarOption->minimum == 0 && progressBarOption->maximum == 0);
17551755

17561756
const State &state(option->state);
1757-
bool horizontal(!progressBarOption || state & QStyle::State_Horizontal);
1757+
#if QT_VERSION >= 0x060000
1758+
bool horizontal(state & QStyle::State_Horizontal);
1759+
#else
1760+
bool horizontal((state & QStyle::State_Horizontal) || (progressBarOption->orientation == Qt::Horizontal));
1761+
#endif
17581762

17591763
// copy rectangle and adjust
17601764
QRect rect(option->rect);
@@ -1800,7 +1804,11 @@ QRect Style::progressBarContentsRect(const QStyleOption *option, const QWidget *
18001804

18011805
// get orientation
18021806
const State &state(option->state);
1803-
bool horizontal(!progressBarOption || state & QStyle::State_Horizontal);
1807+
#if QT_VERSION >= 0x060000
1808+
bool horizontal(state & QStyle::State_Horizontal);
1809+
#else
1810+
bool horizontal((state & QStyle::State_Horizontal) || (progressBarOption->orientation == Qt::Horizontal));
1811+
#endif
18041812

18051813
// check inverted appearance
18061814
bool inverted(progressBarOption ? progressBarOption->invertedAppearance : false);
@@ -1844,7 +1852,11 @@ QRect Style::progressBarLabelRect(const QStyleOption *option, const QWidget *) c
18441852

18451853
// get orientation
18461854
const State &state(option->state);
1847-
bool horizontal(!progressBarOption || state & QStyle::State_Horizontal);
1855+
#if QT_VERSION >= 0x060000
1856+
bool horizontal(state & QStyle::State_Horizontal);
1857+
#else
1858+
bool horizontal((state & QStyle::State_Horizontal) || (progressBarOption->orientation == Qt::Horizontal));
1859+
#endif
18481860

18491861
if (!horizontal) {
18501862
return QRect();
@@ -3040,7 +3052,11 @@ QSize Style::progressBarSizeFromContents(const QStyleOption *option, const QSize
30403052
}
30413053

30423054
const State &state(option->state);
3043-
bool horizontal(!progressBarOption || state & QStyle::State_Horizontal);
3055+
#if QT_VERSION >= 0x060000
3056+
bool horizontal(state & QStyle::State_Horizontal);
3057+
#else
3058+
bool horizontal((state & QStyle::State_Horizontal) || (progressBarOption->orientation == Qt::Horizontal));
3059+
#endif
30443060

30453061
// make local copy
30463062
QSize size(contentsSize);
@@ -5243,7 +5259,11 @@ bool Style::drawProgressBarContentsControl(const QStyleOption *option, QPainter
52435259

52445260
// get direction
52455261
const State &state(option->state);
5246-
bool horizontal(!progressBarOption || state & QStyle::State_Horizontal);
5262+
#if QT_VERSION >= 0x060000
5263+
bool horizontal(state & QStyle::State_Horizontal);
5264+
#else
5265+
bool horizontal((state & QStyle::State_Horizontal) || (progressBarOption->orientation == Qt::Horizontal));
5266+
#endif
52475267
bool inverted(progressBarOption ? progressBarOption->invertedAppearance : false);
52485268
bool reverse = horizontal && option->direction == Qt::RightToLeft;
52495269
if (inverted)
@@ -5326,7 +5346,11 @@ bool Style::drawProgressBarLabelControl(const QStyleOption *option, QPainter *pa
53265346

53275347
// get direction and check
53285348
const State &state(option->state);
5329-
bool horizontal(!progressBarOption || state & QStyle::State_Horizontal);
5349+
#if QT_VERSION >= 0x060000
5350+
bool horizontal(state & QStyle::State_Horizontal);
5351+
#else
5352+
bool horizontal((state & QStyle::State_Horizontal) || (progressBarOption->orientation == Qt::Horizontal));
5353+
#endif
53305354

53315355
if (!horizontal) {
53325356
return true;

0 commit comments

Comments
 (0)