123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #ifndef LHCOLORDIALOG_H
- #define LHCOLORDIALOG_H
- #include <QWidget>
- #include <QColorDialog>
- #include <QHBoxLayout>
- #include "DropShadow/idropshadowable.h"
- enum Skin {
- emBRIGHT = 0,
- emDARK = 1,
- emOTHER = 2
- };
- class LHColorDialog : public QDialog, public IDropShadowable
- {
- Q_OBJECT
- public:
- explicit LHColorDialog(Skin sk, const QString& qss, QWidget* parent = nullptr);
- explicit LHColorDialog(Skin sk, const QString& qss, const QColor& initial, QWidget* parent = nullptr);
- virtual ~LHColorDialog();
- void setStandardColor(int idx, const QColor& clr);
- void setCustomColor(int idx, const QColor& clr);
- QColor selectedColor() const {return m_selColor;}
- protected:
- void mousePressEvent(QMouseEvent*) override;
- void mouseReleaseEvent(QMouseEvent*) override;
- void mouseMoveEvent(QMouseEvent* ) override;
- signals:
- void sigColorSelected(const QColor& clr);
- void sigCurrentColorChanged(const QColor& clr);
- private slots:
- void createColorDialog(Skin sk, const QColor& initial = QColor());
- private:
- void setButtonName(); // 设置确认,取消按钮名称
- void customDialog(); // 自定义设置
- private:
- const int SHADOW_RADIUS = 20;
- QColorDialog* m_pColorDlg{nullptr};
- QHBoxLayout* m_pLayout{nullptr};
- bool m_bMousePress{false};
- QPoint m_prePos;
- QColor m_selColor;
- QString m_skinQss;
- };
- #endif // LHCOLORDIALOG_H
|