theshell/shell/switch.h

75 lines
2.1 KiB
C
Raw Normal View History

2017-08-05 01:20:02 -04:00
/****************************************
2018-01-08 02:26:23 -05:00
*
2017-08-05 01:20:02 -04:00
* theShell - Desktop Environment
2019-01-01 05:52:05 -05:00
* Copyright (C) 2019 Victor Tran
2017-08-05 01:20:02 -04:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2018-01-08 02:26:23 -05:00
*
2017-08-05 01:20:02 -04:00
* *************************************/
#ifndef SWITCH_H
#define SWITCH_H
#include <QWidget>
#include <QPushButton>
#include <QPaintEvent>
#include <QPainter>
#include <QStaticText>
2017-01-11 09:00:27 -05:00
#include <tvariantanimation.h>
class Switch : public QPushButton
{
Q_OBJECT
2016-05-29 03:03:52 -04:00
Q_PROPERTY(QString OnText READ OnText WRITE setOnText NOTIFY OnTextChanged)
Q_PROPERTY(QString OffText READ OffText WRITE setOffText NOTIFY OffTextChanged)
Q_PROPERTY(QIcon OnIcon READ OnIcon WRITE setOnIcon NOTIFY OnIconChanged)
public:
explicit Switch(QWidget *parent = 0);
2016-05-29 03:03:52 -04:00
QString OnText();
QString OffText();
QIcon OnIcon();
signals:
2016-05-29 03:03:52 -04:00
void OnTextChanged(QString OnText);
void OffTextChanged(QString OffText);
void OnIconChanged(QString OffText);
public slots:
2016-05-29 03:03:52 -04:00
void setOnText(QString text);
void setOffText(QString text);
void setOnIcon(QIcon icon);
private slots:
void checkChanging(bool checked);
private:
void paintEvent(QPaintEvent *event);
2016-05-29 03:03:52 -04:00
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
QPalette::ColorGroup IsActiveColorRole();
2016-06-30 02:07:29 -04:00
QSize sizeHint() const;
2016-05-29 03:03:52 -04:00
QRect innerRect;
int mouseClickPoint;
int initialPoint;
bool mouseMovedLeft = false;
QString iText = "I";
QString oText = "O";
QIcon iIcon;
};
#endif // SWITCH_H