diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2023-11-01 10:24:48 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2023-11-04 19:01:18 +0100 |
commit | fea9109b3b80756be2a03b0c1e429c7598bae420 (patch) | |
tree | ba33498c69e6cc2cee726ea6a7d8e33b9a5cc4d4 /src/widgets/styles/qwindowsstyle.cpp | |
parent | acdef6669f8e179ac14ff1be1d974e1230879c51 (diff) |
QWindowStyle: misc cleanup
Misc cleanup in QWindowsStyle:
- use range-base for loop
- use std::array instead raw c-array
- use std::swap instead custom implementation
Change-Id: I479c014d4e19556e1c0a6ce3fbb8ddacd4e179ae
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/widgets/styles/qwindowsstyle.cpp')
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index fd1f8e1c17..8f3d9d6d9a 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -117,19 +117,20 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) widget = widget->window(); // Alt has been pressed - find all widgets that care - QList<QWidget *> l = widget->findChildren<QWidget *>(); + const QList<QWidget *> children = widget->findChildren<QWidget *>(); auto ignorable = [](QWidget *w) { return w->isWindow() || !w->isVisible() || w->style()->styleHint(SH_UnderlineShortcut, nullptr, w); }; - l.removeIf(ignorable); // Update states before repainting d->seenAlt.append(widget); d->alt_down = true; // Repaint all relevant widgets - for (int pos = 0; pos < l.size(); ++pos) - l.at(pos)->update(); + for (QWidget *w : children) { + if (!ignorable(w)) + w->update(); + } } break; case QEvent::KeyRelease: @@ -139,9 +140,9 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) // Update state and repaint the menu bars. d->alt_down = false; #if QT_CONFIG(menubar) - QList<QMenuBar *> l = widget->findChildren<QMenuBar *>(); - for (int i = 0; i < l.size(); ++i) - l.at(i)->update(); + const QList<QMenuBar *> menuBars = widget->findChildren<QMenuBar *>(); + for (QWidget *w : menuBars) + w->update(); #endif } break; @@ -808,7 +809,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } #endif // QT_CONFIG(itemviews) if (!(opt->state & State_Off)) { - QPointF points[6]; + std::array<QPointF, 6> points; qreal scaleh = opt->rect.width() / 12.0; qreal scalev = opt->rect.height() / 12.0; points[0] = { opt->rect.x() + qreal(3.5) * scaleh, opt->rect.y() + qreal(5.5) * scalev }; @@ -819,7 +820,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, points[5] = { points[4].x() - 4 * scaleh, points[4].y() + 4 * scalev }; p->setPen(QPen(opt->palette.text().color(), 0)); p->setBrush(opt->palette.text().color()); - p->drawPolygon(points, 6); + p->drawPolygon(points.data(), static_cast<int>(points.size())); } if (doRestore) p->restore(); @@ -1571,11 +1572,8 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai default: break; } - if (opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end - bool tmp = paintLeftBorder; - paintRightBorder=paintLeftBorder; - paintLeftBorder=tmp; - } + if (opt->direction == Qt::RightToLeft) //reverse layout changes the order of Beginning/end + std::swap(paintLeftBorder, paintRightBorder); break; case Qt::RightToolBarArea : switch (toolbar->positionOfLine){ |