From 48968691233eaa40bb84ed19efc28761b4b9fcf0 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 18 Jan 2023 10:00:18 +0800 Subject: [PATCH] use better name Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- include/FramelessHelper/Core/utils.h | 2 +- .../private/quickstandardsystembutton_p.h | 10 +++---- .../Widgets/private/standardsystembutton_p.h | 6 ++--- .../Widgets/standardsystembutton.h | 8 +++--- src/core/utils.cpp | 2 +- src/quick/quickstandardsystembutton.cpp | 16 ++++++------ src/widgets/standardsystembutton.cpp | 26 +++++++++---------- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/include/FramelessHelper/Core/utils.h b/include/FramelessHelper/Core/utils.h index 2afe93c..33bdf2d 100644 --- a/include/FramelessHelper/Core/utils.h +++ b/include/FramelessHelper/Core/utils.h @@ -49,7 +49,7 @@ namespace Utils Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos); FRAMELESSHELPER_CORE_API void startSystemMove(QWindow *window, const QPoint &globalPos); FRAMELESSHELPER_CORE_API void startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos); -[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemButtonIconCode(const Global::SystemButtonType button); +[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemButtonGlyph(const Global::SystemButtonType button); [[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId); FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter( const Global::GetWindowScreenCallback &getWindowScreen, diff --git a/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h b/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h index 8f2ca9b..7418d90 100644 --- a/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h +++ b/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h @@ -45,7 +45,7 @@ class FRAMELESSHELPER_QUICK_API QuickStandardSystemButton : public QQuickButton #endif Q_DISABLE_COPY_MOVE(QuickStandardSystemButton) Q_PROPERTY(QuickGlobal::SystemButtonType buttonType READ buttonType WRITE setButtonType NOTIFY buttonTypeChanged FINAL) - Q_PROPERTY(QString code READ code WRITE setCode NOTIFY codeChanged FINAL) + Q_PROPERTY(QString glyph READ glyph WRITE setGlyph NOTIFY glyphChanged FINAL) Q_PROPERTY(QColor hoverColor READ hoverColor WRITE setHoverColor NOTIFY hoverColorChanged FINAL) Q_PROPERTY(QColor pressColor READ pressColor WRITE setPressColor NOTIFY pressColorChanged FINAL) Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor NOTIFY normalColorChanged FINAL) @@ -59,7 +59,7 @@ public: ~QuickStandardSystemButton() override; Q_NODISCARD QuickGlobal::SystemButtonType buttonType() const; - Q_NODISCARD QString code() const; + Q_NODISCARD QString glyph() const; Q_NODISCARD QColor normalColor() const; Q_NODISCARD QColor hoverColor() const; Q_NODISCARD QColor pressColor() const; @@ -70,7 +70,7 @@ public: public Q_SLOTS: void updateColor(); void setButtonType(const QuickGlobal::SystemButtonType type); - void setCode(const QString &value); + void setGlyph(const QString &value); void setNormalColor(const QColor &value); void setHoverColor(const QColor &value); void setPressColor(const QColor &value); @@ -87,7 +87,7 @@ private: Q_SIGNALS: void buttonTypeChanged(); - void codeChanged(); + void glyphChanged(); void normalColorChanged(); void hoverColorChanged(); void pressColorChanged(); @@ -99,7 +99,7 @@ private: QQuickText *m_contentItem = nullptr; QQuickRectangle *m_backgroundItem = nullptr; QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown; - QString m_code = {}; + QString m_glyph = {}; QColor m_normalColor = {}; QColor m_hoverColor = {}; QColor m_pressColor = {}; diff --git a/include/FramelessHelper/Widgets/private/standardsystembutton_p.h b/include/FramelessHelper/Widgets/private/standardsystembutton_p.h index 5868ec3..c1d09c7 100644 --- a/include/FramelessHelper/Widgets/private/standardsystembutton_p.h +++ b/include/FramelessHelper/Widgets/private/standardsystembutton_p.h @@ -48,8 +48,8 @@ public: Q_NODISCARD static StandardSystemButtonPrivate *get(StandardSystemButton *pub); Q_NODISCARD static const StandardSystemButtonPrivate *get(const StandardSystemButton *pub); - Q_NODISCARD QString getCode() const; - void setCode(const QString &value); + Q_NODISCARD QString getGlyph() const; + void setGlyph(const QString &value); Q_NODISCARD Global::SystemButtonType getButtonType() const; void setButtonType(const Global::SystemButtonType type); @@ -86,7 +86,7 @@ private: private: StandardSystemButton *q_ptr = nullptr; Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown; - QString m_code = {}; + QString m_glyph = {}; QColor m_hoverColor = {}; QColor m_pressColor = {}; QColor m_normalColor = {}; diff --git a/include/FramelessHelper/Widgets/standardsystembutton.h b/include/FramelessHelper/Widgets/standardsystembutton.h index bacd796..8347885 100644 --- a/include/FramelessHelper/Widgets/standardsystembutton.h +++ b/include/FramelessHelper/Widgets/standardsystembutton.h @@ -39,7 +39,7 @@ class FRAMELESSHELPER_WIDGETS_API StandardSystemButton : public QAbstractButton Q_DECLARE_PRIVATE(StandardSystemButton) Q_DISABLE_COPY_MOVE(StandardSystemButton) Q_PROPERTY(Global::SystemButtonType buttonType READ buttonType WRITE setButtonType NOTIFY buttonTypeChanged FINAL) - Q_PROPERTY(QString code READ code WRITE setCode NOTIFY codeChanged FINAL) + Q_PROPERTY(QString glyph READ glyph WRITE setGlyph NOTIFY glyphChanged FINAL) Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL) Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) Q_PROPERTY(QColor hoverColor READ hoverColor WRITE setHoverColor NOTIFY hoverColorChanged FINAL) @@ -57,7 +57,7 @@ public: Q_NODISCARD QSize sizeHint() const override; Q_NODISCARD Global::SystemButtonType buttonType(); - Q_NODISCARD QString code() const; + Q_NODISCARD QString glyph() const; Q_NODISCARD bool isHovered() const; Q_NODISCARD bool isPressed() const; Q_NODISCARD QColor hoverColor() const; @@ -70,7 +70,7 @@ public: public Q_SLOTS: void setButtonType(const Global::SystemButtonType value); - void setCode(const QString &code); + void setGlyph(const QString &glyph); void setHovered(const bool value); void setPressed(const bool value); void setHoverColor(const QColor &value); @@ -88,7 +88,7 @@ protected: Q_SIGNALS: void buttonTypeChanged(); - void codeChanged(); + void glyphChanged(); void hoveredChanged(); void pressedChanged(); void hoverColorChanged(); diff --git a/src/core/utils.cpp b/src/core/utils.cpp index 8bc99a8..ea81ea7 100644 --- a/src/core/utils.cpp +++ b/src/core/utils.cpp @@ -145,7 +145,7 @@ Qt::Edges Utils::calculateWindowEdges(const QWindow *window, const QPoint &pos) #endif } -QString Utils::getSystemButtonIconCode(const SystemButtonType button) +QString Utils::getSystemButtonGlyph(const SystemButtonType button) { #ifdef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE return {}; diff --git a/src/quick/quickstandardsystembutton.cpp b/src/quick/quickstandardsystembutton.cpp index 235c666..de7cef7 100644 --- a/src/quick/quickstandardsystembutton.cpp +++ b/src/quick/quickstandardsystembutton.cpp @@ -70,9 +70,9 @@ QuickGlobal::SystemButtonType QuickStandardSystemButton::buttonType() const return m_buttonType; } -QString QuickStandardSystemButton::code() const +QString QuickStandardSystemButton::glyph() const { - return m_code; + return m_glyph; } QColor QuickStandardSystemButton::normalColor() const @@ -127,23 +127,23 @@ void QuickStandardSystemButton::setButtonType(const QuickGlobal::SystemButtonTyp return; } m_buttonType = type; - setCode(Utils::getSystemButtonIconCode( + setGlyph(Utils::getSystemButtonGlyph( FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, m_buttonType))); Q_EMIT buttonTypeChanged(); } -void QuickStandardSystemButton::setCode(const QString &value) +void QuickStandardSystemButton::setGlyph(const QString &value) { Q_ASSERT(!value.isEmpty()); if (value.isEmpty()) { return; } - if (m_code == value) { + if (m_glyph == value) { return; } - m_code = value; - m_contentItem->setText(m_code); - Q_EMIT codeChanged(); + m_glyph = value; + m_contentItem->setText(m_glyph); + Q_EMIT glyphChanged(); } void QuickStandardSystemButton::setNormalColor(const QColor &value) diff --git a/src/widgets/standardsystembutton.cpp b/src/widgets/standardsystembutton.cpp index 5537195..f0f9fbc 100644 --- a/src/widgets/standardsystembutton.cpp +++ b/src/widgets/standardsystembutton.cpp @@ -78,24 +78,24 @@ const StandardSystemButtonPrivate *StandardSystemButtonPrivate::get(const Standa return pub->d_func(); } -QString StandardSystemButtonPrivate::getCode() const +QString StandardSystemButtonPrivate::getGlyph() const { - return m_code; + return m_glyph; } -void StandardSystemButtonPrivate::setCode(const QString &value) +void StandardSystemButtonPrivate::setGlyph(const QString &value) { Q_ASSERT(!value.isEmpty()); if (value.isEmpty()) { return; } - if (m_code == value) { + if (m_glyph == value) { return; } - m_code = value; + m_glyph = value; Q_Q(StandardSystemButton); q->update(); - Q_EMIT q->codeChanged(); + Q_EMIT q->glyphChanged(); } SystemButtonType StandardSystemButtonPrivate::getButtonType() const @@ -113,7 +113,7 @@ void StandardSystemButtonPrivate::setButtonType(const SystemButtonType type) return; } m_buttonType = type; - setCode(Utils::getSystemButtonIconCode(m_buttonType)); + setGlyph(Utils::getSystemButtonGlyph(m_buttonType)); Q_Q(StandardSystemButton); q->update(); } @@ -364,7 +364,7 @@ void StandardSystemButtonPrivate::paintEventHandler(QPaintEvent *event) if (backgroundColor.isValid()) { painter.fillRect(buttonRect, backgroundColor); } - if (!m_code.isEmpty()) { + if (!m_glyph.isEmpty()) { painter.setPen([this]() -> QColor { if (!m_hovered && !m_active && m_inactiveForegroundColor.isValid()) { return m_inactiveForegroundColor; @@ -381,7 +381,7 @@ void StandardSystemButtonPrivate::paintEventHandler(QPaintEvent *event) } return font; }()); - painter.drawText(buttonRect, Qt::AlignCenter, m_code); + painter.drawText(buttonRect, Qt::AlignCenter, m_glyph); } painter.restore(); event->accept(); @@ -423,10 +423,10 @@ SystemButtonType StandardSystemButton::buttonType() return d->getButtonType(); } -QString StandardSystemButton::code() const +QString StandardSystemButton::glyph() const { Q_D(const StandardSystemButton); - return d->getCode(); + return d->getGlyph(); } void StandardSystemButton::setButtonType(const SystemButtonType value) @@ -435,10 +435,10 @@ void StandardSystemButton::setButtonType(const SystemButtonType value) d->setButtonType(value); } -void StandardSystemButton::setCode(const QString &code) +void StandardSystemButton::setGlyph(const QString &glyph) { Q_D(StandardSystemButton); - d->setCode(code); + d->setGlyph(glyph); } bool StandardSystemButton::isHovered() const