KIconThemes

kiconbutton.h
1/*
2
3 This file is part of the KDE project, module kfile.
4 SPDX-FileCopyrightText: 2000 Geert Jansen <jansen@kde.org>
5 SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org>
6 SPDX-FileCopyrightText: 1997 Christoph Neerfeld <chris@kde.org>
7 SPDX-FileCopyrightText: 2002 Carsten Pfeiffer <pfeiffer@kde.org>
8
9 SPDX-License-Identifier: LGPL-2.0-only
10*/
11
12#ifndef KICONBUTTON_H
13#define KICONBUTTON_H
14
15#include "kiconwidgets_export.h"
16
17#include <QPushButton>
18#include <memory>
19
20#include <kiconloader.h>
21
22/**
23 * @class KIconButton kiconbutton.h KIconButton
24 *
25 * A pushbutton for choosing an icon. Pressing on the button will open a
26 * KIconDialog for the user to select an icon. The current icon will be
27 * displayed on the button.
28 *
29 * @see KIconDialog
30 * @short A push button that allows selection of an icon.
31 */
32class KICONWIDGETS_EXPORT KIconButton : public QPushButton
33{
34 Q_OBJECT
35 Q_PROPERTY(QString icon READ icon WRITE setIcon RESET resetIcon NOTIFY iconChanged USER true)
36 Q_PROPERTY(int iconSize READ iconSize WRITE setIconSize)
37 Q_PROPERTY(bool strictIconSize READ strictIconSize WRITE setStrictIconSize)
38
39public:
40 /**
41 * Constructs a KIconButton using the global icon loader.
42 *
43 * @param parent The parent widget.
44 */
45 explicit KIconButton(QWidget *parent = nullptr);
46
47 /**
48 * Destructs the button.
49 */
50 ~KIconButton() override;
51
52 /**
53 * Sets a strict icon size policy for allowed icons. When true,
54 * only icons of the specified group's size in setIconType() are allowed,
55 * and only icons of that size will be shown in the icon dialog.
56 */
57 void setStrictIconSize(bool b);
58 /**
59 * Returns true if a strict icon size policy is set.
60 */
61 bool strictIconSize() const;
62
63 /**
64 * Sets the icon group and context. Use KIconLoader::NoGroup if you want to
65 * allow icons for any group in the given context.
66 */
67 void setIconType(KIconLoader::Group group, KIconLoader::Context context, bool user = false);
68
69 /**
70 * Sets the button's initial icon.
71 */
72 void setIcon(const QString &icon);
73
74 void setIcon(const QIcon &icon);
75
76 /**
77 * Resets the icon (reverts to an empty button).
78 */
79 void resetIcon();
80
81 /**
82 * Returns the name of the selected icon.
83 */
84 const QString &icon() const;
85
86 /**
87 * Sets the size of the icon to be shown / selected.
88 * @see KIconLoader::StdSizes
89 * @see iconSize
90 */
91 void setIconSize(int size);
92 /**
93 * Returns the icon size set via setIconSize() or 0, if the default
94 * icon size will be used.
95 */
96 int iconSize() const;
97
98 /**
99 * Sets the size of the icon to be shown on the button.
100 * @see KIconLoader::StdSizes
101 * @see buttonIconSize
102 * @since 4.1
103 */
104 void setButtonIconSize(int size);
105 /**
106 * Returns the button's icon size.
107 * @since 4.1
108 */
109 int buttonIconSize() const;
110
112 /**
113 * Emitted when the icon has changed.
114 */
115 void iconChanged(const QString &icon);
116
117private:
118 std::unique_ptr<class KIconButtonPrivate> const d;
119
120 Q_DISABLE_COPY(KIconButton)
121};
122
123#endif // KICONBUTTON_H
A pushbutton for choosing an icon.
Definition kiconbutton.h:33
~KIconButton() override
Destructs the button.
void iconChanged(const QString &icon)
Emitted when the icon has changed.
Group
The group of the icon.
Context
Defines the context of the icon.
Definition kiconloader.h:80
void setIcon(const QIcon &icon)
void setIconSize(const QSize &size)
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.