You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.7 KiB
C

#ifndef SARIBBONCOLORTOOLBUTTON_H
#define SARIBBONCOLORTOOLBUTTON_H
#include "SARibbonToolButton.h"
#include "SARibbonGlobal.h"
class SAColorMenu;
/**
* @brief Refer to the color setting button in the office, which can display the color below the icon(office)
*/
class SA_RIBBON_EXPORT SARibbonColorToolButton : public SARibbonToolButton
{
Q_OBJECT
SA_RIBBON_DECLARE_PRIVATE(SARibbonColorToolButton)
public:
/**
* @brief
*/
enum ColorStyle
{
ColorUnderIcon, ///< 颜色在icon下方这个要求必须设置icon
ColorFillToIcon ///< 颜色作为icon这个模式下在setColor会自动生成一个颜色icon替换掉原来的icon因此setIcon函数没有作用
};
public:
SARibbonColorToolButton(QWidget* parent = Q_NULLPTR);
SARibbonColorToolButton(QAction* defaultAction, QWidget* parent = Q_NULLPTR);
~SARibbonColorToolButton();
// 获取颜色
QColor color() const;
// 设置颜色显示方案
void setColorStyle(ColorStyle s);
ColorStyle colorStyle() const;
// 建立标准的颜色菜单
SAColorMenu* setupStandardColorMenu();
public slots:
// 设置颜色,会发射colorChanged信号
void setColor(const QColor& c);
private slots:
void onButtonClicked(bool checked = false);
signals:
/**
* @brief
* @param color
*/
void colorClicked(const QColor& color, bool checked = false);
/**
* @brief
* @param color
*/
void colorChanged(const QColor& color);
protected:
void paintIcon(QPainter& p, const QStyleOptionToolButton& opt, const QRect& iconDrawRect);
};
#endif // SARIBBONCOLORTOOLBUTTON_H