From 07ce6b642fdd1b6627a8efa3278cb88bcad4c42f Mon Sep 17 00:00:00 2001 From: laserpants Date: Sun, 12 Jun 2016 19:02:45 +0300 Subject: [PATCH] make Radio Button pimpl class --- components/radiobutton.cpp | 16 ++++++++++++++-- components/radiobutton.h | 12 ++++++++++-- components/radiobutton_p.h | 23 +++++++++++++++++++++++ qt-material-widgets.pro | 3 ++- 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 components/radiobutton_p.h diff --git a/components/radiobutton.cpp b/components/radiobutton.cpp index aba1826..1766733 100644 --- a/components/radiobutton.cpp +++ b/components/radiobutton.cpp @@ -1,8 +1,20 @@ -#include #include "radiobutton.h" +#include +#include "radiobutton_p.h" + +RadioButtonPrivate::RadioButtonPrivate(RadioButton *q) + : q_ptr(q) +{ +} + +void RadioButtonPrivate::init() +{ + //Q_Q(RadioButton); +} RadioButton::RadioButton(QWidget *parent) - : QWidget(parent) + : QRadioButton(parent), + d_ptr(new RadioButtonPrivate(this)) { } diff --git a/components/radiobutton.h b/components/radiobutton.h index c5d6d42..5b1dec7 100644 --- a/components/radiobutton.h +++ b/components/radiobutton.h @@ -1,9 +1,11 @@ #ifndef RADIOBUTTON_H #define RADIOBUTTON_H -#include +#include -class RadioButton : public QWidget +class RadioButtonPrivate; + +class RadioButton : public QRadioButton { Q_OBJECT @@ -15,6 +17,12 @@ protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + + const QScopedPointer d_ptr; + +private: + Q_DISABLE_COPY(RadioButton) + Q_DECLARE_PRIVATE(RadioButton) }; #endif // RADIOBUTTON_H diff --git a/components/radiobutton_p.h b/components/radiobutton_p.h new file mode 100644 index 0000000..a9723a2 --- /dev/null +++ b/components/radiobutton_p.h @@ -0,0 +1,23 @@ +#ifndef RADIOBUTTON_P_H +#define RADIOBUTTON_P_H + +#include + +class RadioButton; +class RippleOverlay; + +class RadioButtonPrivate +{ + Q_DISABLE_COPY(RadioButtonPrivate) + Q_DECLARE_PUBLIC(RadioButton) + +public: + RadioButtonPrivate(RadioButton *q); + + void init(); + + RadioButton *const q_ptr; + RippleOverlay *ripple; +}; + +#endif // RADIOBUTTON_P_H diff --git a/qt-material-widgets.pro b/qt-material-widgets.pro index 2c80951..26b824d 100644 --- a/qt-material-widgets.pro +++ b/qt-material-widgets.pro @@ -120,7 +120,8 @@ HEADERS += mainwindow.h \ components/badge.h \ components/progress.h \ components/selectfield.h \ - components/fab_p.h + components/fab_p.h \ + components/radiobutton_p.h RESOURCES += \ resources.qrc