From cbee4d6ff281f565101aa24c0e80eb5305d00417 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Tue, 20 Dec 2022 10:04:51 +0800 Subject: [PATCH] QStyleHints: code tidies 1. Use Q_D and Q_Q instead of d_func() and q_func(). 2. Use early return. 3. Remove unnecessary semicon. 4. Add one new line to separate two unrelated functions. Change-Id: Ie6171c857f00ca171e97723a0d517d2295bbbbd1 Reviewed-by: Axel Spoerl Reviewed-by: Paul Wicking (cherry picked from commit 528f28f380e3f0c55b9a305f6b208dc1a2db73d6) --- src/gui/kernel/qstylehints.cpp | 12 +++++++----- src/gui/kernel/qstylehints_p.h | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index ea30741dbe3..d688d0ae3aa 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -129,7 +129,8 @@ int QStyleHints::touchDoubleTapDistance() const */ Qt::Appearance QStyleHints::appearance() const { - return d_func()->appearance(); + Q_D(const QStyleHints); + return d->appearance(); } Qt::ColorScheme QStyleHints::colorScheme() const @@ -602,10 +603,11 @@ int QStyleHints::mouseQuickSelectionThreshold() const */ void QStyleHintsPrivate::setAppearance(Qt::Appearance appearance) { - if (m_appearance != appearance) { - m_appearance = appearance; - emit q_func()->appearanceChanged(appearance); - } + if (m_appearance == appearance) + return; + m_appearance = appearance; + Q_Q(QStyleHints); + emit q->appearanceChanged(appearance); } QStyleHintsPrivate *QStyleHintsPrivate::get(QStyleHints *q) diff --git a/src/gui/kernel/qstylehints_p.h b/src/gui/kernel/qstylehints_p.h index 4a16fbef014..a93a410987a 100644 --- a/src/gui/kernel/qstylehints_p.h +++ b/src/gui/kernel/qstylehints_p.h @@ -40,8 +40,9 @@ public: int m_mouseDoubleClickDistance = -1; int m_touchDoubleTapDistance = -1; - Qt::Appearance appearance() const { return m_appearance; }; + Qt::Appearance appearance() const { return m_appearance; } void setAppearance(Qt::Appearance appearance); + static QStyleHintsPrivate *get(QStyleHints *q); private: