lhcolordialog.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef LHCOLORDIALOG_H
  2. #define LHCOLORDIALOG_H
  3. #include <QWidget>
  4. #include <QColorDialog>
  5. #include <QHBoxLayout>
  6. #include "DropShadow/idropshadowable.h"
  7. enum Skin {
  8. emBRIGHT = 0,
  9. emDARK = 1,
  10. emOTHER = 2
  11. };
  12. class LHColorDialog : public QDialog, public IDropShadowable
  13. {
  14. Q_OBJECT
  15. public:
  16. explicit LHColorDialog(Skin sk, const QString& qss, QWidget* parent = nullptr);
  17. explicit LHColorDialog(Skin sk, const QString& qss, const QColor& initial, QWidget* parent = nullptr);
  18. virtual ~LHColorDialog();
  19. void setStandardColor(int idx, const QColor& clr);
  20. void setCustomColor(int idx, const QColor& clr);
  21. QColor selectedColor() const {return m_selColor;}
  22. protected:
  23. void mousePressEvent(QMouseEvent*) override;
  24. void mouseReleaseEvent(QMouseEvent*) override;
  25. void mouseMoveEvent(QMouseEvent* ) override;
  26. signals:
  27. void sigColorSelected(const QColor& clr);
  28. void sigCurrentColorChanged(const QColor& clr);
  29. private slots:
  30. void createColorDialog(Skin sk, const QColor& initial = QColor());
  31. private:
  32. void setButtonName(); // 设置确认,取消按钮名称
  33. void customDialog(); // 自定义设置
  34. private:
  35. const int SHADOW_RADIUS = 20;
  36. QColorDialog* m_pColorDlg{nullptr};
  37. QHBoxLayout* m_pLayout{nullptr};
  38. bool m_bMousePress{false};
  39. QPoint m_prePos;
  40. QColor m_selColor;
  41. QString m_skinQss;
  42. };
  43. #endif // LHCOLORDIALOG_H