use better name

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2023-01-18 10:00:18 +08:00
parent 139d5a41df
commit 4896869123
7 changed files with 35 additions and 35 deletions

View File

@ -49,7 +49,7 @@ namespace Utils
Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos); Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos);
FRAMELESSHELPER_CORE_API void startSystemMove(QWindow *window, const QPoint &globalPos); FRAMELESSHELPER_CORE_API void startSystemMove(QWindow *window, const QPoint &globalPos);
FRAMELESSHELPER_CORE_API void startSystemResize(QWindow *window, const Qt::Edges edges, 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); [[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId);
FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter( FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
const Global::GetWindowScreenCallback &getWindowScreen, const Global::GetWindowScreenCallback &getWindowScreen,

View File

@ -45,7 +45,7 @@ class FRAMELESSHELPER_QUICK_API QuickStandardSystemButton : public QQuickButton
#endif #endif
Q_DISABLE_COPY_MOVE(QuickStandardSystemButton) Q_DISABLE_COPY_MOVE(QuickStandardSystemButton)
Q_PROPERTY(QuickGlobal::SystemButtonType buttonType READ buttonType WRITE setButtonType NOTIFY buttonTypeChanged FINAL) 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 hoverColor READ hoverColor WRITE setHoverColor NOTIFY hoverColorChanged FINAL)
Q_PROPERTY(QColor pressColor READ pressColor WRITE setPressColor NOTIFY pressColorChanged FINAL) Q_PROPERTY(QColor pressColor READ pressColor WRITE setPressColor NOTIFY pressColorChanged FINAL)
Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor NOTIFY normalColorChanged FINAL) Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor NOTIFY normalColorChanged FINAL)
@ -59,7 +59,7 @@ public:
~QuickStandardSystemButton() override; ~QuickStandardSystemButton() override;
Q_NODISCARD QuickGlobal::SystemButtonType buttonType() const; Q_NODISCARD QuickGlobal::SystemButtonType buttonType() const;
Q_NODISCARD QString code() const; Q_NODISCARD QString glyph() const;
Q_NODISCARD QColor normalColor() const; Q_NODISCARD QColor normalColor() const;
Q_NODISCARD QColor hoverColor() const; Q_NODISCARD QColor hoverColor() const;
Q_NODISCARD QColor pressColor() const; Q_NODISCARD QColor pressColor() const;
@ -70,7 +70,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void updateColor(); void updateColor();
void setButtonType(const QuickGlobal::SystemButtonType type); void setButtonType(const QuickGlobal::SystemButtonType type);
void setCode(const QString &value); void setGlyph(const QString &value);
void setNormalColor(const QColor &value); void setNormalColor(const QColor &value);
void setHoverColor(const QColor &value); void setHoverColor(const QColor &value);
void setPressColor(const QColor &value); void setPressColor(const QColor &value);
@ -87,7 +87,7 @@ private:
Q_SIGNALS: Q_SIGNALS:
void buttonTypeChanged(); void buttonTypeChanged();
void codeChanged(); void glyphChanged();
void normalColorChanged(); void normalColorChanged();
void hoverColorChanged(); void hoverColorChanged();
void pressColorChanged(); void pressColorChanged();
@ -99,7 +99,7 @@ private:
QQuickText *m_contentItem = nullptr; QQuickText *m_contentItem = nullptr;
QQuickRectangle *m_backgroundItem = nullptr; QQuickRectangle *m_backgroundItem = nullptr;
QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown; QuickGlobal::SystemButtonType m_buttonType = QuickGlobal::SystemButtonType::Unknown;
QString m_code = {}; QString m_glyph = {};
QColor m_normalColor = {}; QColor m_normalColor = {};
QColor m_hoverColor = {}; QColor m_hoverColor = {};
QColor m_pressColor = {}; QColor m_pressColor = {};

View File

