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++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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