Krita Source Code Documentation
Loading...
Searching...
No Matches
KoAspectButton.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2005-2007 Thomas Zander <zander@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "KoAspectButton.h"
7
8#include <QPixmap>
9#include <QPainter>
10#include <QMouseEvent>
11
12#include <kis_icon_utils.h>
13
14class Q_DECL_HIDDEN KoAspectButton::Private
15{
16public:
18 : keepAspect(true)
19 {
20 }
22};
23
25 : QToolButton(parent),
26 d( new Private() )
27{
28 setIconSize(QSize(9, 24));
29 setFixedSize(19, 34);
30 setAutoRaise(true);
31
32 connect(this, SIGNAL(released()), this, SLOT(buttonReleased()));
33
34 setKeepAspectRatio(false);
35}
36
41
43 if(! isEnabled())
44 return;
45 setKeepAspectRatio(!d->keepAspect);
46}
47
49 this->setIcon(on ? KisIconUtils::loadIcon("chain-icon") : KisIconUtils::loadIcon("chain-broken-icon"));
50 update();
51
52 if(d->keepAspect != on) {
53 d->keepAspect = on;
54 Q_EMIT keepAspectRatioChanged(d->keepAspect);
55 }
56}
57
59{
60 return d->keepAspect;
61}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
~KoAspectButton() override
void keepAspectRatioChanged(bool keep)
KoAspectButton(QWidget *parent)
constructor
bool keepAspectRatio() const
Returns of keeping aspect ratio is on or off.
void setKeepAspectRatio(bool keep)
Private *const d
QIcon loadIcon(const QString &name)