Remove QStyleOptionProgressBar::orientation member
Address ### Qt 6 comment; the information is already stored in the state variable, using the QStyle::State_Horizontal bit. Change-Id: I61d143ba057776f9d622793a0592b5dd4726f25d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
62c0844109
commit
add8262f72
@ -1619,10 +1619,11 @@ void QAndroidStyle::AndroidProgressBarControl::drawControl(const QStyleOption *o
|
||||
if (m_progressDrawable->type() == QAndroidStyle::Layer) {
|
||||
const double fraction = double(qint64(pb->progress) - pb->minimum) / (qint64(pb->maximum) - pb->minimum);
|
||||
QAndroidStyle::AndroidDrawable *clipDrawable = static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->layer(m_progressId);
|
||||
const Qt::Orientation orientation = pb->state & QStyle::State_Horizontal ? Qt::Horizontal : Qt::Vertical;
|
||||
if (clipDrawable->type() == QAndroidStyle::Clip)
|
||||
static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, pb->orientation);
|
||||
static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, orientation);
|
||||
else
|
||||
static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, pb->orientation);
|
||||
static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, orientation);
|
||||
}
|
||||
m_progressDrawable->draw(p, option);
|
||||
}
|
||||
@ -1634,7 +1635,7 @@ QRect QAndroidStyle::AndroidProgressBarControl::subElementRect(QStyle::SubElemen
|
||||
{
|
||||
if (const QStyleOptionProgressBar *progressBarOption =
|
||||
qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
const bool horizontal = progressBarOption->orientation == Qt::Vertical;
|
||||
const bool horizontal = progressBarOption->state & QStyle::State_Horizontal;
|
||||
if (!m_background)
|
||||
return option->rect;
|
||||
|
||||
@ -1676,12 +1677,12 @@ QSize QAndroidStyle::AndroidProgressBarControl::sizeFromContents(const QStyleOpt
|
||||
|
||||
if (const QStyleOptionProgressBar *progressBarOption =
|
||||
qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
||||
if (progressBarOption->orientation == Qt::Vertical) {
|
||||
if (sz.height() > m_maxSize.height())
|
||||
sz.setHeight(m_maxSize.height());
|
||||
} else {
|
||||
if (progressBarOption->state & QStyle::State_Horizontal) {
|
||||
if (sz.width() > m_maxSize.width())
|
||||
sz.setWidth(m_maxSize.width());
|
||||
} else {
|
||||
if (sz.height() > m_maxSize.height())
|
||||
sz.setHeight(m_maxSize.height());
|
||||
}
|
||||
}
|
||||
return contentsSize;
|
||||
|
@ -4382,7 +4382,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
||||
case CE_ProgressBarContents:
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
||||
const bool isIndeterminate = (pb->minimum == 0 && pb->maximum == 0);
|
||||
const bool vertical = pb->orientation == Qt::Vertical;
|
||||
const bool vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
const bool inverted = pb->invertedAppearance;
|
||||
bool reverse = (!vertical && (pb->direction == Qt::RightToLeft));
|
||||
if (inverted)
|
||||
|
@ -1006,7 +1006,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
||||
if (const QStyleOptionProgressBar *bar
|
||||
= qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
bool isIndeterminate = (bar->minimum == 0 && bar->maximum == 0);
|
||||
const bool vertical = bar->orientation == Qt::Vertical;
|
||||
const bool vertical = !(bar->state & QStyle::State_Horizontal);
|
||||
const bool inverted = bar->invertedAppearance;
|
||||
|
||||
if (isIndeterminate || (bar->progress > 0 && (bar->progress < bar->maximum) && d->transitionsEnabled())) {
|
||||
|
@ -383,6 +383,13 @@ bool QWindowsXPStylePrivate::isLineEditBaseColorSet(const QStyleOption *option,
|
||||
return (resolveMask & (1 << QPalette::Base)) != 0;
|
||||
}
|
||||
|
||||
static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = nullptr)
|
||||
{
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
|
||||
return pb->state & QStyle::State_Horizontal ? Qt::Horizontal : Qt::Vertical;
|
||||
return Qt::Horizontal;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
This function will always return a valid window handle, and might
|
||||
create a limbo widget to do so.
|
||||
@ -1739,10 +1746,10 @@ case PE_Frame:
|
||||
Qt::Orientation orient = Qt::Horizontal;
|
||||
bool inverted = false;
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
orient = pb->orientation;
|
||||
orient = pb->state & QStyle::State_Horizontal ? Qt::Horizontal : Qt::Vertical;
|
||||
inverted = pb->invertedAppearance;
|
||||
}
|
||||
if (orient == Qt::Horizontal) {
|
||||
if (orient & Qt::Horizontal) {
|
||||
partId = PP_CHUNK;
|
||||
rect = QRect(option->rect.x(), option->rect.y(), option->rect.width(), option->rect.height() );
|
||||
if (inverted && option->direction == Qt::LeftToRight)
|
||||
@ -2117,9 +2124,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
||||
|
||||
case CE_ProgressBarGroove:
|
||||
{
|
||||
Qt::Orientation orient = Qt::Horizontal;
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
|
||||
orient = pb->orientation;
|
||||
Qt::Orientation orient = progressBarOrientation(option);
|
||||
partId = (orient == Qt::Horizontal) ? PP_BAR : PP_BARVERT;
|
||||
themeNumber = QWindowsXPStylePrivate::ProgressTheme;
|
||||
stateId = 1;
|
||||
@ -3155,13 +3160,6 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
|
||||
}
|
||||
}
|
||||
|
||||
static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = nullptr)
|
||||
{
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
|
||||
return pb->orientation;
|
||||
return Qt::Horizontal;
|
||||
}
|
||||
|
||||
int QWindowsXPStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option, const QWidget *widget)
|
||||
{
|
||||
switch (pm) {
|
||||
|
@ -307,7 +307,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
||||
{
|
||||
bool vertical = false;
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt))
|
||||
vertical = pb->orientation == Qt::Vertical;
|
||||
vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
if (!vertical) {
|
||||
p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6,
|
||||
opt->palette.brush(QPalette::Highlight));
|
||||
@ -1526,7 +1526,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
||||
break;
|
||||
case CE_ProgressBarLabel:
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
||||
const bool vertical = pb->orientation == Qt::Vertical;
|
||||
const bool vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
if (!vertical) {
|
||||
QPalette::ColorRole textRole = QPalette::NoRole;
|
||||
if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible
|
||||
@ -1551,7 +1551,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
||||
|
||||
QRect rect = pb->rect;
|
||||
const bool vertical = pb->orientation == Qt::Vertical;
|
||||
const bool vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
const bool inverted = pb->invertedAppearance;
|
||||
qint64 minimum = qint64(pb->minimum);
|
||||
qint64 maximum = qint64(pb->maximum);
|
||||
@ -2591,7 +2591,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
|
||||
case SE_ProgressBarLabel:
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
||||
int textw = 0;
|
||||
const bool vertical = pb->orientation == Qt::Vertical;
|
||||
const bool vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
if (!vertical) {
|
||||
if (pb->textVisible)
|
||||
textw = qMax(pb->fontMetrics.horizontalAdvance(pb->text), pb->fontMetrics.horizontalAdvance(QLatin1String("100%"))) + 6;
|
||||
|
@ -1364,8 +1364,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
|
||||
bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
|
||||
bool complete = bar->progress == bar->maximum;
|
||||
|
||||
// Get extra style options if version 2
|
||||
vertical = (bar->orientation == Qt::Vertical);
|
||||
vertical = !(bar->state & QStyle::State_Horizontal);
|
||||
inverted = bar->invertedAppearance;
|
||||
|
||||
// If the orientation is vertical, we use a transform to rotate
|
||||
@ -1474,7 +1473,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
|
||||
|
||||
painter->save();
|
||||
bool vertical = false, inverted = false;
|
||||
vertical = (bar->orientation == Qt::Vertical);
|
||||
vertical = !(bar->state & QStyle::State_Horizontal);
|
||||
inverted = bar->invertedAppearance;
|
||||
if (vertical)
|
||||
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
|
||||
|
@ -825,7 +825,7 @@ void QPixmapStyle::drawProgressBarBackground(const QStyleOption *option,
|
||||
bool vertical = false;
|
||||
if (const QStyleOptionProgressBar *pb =
|
||||
qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
vertical = pb->orientation == Qt::Vertical;
|
||||
vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
}
|
||||
drawCachedPixmap(vertical ? PB_VBackground : PB_HBackground, option->rect, painter);
|
||||
}
|
||||
@ -835,7 +835,7 @@ void QPixmapStyle::drawProgressBarLabel(const QStyleOption *option,
|
||||
{
|
||||
if (const QStyleOptionProgressBar *pb =
|
||||
qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
const bool vertical = pb->orientation == Qt::Vertical;
|
||||
const bool vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
if (!vertical) {
|
||||
QPalette::ColorRole textRole = QPalette::ButtonText;
|
||||
proxy()->drawItemText(painter, pb->rect,
|
||||
@ -850,7 +850,7 @@ void QPixmapStyle::drawProgressBarFill(const QStyleOption *option,
|
||||
{
|
||||
const QStyleOptionProgressBar *pbar =
|
||||
qstyleoption_cast<const QStyleOptionProgressBar*>(option);
|
||||
const bool vertical = pbar->orientation == Qt::Vertical;
|
||||
const bool vertical = !(pbar->state & QStyle::State_Horizontal);
|
||||
const bool flip = (pbar->direction == Qt::RightToLeft) ^ pbar->invertedAppearance;
|
||||
|
||||
if (pbar->progress == pbar->maximum) {
|
||||
@ -1026,7 +1026,7 @@ QSize QPixmapStyle::progressBarSizeFromContents(const QStyleOption *option,
|
||||
bool vertical = false;
|
||||
if (const QStyleOptionProgressBar *pb =
|
||||
qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
vertical = pb->orientation == Qt::Vertical;
|
||||
vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
}
|
||||
QSize result = QCommonStyle::sizeFromContents(CT_Slider, option, contentsSize, widget);
|
||||
if (vertical) {
|
||||
|
@ -1496,7 +1496,7 @@ QStyleOptionTab::QStyleOptionTab(int version)
|
||||
QStyleOptionProgressBar::QStyleOptionProgressBar()
|
||||
: QStyleOption(QStyleOptionProgressBar::Version, SO_ProgressBar),
|
||||
minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false),
|
||||
orientation(Qt::Horizontal), invertedAppearance(false), bottomToTop(false)
|
||||
invertedAppearance(false), bottomToTop(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1506,7 +1506,7 @@ QStyleOptionProgressBar::QStyleOptionProgressBar()
|
||||
QStyleOptionProgressBar::QStyleOptionProgressBar(int version)
|
||||
: QStyleOption(version, SO_ProgressBar),
|
||||
minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false),
|
||||
orientation(Qt::Horizontal), invertedAppearance(false), bottomToTop(false)
|
||||
invertedAppearance(false), bottomToTop(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1608,17 +1608,6 @@ QStyleOptionProgressBar::QStyleOptionProgressBar(int version)
|
||||
\sa QProgressBar::value
|
||||
*/
|
||||
|
||||
/*!
|
||||
\variable QStyleOptionProgressBar::orientation
|
||||
\brief the progress bar's orientation (horizontal or vertical);
|
||||
the default orentation is Qt::Horizontal
|
||||
|
||||
\deprecated
|
||||
Use the QStyle::State_Horizontal flag instead (in the QStyleOption::state member).
|
||||
|
||||
\sa QProgressBar::orientation
|
||||
*/
|
||||
|
||||
/*!
|
||||
\variable QStyleOptionProgressBar::invertedAppearance
|
||||
\brief whether the progress bar's appearance is inverted
|
||||
|
@ -336,7 +336,6 @@ public:
|
||||
QString text;
|
||||
Qt::Alignment textAlignment;
|
||||
bool textVisible;
|
||||
Qt::Orientation orientation; // ### Qt 6: remove
|
||||
bool invertedAppearance;
|
||||
bool bottomToTop;
|
||||
|
||||
|
@ -3993,7 +3993,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
||||
qint64 minimum = qint64(pb->minimum);
|
||||
qint64 maximum = qint64(pb->maximum);
|
||||
qint64 progress = qint64(pb->progress);
|
||||
bool vertical = (pb->orientation == Qt::Vertical);
|
||||
bool vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
bool inverted = pb->invertedAppearance;
|
||||
|
||||
QTransform m;
|
||||
|
@ -1025,7 +1025,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
||||
{
|
||||
bool vertical = false, inverted = false;
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
||||
vertical = pb->orientation == Qt::Vertical;
|
||||
vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
inverted = pb->invertedAppearance;
|
||||
}
|
||||
|
||||
@ -1691,7 +1691,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
||||
if (!rect.isValid())
|
||||
return;
|
||||
|
||||
const bool vertical = pb->orientation == Qt::Vertical;
|
||||
const bool vertical = !(pb->state & QStyle::State_Horizontal);
|
||||
const bool inverted = pb->invertedAppearance;
|
||||
|
||||
QTransform m;
|
||||
|
@ -135,7 +135,6 @@ void QProgressBar::initStyleOption(QStyleOptionProgressBar *option) const
|
||||
option->textAlignment = d->alignment;
|
||||
option->textVisible = d->textVisible;
|
||||
option->text = text();
|
||||
option->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBar
|
||||
option->invertedAppearance = d->invertedAppearance;
|
||||
option->bottomToTop = d->textDirection == QProgressBar::BottomToTop;
|
||||
}
|
||||
@ -424,7 +423,7 @@ QSize QProgressBar::sizeHint() const
|
||||
initStyleOption(&opt);
|
||||
int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);
|
||||
QSize size = QSize(qMax(9, cw) * 7 + fm.horizontalAdvance(QLatin1Char('0')) * 4, fm.height() + 8);
|
||||
if (opt.orientation == Qt::Vertical)
|
||||
if (!(opt.state & QStyle::State_Horizontal))
|
||||
size = size.transposed();
|
||||
return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user