@ -48,8 +48,8 @@ public:
Q_NODISCARD static StandardSystemButtonPrivate *get(StandardSystemButton *pub); Q_NODISCARD static StandardSystemButtonPrivate *get(StandardSystemButton *pub);
Q_NODISCARD static const StandardSystemButtonPrivate *get(const StandardSystemButton *pub); Q_NODISCARD static const StandardSystemButtonPrivate *get(const StandardSystemButton *pub);
Q_NODISCARD QString getCode() const; Q_NODISCARD QString getGlyph() const;
void setCode(const QString &value); void setGlyph(const QString &value);
Q_NODISCARD Global::SystemButtonType getButtonType() const; Q_NODISCARD Global::SystemButtonType getButtonType() const;
void setButtonType(const Global::SystemButtonType type); void setButtonType(const Global::SystemButtonType type);
@ -86,7 +86,7 @@ private:
private: private:
StandardSystemButton *q_ptr = nullptr; StandardSystemButton *q_ptr = nullptr;
Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown; Global::SystemButtonType m_buttonType = Global::SystemButtonType::Unknown;
QString m_code = {}; QString m_glyph = {};
QColor m_hoverColor = {}; QColor m_hoverColor = {};
QColor m_pressColor = {}; QColor m_pressColor = {};
QColor m_normalColor = {}; QColor m_normalColor = {};

View File

@ -39,7 +39,7 @@ class FRAMELESSHELPER_WIDGETS_API StandardSystemButton : public QAbstractButton
Q_DECLARE_PRIVATE(StandardSystemButton) Q_DECLARE_PRIVATE(StandardSystemButton)
Q_DISABLE_COPY_MOVE(StandardSystemButton) Q_DISABLE_COPY_MOVE(StandardSystemButton)
Q_PROPERTY(Global::SystemButtonType buttonType READ buttonType WRITE setButtonType NOTIFY buttonTypeChanged FINAL) 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 hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL)
Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
Q_PROPERTY(QColor hoverColor READ hoverColor WRITE setHoverColor NOTIFY hoverColorChanged 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 QSize sizeHint() const override;
Q_NODISCARD Global::SystemButtonType buttonType(); Q_NODISCARD Global::SystemButtonType buttonType();
Q_NODISCARD QString code() const; Q_NODISCARD QString glyph() const;
Q_NODISCARD bool isHovered() const; Q_NODISCARD bool isHovered() const;
Q_NODISCARD bool isPressed() const; Q_NODISCARD bool isPressed() const;
Q_NODISCARD QColor hoverColor() const; Q_NODISCARD QColor hoverColor() const;
@ -70,7 +70,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void setButtonType(const Global::SystemButtonType value); void setButtonType(const Global::SystemButtonType value);
void setCode(const QString &code); void setGlyph(const QString &glyph);
void setHovered(const bool value); void setHovered(const bool value);
void setPressed(const bool value); void setPressed(const bool value);
void setHoverColor(const QColor &value); void setHoverColor(const QColor &value);
@ -88,7 +88,7 @@ protected:
Q_SIGNALS: Q_SIGNALS:
void buttonTypeChanged(); void buttonTypeChanged();
void codeChanged(); void glyphChanged();
void hoveredChanged(); void hoveredChanged();
void pressedChanged(); void pressedChanged();
void hoverColorChanged(); void hoverColorChanged();

View File

@ -145,7 +145,7 @@ Qt::Edges Utils::calculateWindowEdges(const QWindow *window, const QPoint &pos)
#endif #endif
} }
QString Utils::getSystemButtonIconCode(const SystemButtonType button) QString Utils::getSystemButtonGlyph(const SystemButtonType button)
{ {
#ifdef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE #ifdef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
return {}; return {};

View File

@ -70,9 +70,9 @@ QuickGlobal::SystemButtonType QuickStandardSystemButton::buttonType() const
return m_buttonType; return m_buttonType;
} }
QString QuickStandardSystemButton::code() const QString QuickStandardSystemButton::glyph() const
{ {
return m_code; return m_glyph;
} }
QColor QuickStandardSystemButton::normalColor() const QColor QuickStandardSystemButton::normalColor() const
@ -127,23 +127,23 @@ void QuickStandardSystemButton::setButtonType(const QuickGlobal::SystemButtonTyp
return; return;
} }
m_buttonType = type; m_buttonType = type;
setCode(Utils::getSystemButtonIconCode( setGlyph(Utils::getSystemButtonGlyph(
FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, m_buttonType))); FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, m_buttonType)));
Q_EMIT buttonTypeChanged(); Q_EMIT buttonTypeChanged();
} }
void QuickStandardSystemButton::setCode(const QString &value) void QuickStandardSystemButton::setGlyph(const QString &value)
{ {
Q_ASSERT(!value.isEmpty()); Q_ASSERT(!value.isEmpty());
if (value.isEmpty()) { if (value.isEmpty()) {
return; return;
} }
if (m_code == value) { if (m_glyph == value) {
return; return;
} }
m_code = value; m_glyph = value;
m_contentItem->setText(m_code); m_contentItem->setText(m_glyph);
Q_EMIT codeChanged(); Q_EMIT glyphChanged();
} }
void QuickStandardSystemButton::setNormalColor(const QColor &value) void QuickStandardSystemButton::setNormalColor(const QColor &value)

