diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-09-12 09:43:21 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-09-16 10:48:07 +0200 |
commit | 72522517688d68a25a543a1da2497a4b8f6b424b (patch) | |
tree | b6afb634dfdd002f0d86fa76680c954a538ffc46 /src/widgets/styles | |
parent | e2431b619da5c53d34df0b46105deb4450ed0c1f (diff) |
Brush up the Windows styles
- use range-based for loops where possible
- use nullptr
- use member initialization
- remove a lot of C-style casts
- use override
- fix some signedness warnings
- add some missing break statements
Task-number: QTBUG-76493
Change-Id: Ica6ed65ec29e958406e54d816b8a679ed81bd177
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 28 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle_p_p.h | 4 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 72c803cb99..7d4e1fe9e7 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -120,10 +120,7 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; \internal */ -QWindowsStylePrivate::QWindowsStylePrivate() - : alt_down(false), menuBarTimer(0) -{ -} +QWindowsStylePrivate::QWindowsStylePrivate() = default; qreal QWindowsStylePrivate::appDevicePixelRatio() { @@ -157,7 +154,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) QList<QWidget *> l = widget->findChildren<QWidget *>(); auto ignorable = [](QWidget *w) { return w->isWindow() || !w->isVisible() - || w->style()->styleHint(SH_UnderlineShortcut, 0, w); + || w->style()->styleHint(SH_UnderlineShortcut, nullptr, w); }; l.erase(std::remove_if(l.begin(), l.end(), ignorable), l.end()); // Update states before repainting @@ -242,7 +239,7 @@ void QWindowsStyle::polish(QApplication *app) QCommonStyle::polish(app); QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func()); // We only need the overhead when shortcuts are sometimes hidden - if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app) + if (!proxy()->styleHint(SH_UnderlineShortcut, nullptr) && app) app->installEventFilter(this); const auto &palette = QGuiApplication::palette(); @@ -343,7 +340,6 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm) case QStyle::PM_MenuVMargin: case QStyle::PM_ToolBarItemMargin: return 1; - break; case QStyle::PM_DockWidgetSeparatorExtent: return 4; #if QT_CONFIG(tabbar) @@ -698,17 +694,17 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, x -= 2; if (opt->rect.height() > 4) { qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } else { if (opt->rect.width() > 4) { int y = opt->rect.height() / 2 - 4; qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } p->restore(); @@ -759,7 +755,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } } else { qDrawWinButton(p, opt->rect, opt->palette, - opt->state & (State_Sunken | State_On), panel ? &fill : 0); + opt->state & (State_Sunken | State_On), panel ? &fill : nullptr); } } else { p->fillRect(opt->rect, fill); @@ -980,7 +976,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, if (opt->state & (State_Raised | State_On | State_Sunken)) { qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On), - panel ? &fill : 0); + panel ? &fill : nullptr); } else { if (panel) p->fillRect(opt->rect, fill); @@ -1005,7 +1001,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, #endif // QT_CONFIG(dockwidget) case PE_FrameStatusBarItem: - qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0); + qDrawShadePanel(p, opt->rect, opt->palette, true, 1, nullptr); break; case PE_IndicatorProgressChunk: @@ -1043,7 +1039,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, break; case PE_FrameTabWidget: { - qDrawWinButton(p, opt->rect, opt->palette, false, 0); + qDrawWinButton(p, opt->rect, opt->palette, false, nullptr); break; } default: @@ -1585,6 +1581,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai case QStyleOptionToolBar::Beginning: case QStyleOptionToolBar::OnlyOne: paintBottomBorder = false; + break; default: break; } @@ -1600,6 +1597,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai case QStyleOptionToolBar::OnlyOne: paintRightBorder = false; paintLeftBorder = false; + break; default: break; } diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index e6ea809f11..4f6ffcefc2 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -77,9 +77,9 @@ public: bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } - bool alt_down; + bool alt_down = false; QList<const QWidget *> seenAlt; - int menuBarTimer; + int menuBarTimer = 0; QColor inactiveCaptionText; QColor activeCaptionColor; |