You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							37 lines
						
					
					
						
							759 B
						
					
					
				
			
		
		
	
	
							37 lines
						
					
					
						
							759 B
						
					
					
				#pragma once
 | 
						|
#include <QtWidgets>
 | 
						|
 | 
						|
class Toggle : public QAbstractButton {
 | 
						|
  Q_OBJECT
 | 
						|
  Q_PROPERTY(int offset_circle READ offset_circle WRITE set_offset_circle CONSTANT)
 | 
						|
 | 
						|
public:
 | 
						|
  Toggle(QWidget* parent = nullptr);
 | 
						|
  void togglePosition();
 | 
						|
  bool on;
 | 
						|
  int animation_duration = 250;
 | 
						|
  int immediateOffset = 0;
 | 
						|
  int offset_circle() const {
 | 
						|
    return _x_circle;
 | 
						|
  }
 | 
						|
 | 
						|
  void set_offset_circle(int o) {
 | 
						|
    _x_circle = o;
 | 
						|
    update();
 | 
						|
  }
 | 
						|
 | 
						|
 | 
						|
protected:
 | 
						|
  void paintEvent(QPaintEvent*) override;
 | 
						|
  void mouseReleaseEvent(QMouseEvent*) override;
 | 
						|
  void enterEvent(QEvent*) override;
 | 
						|
 | 
						|
private:
 | 
						|
  int _x_circle, _y_circle;
 | 
						|
  int _height, _radius;
 | 
						|
  int _height_rect, _y_rect;
 | 
						|
  QPropertyAnimation *_anim = nullptr;
 | 
						|
 | 
						|
signals:
 | 
						|
  void stateChanged(int new_state);
 | 
						|
};
 | 
						|
 |