File indexing completed on 2024-05-12 16:02:07
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef KOASPECTBUTTON_H 0007 #define KOASPECTBUTTON_H 0008 0009 #include <QToolButton> 0010 0011 #include "kritawidgets_export.h" 0012 0013 /** 0014 * This button gives a visual indication of weather the 'aspect ratio' is locked. 0015 * Typically you would use this alongside 2 spinboxes with a value like a width and height. 0016 */ 0017 class KRITAWIDGETS_EXPORT KoAspectButton : public QToolButton { 0018 Q_OBJECT 0019 public: 0020 /// constructor 0021 explicit KoAspectButton(QWidget *parent); 0022 ~KoAspectButton() override; 0023 0024 /// Returns of keeping aspect ratio is on or off 0025 bool keepAspectRatio() const; 0026 0027 public Q_SLOTS: 0028 /** 0029 * Set the visual indicator to be locked or not. 0030 * This also emits the keepAspectRatioChanged if the value has changed. 0031 * @param keep if true, lock the aspect ratio. 0032 */ 0033 void setKeepAspectRatio(bool keep); 0034 0035 // connect the button release 0036 void buttonReleased(); 0037 0038 Q_SIGNALS: 0039 /** 0040 * This signal is emitted every time the button changes value, either by user interaction or 0041 * by programetically setting it. 0042 */ 0043 void keepAspectRatioChanged(bool keep); 0044 0045 private: 0046 class Private; 0047 Private * const d; 0048 }; 0049 0050 #endif