KIconThemes 5.109.0
kiconbutton.h
1/* vi: ts=8 sts=4 sw=4
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 "kiconthemes_export.h"
16
17#include <QPushButton>
18#include <memory>
19
20#include <kiconloader.h>
21
32class KICONTHEMES_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:
45 explicit KIconButton(QWidget *parent = nullptr);
46
47#if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 104)
55 KICONTHEMES_DEPRECATED_VERSION(5, 104, "Use KIconButton(QWidget *) instead")
56 KIconButton(KIconLoader *loader, QWidget *parent);
57#endif
58
62 ~KIconButton() override;
63
69 void setStrictIconSize(bool b);
73 bool strictIconSize() const;
74
79 void setIconType(KIconLoader::Group group, KIconLoader::Context context, bool user = false);
80
84 void setIcon(const QString &icon);
85
86 void setIcon(const QIcon &icon);
87
91 void resetIcon();
92
96 const QString &icon() const;
97
103 void setIconSize(int size);
108 int iconSize() const;
109
116 void setButtonIconSize(int size);
121 int buttonIconSize() const;
122
123Q_SIGNALS:
127 void iconChanged(const QString &icon);
128
129private:
130 std::unique_ptr<class KIconButtonPrivate> const d;
131
132 Q_DISABLE_COPY(KIconButton)
133};
134
135#endif // KICONBUTTON_H
A pushbutton for choosing an icon.
Definition kiconbutton.h:33
int iconSize() const
Returns the icon size set via setIconSize() or 0, if the default icon size will be used.
void setIcon(const QString &icon)
Sets the button's initial icon.
void setStrictIconSize(bool b)
Sets a strict icon size policy for allowed icons.
void setIconType(KIconLoader::Group group, KIconLoader::Context context, bool user=false)
Sets the icon group and context.
int buttonIconSize() const
Returns the button's icon size.
KIconButton(QWidget *parent=nullptr)
Constructs a KIconButton using the global icon loader.
~KIconButton() override
Destructs the button.
void setButtonIconSize(int size)
Sets the size of the icon to be shown on the button.
void iconChanged(const QString &icon)
Emitted when the icon has changed.
const QString & icon() const
Returns the name of the selected icon.
bool strictIconSize() const
Returns true if a strict icon size policy is set.
void resetIcon()
Resets the icon (reverts to an empty button).
void setIconSize(int size)
Sets the size of the icon to be shown / selected.
Iconloader for KDE.
Definition kiconloader.h:74
Group
The group of the icon.
Definition kiconloader.h:125
Context
Defines the context of the icon.
Definition kiconloader.h:81