make toggle pimpl class

This commit is contained in:
laserpants 2016-05-29 13:08:55 +03:00
parent 72162066b4
commit 26072c8373
6 changed files with 71 additions and 3 deletions

View File

@ -1,8 +1,20 @@
#include "toggle.h"
#include "toggle_p.h"
TogglePrivate::TogglePrivate(Toggle *q)
: q_ptr(q)
{
}
void TogglePrivate::init()
{
}
Toggle::Toggle(QWidget *parent)
: QAbstractButton(parent)
: QAbstractButton(parent),
d_ptr(new TogglePrivate(this))
{
d_func()->init();
}
Toggle::~Toggle()

View File

@ -3,6 +3,8 @@
#include <QAbstractButton>
class TogglePrivate;
class Toggle : public QAbstractButton
{
Q_OBJECT
@ -15,6 +17,12 @@ public:
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
const QScopedPointer<TogglePrivate> d_ptr;
private:
Q_DISABLE_COPY(Toggle)
Q_DECLARE_PRIVATE(Toggle)
};
#endif // TOGGLE_H

View File

@ -0,0 +1,11 @@
#include "toggle_internal.h"
#include "toggle.h"
Thumb::Thumb(Toggle *parent)
: QWidget(parent)
{
}
Thumb::~Thumb()
{
}

View File

@ -0,0 +1,20 @@
#ifndef TOGGLE_INTERNAL_H
#define TOGGLE_INTERNAL_H
#include <QWidget>
class Toggle;
class Thumb : public QWidget
{
Q_OBJECT
public:
Thumb(Toggle *parent);
~Thumb();
private:
Q_DISABLE_COPY(Thumb)
};
#endif // TOGGLE_INTERNAL_H

View File

@ -1,4 +1,19 @@
#ifndef TOGGLE_P_H
#define TOGGLE_P_H
#include "toggle_internal.h"
class TogglePrivate
{
Q_DISABLE_COPY(TogglePrivate)
Q_DECLARE_PUBLIC(Toggle)
public:
TogglePrivate(Toggle *q);
void init();
Toggle *const q_ptr;
};
#endif // TOGGLE_P_H

View File

@ -54,7 +54,8 @@ SOURCES += main.cpp\
components/searchfield.cpp \
lib/theme.cpp \
components/slider_internal.cpp \
components/flatbutton_internal.cpp
components/flatbutton_internal.cpp \
components/toggle_internal.cpp
HEADERS += mainwindow.h \
components/appbar.h \
@ -107,7 +108,8 @@ HEADERS += mainwindow.h \
components/slider_internal.h \
components/flatbutton_internal.h \
components/raisedbutton_p.h \
components/toggle_p.h
components/toggle_p.h \
components/toggle_internal.h
RESOURCES += \
resources.qrc