From 792f3cfa24b9767cfe6ed1a16827b34133439396 Mon Sep 17 00:00:00 2001 From: Achraf k Date: Thu, 17 Feb 2022 02:23:36 +0100 Subject: [PATCH] IconButton => md --- components/qtmaterialiconbutton.cpp | 66 +++++++++++++++-------------- components/qtmaterialiconbutton.h | 21 +++++---- components/qtmaterialiconbutton_p.h | 23 ++++++---- 3 files changed, 62 insertions(+), 48 deletions(-) diff --git a/components/qtmaterialiconbutton.cpp b/components/qtmaterialiconbutton.cpp index 525d6b2..9fbe457 100644 --- a/components/qtmaterialiconbutton.cpp +++ b/components/qtmaterialiconbutton.cpp @@ -5,25 +5,27 @@ #include "lib/qtmaterialstyle.h" #include "lib/qtmaterialrippleoverlay.h" +namespace md +{ /*! * \class QtMaterialIconButtonPrivate * \internal */ -QtMaterialIconButtonPrivate::QtMaterialIconButtonPrivate(QtMaterialIconButton *q) +IconButtonPrivate::IconButtonPrivate(IconButton *q) : q_ptr(q) { } -QtMaterialIconButtonPrivate::~QtMaterialIconButtonPrivate() +IconButtonPrivate::~IconButtonPrivate() { } -void QtMaterialIconButtonPrivate::init() +void IconButtonPrivate::init() { - Q_Q(QtMaterialIconButton); + Q_Q(IconButton); - rippleOverlay = new QtMaterialRippleOverlay(q->parentWidget()); + rippleOverlay = new RippleOverlay(q->parentWidget()); useThemeColors = true; rippleOverlay->installEventFilter(q); @@ -35,9 +37,9 @@ void QtMaterialIconButtonPrivate::init() q->setSizePolicy(policy); } -void QtMaterialIconButtonPrivate::updateRipple() +void IconButtonPrivate::updateRipple() { - Q_Q(QtMaterialIconButton); + Q_Q(IconButton); QRect r(q->rect()); r.setSize(QSize(q->width()*2, q->height()*2)); @@ -49,30 +51,30 @@ void QtMaterialIconButtonPrivate::updateRipple() * \class QtMaterialIconButton */ -QtMaterialIconButton::QtMaterialIconButton(const QIcon &icon, QWidget *parent) +IconButton::IconButton(const QIcon &icon, QWidget *parent) : QAbstractButton(parent), - d_ptr(new QtMaterialIconButtonPrivate(this)) + d_ptr(new IconButtonPrivate(this)) { d_func()->init(); setIcon(icon); } -QtMaterialIconButton::~QtMaterialIconButton() +IconButton::~IconButton() { } /*! * \reimp */ -QSize QtMaterialIconButton::sizeHint() const +QSize IconButton::sizeHint() const { return iconSize(); } -void QtMaterialIconButton::setUseThemeColors(bool value) +void IconButton::setUseThemeColors(bool value) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); if (d->useThemeColors == value) { return; @@ -82,16 +84,16 @@ void QtMaterialIconButton::setUseThemeColors(bool value) update(); } -bool QtMaterialIconButton::useThemeColors() const +bool IconButton::useThemeColors() const { - Q_D(const QtMaterialIconButton); + Q_D(const IconButton); return d->useThemeColors; } -void QtMaterialIconButton::setColor(const QColor &color) +void IconButton::setColor(const QColor &color) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->color = color; @@ -99,9 +101,9 @@ void QtMaterialIconButton::setColor(const QColor &color) update(); } -QColor QtMaterialIconButton::color() const +QColor IconButton::color() const { - Q_D(const QtMaterialIconButton); + Q_D(const IconButton); if (d->useThemeColors || !d->color.isValid()) { return QtMaterialStyle::instance().themeColor("text"); @@ -109,9 +111,9 @@ QColor QtMaterialIconButton::color() const return d->color; } -void QtMaterialIconButton::setDisabledColor(const QColor &color) +void IconButton::setDisabledColor(const QColor &color) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->disabledColor = color; @@ -119,9 +121,9 @@ void QtMaterialIconButton::setDisabledColor(const QColor &color) update(); } -QColor QtMaterialIconButton::disabledColor() const +QColor IconButton::disabledColor() const { - Q_D(const QtMaterialIconButton); + Q_D(const IconButton); if (d->useThemeColors || !d->disabledColor.isValid()) { return QtMaterialStyle::instance().themeColor("disabled"); @@ -129,7 +131,7 @@ QColor QtMaterialIconButton::disabledColor() const return d->disabledColor; } -QtMaterialIconButton::QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidget *parent) +IconButton::IconButton(IconButtonPrivate &d, QWidget *parent) : QAbstractButton(parent), d_ptr(&d) { @@ -139,9 +141,9 @@ QtMaterialIconButton::QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidg /*! * \reimp */ -bool QtMaterialIconButton::event(QEvent *event) +bool IconButton::event(QEvent *event) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); switch (event->type()) { @@ -165,11 +167,11 @@ bool QtMaterialIconButton::event(QEvent *event) /*! * \reimp */ -bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event) +bool IconButton::eventFilter(QObject *obj, QEvent *event) { if (QEvent::Resize == event->type()) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->updateRipple(); } @@ -179,9 +181,9 @@ bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event) /*! * \reimp */ -void QtMaterialIconButton::mousePressEvent(QMouseEvent *event) +void IconButton::mousePressEvent(QMouseEvent *event) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->rippleOverlay->addRipple(QPoint(d->rippleOverlay->width(), d->rippleOverlay->height())/2, @@ -194,7 +196,7 @@ void QtMaterialIconButton::mousePressEvent(QMouseEvent *event) /*! * \reimp */ -void QtMaterialIconButton::paintEvent(QPaintEvent *event) +void IconButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -210,3 +212,5 @@ void QtMaterialIconButton::paintEvent(QPaintEvent *event) const qreal h = pixmap.height(); painter.drawPixmap(QRect((r.width()-w)/2, (r.height()-h)/2, w, h), pixmap); } + +} diff --git a/components/qtmaterialiconbutton.h b/components/qtmaterialiconbutton.h index 5c2afc4..1495743 100644 --- a/components/qtmaterialiconbutton.h +++ b/components/qtmaterialiconbutton.h @@ -3,15 +3,18 @@ #include -class QtMaterialIconButtonPrivate; +namespace md +{ -class QtMaterialIconButton : public QAbstractButton +class IconButtonPrivate; + +class IconButton : public QAbstractButton { Q_OBJECT public: - explicit QtMaterialIconButton(const QIcon &icon, QWidget *parent = 0); - ~QtMaterialIconButton(); + explicit IconButton(const QIcon &icon, QWidget *parent = 0); + ~IconButton(); QSize sizeHint() const Q_DECL_OVERRIDE; @@ -25,18 +28,20 @@ public: QColor disabledColor() const; protected: - QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidget *parent = 0); + IconButton(IconButtonPrivate &d, QWidget *parent = 0); bool event(QEvent *event) Q_DECL_OVERRIDE; bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialIconButton) - Q_DECLARE_PRIVATE(QtMaterialIconButton) + Q_DISABLE_COPY(IconButton) + Q_DECLARE_PRIVATE(IconButton) }; +} + #endif // QTMATERIALICONBUTTON_H diff --git a/components/qtmaterialiconbutton_p.h b/components/qtmaterialiconbutton_p.h index a532abc..42d071e 100644 --- a/components/qtmaterialiconbutton_p.h +++ b/components/qtmaterialiconbutton_p.h @@ -3,27 +3,32 @@ #include -class QtMaterialIconButton; -class QtMaterialRippleOverlay; + +namespace md +{ +class IconButton; +class RippleOverlay; class QColor; -class QtMaterialIconButtonPrivate +class IconButtonPrivate { - Q_DISABLE_COPY(QtMaterialIconButtonPrivate) - Q_DECLARE_PUBLIC(QtMaterialIconButton) + Q_DISABLE_COPY(IconButtonPrivate) + Q_DECLARE_PUBLIC(IconButton) public: - QtMaterialIconButtonPrivate(QtMaterialIconButton *q); - virtual ~QtMaterialIconButtonPrivate(); + IconButtonPrivate(IconButton *q); + virtual ~IconButtonPrivate(); void init(); void updateRipple(); - QtMaterialIconButton *const q_ptr; - QtMaterialRippleOverlay *rippleOverlay; + IconButton *const q_ptr; + RippleOverlay *rippleOverlay; QColor color; QColor disabledColor; bool useThemeColors; }; +} + #endif // QTMATERIALICONBUTTON_P_H