#include "touchbuttframe.h" TouchButtFrame::TouchButtFrame(QWidget *parent, QColor cr, QColor cg, QColor cw, QColor cp, Orientation orientation) : QFrame(parent) { colr = cr; colg = cg; colw = cw; colp = cp; setFrameShape(QFrame::StyledPanel);; if (orientation == Horizontal) lay = new QHBoxLayout(); else lay = new QVBoxLayout(); count = 0; } void TouchButtFrame::addButton(QString caption) { touch_butt * butt = new touch_butt(count,caption,colr,colg,colw,colp); butt->setMinimumHeight(50); butt->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); butt->setCheckable(true); butt->setAutoExclusive(true); butt->setAutoFillBackground(true); if (lay->isEmpty()) butt->setChecked(true); connect(butt,SIGNAL(touch_click(int)),SLOT(butt_click(int))); connect(butt,SIGNAL(touch_toggle(int,bool)),SLOT(butt_toggle(int,bool))); lay->addWidget(butt); this->setLayout(lay); count++; } void TouchButtFrame::butt_click(int index) { //qDebug() << "button" << index << "clicked!"; //if (((touch_butt*)lay->itemAt(index)->widget())->isChecked()) //((touch_butt*)lay->itemAt(index)->widget())->setGreen(); emit click(index); } void TouchButtFrame::butt_toggle(int index,bool checked) { //if (((touch_butt*)lay->itemAt(index)->widget())->isChecked()) //qDebug() << "button" << index << "toggled" << checked; emit toggle(index,checked); } void TouchButtFrame::resetColors() { for (int i=0; isetColor(colr,colg,colw,colp); } } int TouchButtFrame::buttCount() { return count; } touch_butt * TouchButtFrame::Button(int index) { return ((touch_butt*)lay->itemAt(index)->widget()); }