QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
34class GUI_EXPORT QgsRatioLockButton : public QToolButton
35{
36 Q_OBJECT
37 Q_PROPERTY( bool locked READ locked WRITE setLocked )
38
39 public:
40
45 QgsRatioLockButton( QWidget *parent SIP_TRANSFERTHIS = nullptr );
46
52 void setLocked( bool locked );
53
59 bool locked() const { return mLocked; }
60
71 void setWidthSpinBox( QDoubleSpinBox *widget );
72
83 void setHeightSpinBox( QDoubleSpinBox *widget );
84
89 void resetRatio();
90
91 signals:
92
96 void lockChanged( bool locked );
97
98 protected:
99
100 void changeEvent( QEvent *e ) override;
101 void showEvent( QShowEvent *e ) override;
102 void resizeEvent( QResizeEvent *event ) override;
103
104 private:
105
106 void drawButton();
107
108 bool mLocked = false;
109
110 QPointer< QDoubleSpinBox > mWidthSpinBox;
111 double mPrevWidth = 0;
112 QPointer< QDoubleSpinBox > mHeightSpinBox;
113 double mPrevHeight = 0;
114 bool mUpdatingRatio = false;
115
116 private slots:
117
118 void buttonClicked();
119
120 void widthSpinBoxChanged( double value );
121 void heightSpinBoxChanged( double value );
122
123};
124
125#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