QGIS API Documentation 3.41.0-Master (3440c17df1d)
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:
39
44 QgsRatioLockButton( QWidget *parent SIP_TRANSFERTHIS = nullptr );
45
51 void setLocked( bool locked );
52
58 bool locked() const { return mLocked; }
59
70 void setWidthSpinBox( QDoubleSpinBox *widget );
71
82 void setHeightSpinBox( QDoubleSpinBox *widget );
83
88 void resetRatio();
89
90 signals:
91
95 void lockChanged( bool locked );
96
97 protected:
98
99 void changeEvent( QEvent *e ) override;
100 void showEvent( QShowEvent *e ) override;
101 void resizeEvent( QResizeEvent *event ) override;
102
103 private:
104
105 void drawButton();
106
107 bool mLocked = false;
108
109 QPointer< QDoubleSpinBox > mWidthSpinBox;
110 double mPrevWidth = 0;
111 QPointer< QDoubleSpinBox > mHeightSpinBox;
112 double mPrevHeight = 0;
113 bool mUpdatingRatio = false;
114
115 private slots:
116
117 void buttonClicked();
118
119 void widthSpinBoxChanged( double value );
120 void heightSpinBoxChanged( double value );
121
122};
123
124#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