QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsratiolockbutton.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsratiolockbutton.cpp - Lock button
3 --------------------------------------
4 Date : July, 2017
5 Copyright : (C) 2017 by Mathieu Pellerin
6 Email : nirvn dot asia at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSLOCKBUTTON_H
17#define QGSLOCKBUTTON_H
18
19#include "qgsratiolockbutton.h"
20
21#include <QToolButton>
22#include "qgis_gui.h"
23#include "qgis_sip.h"
24
25#include <QPointer>
26class QDoubleSpinBox;
27
33class GUI_EXPORT QgsRatioLockButton : public QToolButton
34{
35 Q_OBJECT
36 Q_PROPERTY( bool locked READ locked WRITE setLocked )
37
38 public:
43 QgsRatioLockButton( QWidget *parent SIP_TRANSFERTHIS = nullptr );
44
50 void setLocked( bool locked );
51
57 bool locked() const { return mLocked; }
58
69 void setWidthSpinBox( QDoubleSpinBox *widget );
70
81 void setHeightSpinBox( QDoubleSpinBox *widget );
82
87 void resetRatio();
88
89 signals:
90
94 void lockChanged( bool locked );
95
96 protected:
97 void changeEvent( QEvent *e ) override;
98 void showEvent( QShowEvent *e ) override;
99 void resizeEvent( QResizeEvent *event ) override;
100
101 private:
102 void drawButton();
103
104 bool mLocked = false;
105
106 QPointer<QDoubleSpinBox> mWidthSpinBox;
107 double mPrevWidth = 0;
108 QPointer<QDoubleSpinBox> mHeightSpinBox;
109 double mPrevHeight = 0;
110 bool mUpdatingRatio = false;
111
112 private slots:
113
114 void buttonClicked();
115
116 void widthSpinBoxChanged( double value );
117 void heightSpinBoxChanged( double value );
118};
119
120#endif
A cross platform button subclass used to represent a locked / unlocked ratio state.
bool locked() const
Returns whether the button state is locked.
void lockChanged(bool locked)
Emitted whenever the lock state changes.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53