Krita Source Code Documentation
Loading...
Searching...
No Matches
KisStretchedIconButton.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QIcon>
10#include <QLabel>
11#include <QHBoxLayout>
12#include <QAction>
13
14#include <kis_debug.h>
15
17 : QToolButton(parent),
18 m_label(new QLabel(this))
19{
20 m_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
21 QHBoxLayout *layout = new QHBoxLayout();
22 layout->addWidget(m_label);
23 setLayout(layout);
25}
26
30
32{
33 m_stretchedIcon = icon;
35}
36
41
43{
45 m_action = action;
46 if (action) {
47 m_actionConnections.addConnection(action, &QAction::changed,
49 m_actionConnections.addConnection(this, &KisStretchedIconButton::clicked,
50 action, &QAction::trigger);
51 }
53}
54
56{
57 return m_action;
58}
59
60void KisStretchedIconButton::resizeEvent(QResizeEvent *event)
61{
62 QToolButton::resizeEvent(event);
64}
65
67{
68 m_label->setPixmap(m_stretchedIcon.pixmap(this->windowHandle(), m_label->size()));
69}
70
72{
73 setStretchedIcon(m_action ? m_action->icon() : QIcon());
74 setText("");
75 setToolTip(m_action ? m_action->toolTip() : "");
76 setStatusTip(m_action ? m_action->statusTip() : "");
77 setWhatsThis(m_action ? m_action->whatsThis() : "");
78 setEnabled(m_action && m_action->isEnabled());
79 setVisible(m_action && m_action->isVisible());
80}
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
KisStretchedIconButton(QWidget *parent)
void setStretchedIcon(const QIcon &icon)
void resizeEvent(QResizeEvent *event)
KisSignalAutoConnectionsStore m_actionConnections
void setAssociatedAction(QAction *action)