View File

@ -78,24 +78,24 @@ const StandardSystemButtonPrivate *StandardSystemButtonPrivate::get(const Standa
return pub->d_func(); 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()); Q_ASSERT(!value.isEmpty());
if (value.isEmpty()) { if (value.isEmpty()) {
return; return;
} }
if (m_code == value) { if (m_glyph == value) {
return; return;
} }
m_code = value; m_glyph = value;
Q_Q(StandardSystemButton); Q_Q(StandardSystemButton);
q->update(); q->update();
Q_EMIT q->codeChanged(); Q_EMIT q->glyphChanged();
} }
SystemButtonType StandardSystemButtonPrivate::getButtonType() const SystemButtonType StandardSystemButtonPrivate::getButtonType() const
@ -113,7 +113,7 @@ void StandardSystemButtonPrivate::setButtonType(const SystemButtonType type)
return; return;
} }
m_buttonType = type; m_buttonType = type;
setCode(Utils::getSystemButtonIconCode(m_buttonType)); setGlyph(Utils::getSystemButtonGlyph(m_buttonType));
Q_Q(StandardSystemButton); Q_Q(StandardSystemButton);
q->update(); q->update();
} }
@ -364,7 +364,7 @@ void StandardSystemButtonPrivate::paintEventHandler(QPaintEvent *event)
if (backgroundColor.isValid()) { if (backgroundColor.isValid()) {
painter.fillRect(buttonRect, backgroundColor); painter.fillRect(buttonRect, backgroundColor);
} }
if (!m_code.isEmpty()) { if (!m_glyph.isEmpty()) {
painter.setPen([this]() -> QColor { painter.setPen([this]() -> QColor {
if (!m_hovered && !m_active && m_inactiveForegroundColor.isValid()) { if (!m_hovered && !m_active && m_inactiveForegroundColor.isValid()) {
return m_inactiveForegroundColor; return m_inactiveForegroundColor;
@ -381,7 +381,7 @@ void StandardSystemButtonPrivate::paintEventHandler(QPaintEvent *event)
} }
return font; return font;
}()); }());
painter.drawText(buttonRect, Qt::AlignCenter, m_code); painter.drawText(buttonRect, Qt::AlignCenter, m_glyph);
} }
painter.restore(); painter.restore();
event->accept(); event->accept();
@ -423,10 +423,10 @@ SystemButtonType StandardSystemButton::buttonType()
return d->getButtonType(); return d->getButtonType();
} }
QString StandardSystemButton::code() const QString StandardSystemButton::glyph() const
{ {
Q_D(const StandardSystemButton); Q_D(const StandardSystemButton);
return d->getCode(); return d->getGlyph();
} }
void StandardSystemButton::setButtonType(const SystemButtonType value) void StandardSystemButton::setButtonType(const SystemButtonType value)
@ -435,10 +435,10 @@ void StandardSystemButton::setButtonType(const SystemButtonType value)
d->setButtonType(value); d->setButtonType(value);
} }
void StandardSystemButton::setCode(const QString &code) void StandardSystemButton::setGlyph(const QString &glyph)
{ {
Q_D(StandardSystemButton); Q_D(StandardSystemButton);
d->setCode(code); d->setGlyph(glyph);
} }
bool StandardSystemButton::isHovered() const bool StandardSystemButton::isHovered() const