SceneSwitcher/lib/utils/switch-button.hpp
WarmUpTill 7d0332dd0e Restructure library and plugins
The "core" macro conditions and actions have been extracted out to the
"base" plugin.

The library now mostly contains functionality which is required across
all plugins and (e.g. definitions for macro segments).

The goal is to reduce the complexity and cross-dependencies and group
the source files in a better way.

This should relsove the "library limit of 65535 objects exceeded" build
issue occuring in some Windows build environments.
2024-01-27 14:10:34 +01:00

38 lines
751 B
C++

#pragma once
#include <QWidget>
namespace advss {
/*
Simple switch toogle button widget
Based on https://github.com/KDAB/kdabtv/blob/master/Styling-Qt-Widgets/toggleswitch.h
*/
class SwitchButton : public QWidget {
Q_OBJECT
public:
explicit SwitchButton(QWidget *parent = nullptr);
void setChecked(bool checked);
bool isChecked() const;
void toggle();
QSize sizeHint() const override;
signals:
void checked(bool checked); // by user
void toggled(bool checked); // by user or by program
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
private:
bool _checked = false;
bool _mouseDown = false;
};
} // namespace advss