1 Star 0 Fork 0

tongy boys/material-pri

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
qtmaterialswitch_internal.h 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
#ifndef QTMATERIALSWITCH_INTERNAL_H
#define QTMATERIALSWITCH_INTERNAL_H
#include "lib/qtmaterialrippleoverlay.h"
#include <QWidget>
class QtMaterialSwitch;
class QtMaterialSwitchThumb;
class QtMaterialSwitchTrack;
class QtMaterialSwitchRippleOverlay : public QtMaterialRippleOverlay
{
Q_OBJECT
public:
QtMaterialSwitchRippleOverlay(QtMaterialSwitchThumb *thumb, QtMaterialSwitchTrack *track, QtMaterialSwitch *parent);
~QtMaterialSwitchRippleOverlay() override;
protected slots:
void addSwitchRipple();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
QRect overlayGeometry() const override;
private:
Q_DISABLE_COPY(QtMaterialSwitchRippleOverlay)
QtMaterialSwitch *const m_switch;
QtMaterialSwitchThumb *const m_thumb;
QtMaterialSwitchTrack *const m_track;
};
class QtMaterialSwitchThumb : public QWidget
{
Q_OBJECT
Q_PROPERTY(qreal shift WRITE setShift READ shift)
Q_PROPERTY(QColor thumbColor WRITE setThumbColor READ thumbColor)
public:
QtMaterialSwitchThumb(QtMaterialSwitch *parent);
~QtMaterialSwitchThumb() override;
void setShift(qreal shift);
inline qreal shift() const;
inline qreal offset() const;
inline void setThumbColor(const QColor &color);
inline QColor thumbColor() const;
private:
Q_DISABLE_COPY(QtMaterialSwitchThumb)
void updateOffset();
QtMaterialSwitch *const m_switch;
QColor m_thumbColor;
qreal m_shift;
qreal m_offset;
// QWidget interface
protected:
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
};
inline qreal QtMaterialSwitchThumb::shift() const
{
return m_shift;
}
inline qreal QtMaterialSwitchThumb::offset() const
{
return m_offset;
}
inline void QtMaterialSwitchThumb::setThumbColor(const QColor &color)
{
m_thumbColor = color;
update();
}
inline QColor QtMaterialSwitchThumb::thumbColor() const
{
return m_thumbColor;
}
class QtMaterialSwitchTrack : public QWidget
{
Q_OBJECT
Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor)
public:
QtMaterialSwitchTrack(QtMaterialSwitch *parent);
~QtMaterialSwitchTrack() override;
void setTrackColor(const QColor &color);
inline QColor trackColor() const;
private:
Q_DISABLE_COPY(QtMaterialSwitchTrack)
QtMaterialSwitch *const m_switch;
QColor m_trackColor;
// QWidget interface
protected:
void paintEvent(QPaintEvent *event) override;
};
inline QColor QtMaterialSwitchTrack::trackColor() const
{
return m_trackColor;
}
#endif // QTMATERIALSWITCH_INTERNAL_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/tongynj/material-pri.git
git@gitee.com:tongynj/material-pri.git
tongynj
material-pri
material-pri
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385