Added dimbutton to the mainwindow in TelldusCenter

This commit is contained in:
Micke Prag 2010-06-16 15:23:30 +00:00
parent 5dffca3b3b
commit 4d069179ec
7 changed files with 38 additions and 5 deletions

View file

@ -12,7 +12,7 @@ inline double round(double x) {
}
#endif
const int SUPPORTED_METHODS = TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_BELL /* | TELLSTICK_DIM */ | TELLSTICK_LEARN;
const int SUPPORTED_METHODS = TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_BELL | TELLSTICK_DIM | TELLSTICK_LEARN;
DeviceModel::DeviceModel(QObject *parent)

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -5,19 +5,25 @@
#include <QHBoxLayout>
#include <QToolButton>
#include <QVariant>
#include <QDebug>
class MethodWidget::PrivateData {
public:
Device *device;
QToolButton *turnOff, *turnOn, *bell, *learn;
QToolButton *turnOff, *turnOn, *bell, *learn,
*dim25, *dim50, *dim75;
};
MethodWidget::MethodWidget( Device *device, QWidget *parent )
:QWidget(parent)
{
d = new PrivateData;
d->device = device;
d->turnOff = new QToolButton( this );
d->dim25 = new QToolButton( this );
d->dim50 = new QToolButton( this );
d->dim75 = new QToolButton( this );
d->turnOn = new QToolButton( this );
d->bell = new QToolButton( this );
d->learn = new QToolButton( this );
@ -31,6 +37,19 @@ MethodWidget::MethodWidget( Device *device, QWidget *parent )
d->turnOff->setVisible( false );
layout->addWidget( d->turnOff );
d->dim25->setIcon( QIcon(":/images/state_dimmed_25.png") );
d->dim50->setIcon( QIcon(":/images/state_dimmed_50.png") );
d->dim75->setIcon( QIcon(":/images/state_dimmed_75.png") );
d->dim25->setProperty("dimvalue", 64);
d->dim50->setProperty("dimvalue", 128);
d->dim75->setProperty("dimvalue", 192);
d->dim25->setVisible( false );
d->dim50->setVisible( false );
d->dim75->setVisible( false );
layout->addWidget( d->dim25 );
layout->addWidget( d->dim50 );
layout->addWidget( d->dim75 );
d->turnOn->setIcon( QIcon(":/images/state_1.png") );
d->turnOn->setVisible( false );
layout->addWidget( d->turnOn );
@ -49,6 +68,9 @@ MethodWidget::MethodWidget( Device *device, QWidget *parent )
connect(device, SIGNAL(methodsChanged(int)), this, SLOT(updateMethods(int)));
connect(d->turnOff, SIGNAL(clicked()), device, SLOT(turnOff()));
connect(d->dim25, SIGNAL(clicked()), this, SLOT(dim()));
connect(d->dim50, SIGNAL(clicked()), this, SLOT(dim()));
connect(d->dim75, SIGNAL(clicked()), this, SLOT(dim()));
connect(d->turnOn, SIGNAL(clicked()), device, SLOT(turnOn()));
connect(d->bell, SIGNAL(clicked()), device, SLOT(bell()));
connect(d->learn, SIGNAL(clicked()), device, SLOT(learn()));
@ -62,11 +84,18 @@ MethodWidget::~MethodWidget() {
void MethodWidget::updateMethods(int newMethods) {
d->turnOff->setVisible( newMethods & TELLSTICK_TURNOFF );
d->dim25->setVisible( newMethods & TELLSTICK_DIM );
d->dim50->setVisible( newMethods & TELLSTICK_DIM );
d->dim75->setVisible( newMethods & TELLSTICK_DIM );
d->turnOn->setVisible( newMethods & TELLSTICK_TURNON );
d->bell->setVisible( newMethods & TELLSTICK_BELL );
d->learn->setVisible( newMethods & TELLSTICK_LEARN );
if (newMethods == 0) {
qDebug() << "Methods: " << newMethods;
}
}
void MethodWidget::dim() {
QObject *o = qobject_cast<QObject *>(sender());
if (!o) {
return;
}
d->device->dim(o->property("dimvalue").toChar().toAscii());
}

View file

@ -14,6 +14,7 @@ public:
private slots:
void updateMethods(int newMethods);
void dim();
private:
class PrivateData;

View file

@ -7,5 +7,8 @@
<file>images/state_1.png</file>
<file>images/state_2.png</file>
<file>images/state_16.png</file>
<file>images/state_dimmed_25.png</file>
<file>images/state_dimmed_50.png</file>
<file>images/state_dimmed_75.png</file>
</qresource>
</RCC>