63 lines
2.5 KiB
C++
63 lines
2.5 KiB
C++
#ifndef TOUCHBUTTFRAME_H
|
|
#define TOUCHBUTTFRAME_H
|
|
|
|
#include <QtGui/QFrame>
|
|
#include <QBoxLayout>
|
|
#include <QDebug>
|
|
#include "touch_butt.h"
|
|
|
|
|
|
class TouchButtFrame : public QFrame
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(QColor colorYes READ colorYes WRITE setColorYes)
|
|
Q_PROPERTY(QColor colorNo READ colorNo WRITE setColorNo)
|
|
Q_PROPERTY(QColor colorDefault READ colorDefault WRITE setColorDefault)
|
|
Q_PROPERTY(QColor colorPush READ colorPush WRITE setColorPush)
|
|
Q_PROPERTY(QStringList buttons READ buttons WRITE setButtons)
|
|
Q_PROPERTY(int currentButton READ currentButton WRITE setCurrentButton)
|
|
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
|
|
public:
|
|
TouchButtFrame(QWidget * parent = 0,
|
|
QColor red = Qt::gray, QColor green = Qt::green, QColor white = Qt::white, QColor push = Qt::yellow,
|
|
Qt::Orientation orientation = Qt::Horizontal);
|
|
void setButtons(const QStringList &captions);
|
|
QStringList buttons();
|
|
int buttCount() const {return lay->count();}
|
|
int currentButton();
|
|
void setCurrentButton(int index);
|
|
QColor colorYes() const {return colg;}
|
|
QColor colorNo() const {return colr;}
|
|
QColor colorDefault() const {return colw;}
|
|
QColor colorPush() const {return colp;}
|
|
void setColorYes(QColor ColorYes) {colg = ColorYes; resetColors();}
|
|
void setColorNo(QColor ColorNo) {colr = ColorNo; resetColors();}
|
|
void setColorDefault(QColor ColorDefault) {colw = ColorDefault; resetColors();}
|
|
void setColorPush(QColor ColorPush) {colp = ColorPush; resetColors();}
|
|
void setOrientation(Qt::Orientation orientation)
|
|
{if (orientation == Qt::Horizontal) lay->setDirection(QBoxLayout::LeftToRight);
|
|
else lay->setDirection(QBoxLayout::TopToBottom);}
|
|
Qt::Orientation orientation() const
|
|
{if (lay->direction()==0) return Qt::Horizontal;
|
|
else return Qt::Vertical;}
|
|
void deleteButtons();
|
|
void addButton(const QString &caption);
|
|
touch_butt * Button(int index);
|
|
public slots:
|
|
void butt_click(int index);
|
|
void butt_toggle(int index, bool checked);
|
|
void set_green(int index) {if (Button(index) != 0) Button(index)->setGreen();}
|
|
void set_red(int index) {if (Button(index) != 0) Button(index)->setRed();}
|
|
void set_white(int index) {if (Button(index) != 0) Button(index)->setWhite();}
|
|
private:
|
|
QColor colr,colg,colw,colp;
|
|
QBoxLayout * lay;
|
|
//int count;
|
|
void resetColors();
|
|
signals:
|
|
void click(int index);
|
|
void toggle(int index, bool checked);
|
|
};
|
|
|
|
#endif // TOUCHBUTTFRAME_H
|