QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgis_gui.h"
22#include "qgis_sip.h"
23
24#include <QPointer>
25#include <QToolButton>
26
27class QDoubleSpinBox;
28
34class GUI_EXPORT QgsRatioLockButton : public QToolButton
35{
36 Q_OBJECT
37 Q_PROPERTY( bool locked READ locked WRITE setLocked )
38
39 public:
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 void changeEvent( QEvent *e ) override;
99 void showEvent( QShowEvent *e ) override;
100 void resizeEvent( QResizeEvent *event ) override;
101
102 private:
103 void drawButton();
104
105 bool mLocked = false;
106
107 QPointer<QDoubleSpinBox> mWidthSpinBox;
108 double mPrevWidth = 0;
109 QPointer<QDoubleSpinBox> mHeightSpinBox;
110 double mPrevHeight = 0;
111 bool mUpdatingRatio = false;
112
113 private slots:
114
115 void buttonClicked();
116
117 void widthSpinBoxChanged( double value );
118 void heightSpinBoxChanged( double value );
119};
120
121#endif
void setLocked(bool locked)
Sets whether the button state is locked.
void changeEvent(QEvent *e) override
void resizeEvent(QResizeEvent *event) override
QgsRatioLockButton(QWidget *parent=nullptr)
Construct a new ratio lock button.
bool locked() const
Returns whether the button state is locked.
void showEvent(QShowEvent *e) override
void lockChanged(bool locked)
Emitted whenever the lock state changes.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53