DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
diconbutton.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DICONBUTTON_H
6#define DICONBUTTON_H
7
8#include <dtkwidget_global.h>
9#include <DObject>
10#include <DStyle>
11#include <DDciIcon>
12
13#include <QAbstractButton>
14
15DGUI_BEGIN_NAMESPACE
16class DDciIcon;
17DGUI_END_NAMESPACE
18
19DWIDGET_BEGIN_NAMESPACE
20
21class DIconButtonPrivate;
22class DStyleOptionButton;
23class DIconButton : public QAbstractButton, public DCORE_NAMESPACE::DObject
24{
25 Q_OBJECT
26 D_DECLARE_PRIVATE(DIconButton)
27
28 Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
29
30public:
31 explicit DIconButton(QWidget *parent = nullptr);
32 explicit DIconButton(QStyle::StandardPixmap iconType, QWidget *parent = nullptr);
33 explicit DIconButton(DStyle::StandardPixmap iconType, QWidget *parent = nullptr);
34 explicit DIconButton(const DDciIcon &dciIcon, QWidget *parent = nullptr);
35 ~DIconButton() override;
36
37 void setIcon(const QIcon &icon);
38 void setIcon(QStyle::StandardPixmap iconType);
39 void setIcon(DStyle::StandardPixmap iconType);
40 void setIcon(const DDciIcon &icon);
41
42 DDciIcon dciIcon() const;
43
44 QSize sizeHint() const override;
45 QSize minimumSizeHint() const override;
46 QSize iconSize() const;
47
48 bool isFlat() const;
49
50 void setEnabledCircle(bool status);
51 bool enabledCircle() const;
52 void setNewNotification(const bool set_new);
53
54public Q_SLOTS:
55 void setFlat(bool flat);
56
57protected:
58 using QAbstractButton::setText;
59 using QAbstractButton::text;
60
61 DIconButton(DIconButtonPrivate &dd, QWidget *parent = nullptr);
62 virtual DStyleOptionButton baseStyleOption() const;
63 virtual void initStyleOption(DStyleOptionButton *option) const;
64 void keyPressEvent(QKeyEvent *event) override;
65
66private:
67 void paintEvent(QPaintEvent *event) override;
68 bool event(QEvent *e) override;
69};
70
71DWIDGET_END_NAMESPACE
72
73#endif // DICONBUTTON_H
Definition diconbutton_p.h:14
按钮的图标
Definition diconbutton.h:24
Dtk 样式统一的按钮样式配置.
Definition dstyleoption.h:58
StandardPixmap
Definition dstyle.h:188