Commit 90f860ce authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

added myled and mytextbox

parent 165aeea6
#include "myled.h"
#include <qustring.h>
#include <cudata.h>
void MyLed::onUpdate(const CuData &da) {
QString vs = "-";
if(da.B("err") || !da.containsKey("value"))
QuLedBase::setBorderColor(Qt::red);
else {
QuLedBase::setBorderColor(Qt::darkGreen);
vs = QuString(da, "value");
bool ok;
if(vs.toInt(&ok) == 0 && ok)
QuLedBase::setColor(QColor(Qt::green));
else
QuLedBase::setColor(QColor(Qt::red));
}
const QString& tt = "[ " + vs + " ]\n" + QuString(da, "msg");
setToolTip(tt);
}
#ifndef MYLED_H
#define MYLED_H
#include <quled.h>
class MyLed : public QuLed {
Q_OBJECT
public:
MyLed(QWidget *parent, CumbiaPool *cup, const CuControlsFactoryPool& fp) : QuLed(parent, cup, fp) {}
void onUpdate(const CuData&);
};
#endif // MYLED_H
#include "mytextbox.h"
#include <quwatcher.h>
void MyTextBox::setSource(const QString &s)
{
QuWatcher *w = new QuWatcher(this, cu_p, m_fpool);
connect(w, SIGNAL(newData(CuData)), this, SLOT(onUpdate(CuData)));
w->setSource(s);
}
void MyTextBox::onUpdate(const CuData &da) {
setDisabled(da.B("err"));
if(isEnabled() && da.containsKey("value")) {
setPlainText(da.s("value").c_str());
}
}
#ifndef MYTEXTBOX_H
#define MYTEXTBOX_H
#include <QPlainTextEdit>
#include <cucontrolsfactorypool.h>
class CumbiaPool;
class CuControlsFactoryPool;
class QString;
class CuData;
class MyTextBox : public QPlainTextEdit {
Q_OBJECT
public:
MyTextBox(QWidget *parent, CumbiaPool *cup, const CuControlsFactoryPool& fp) : QPlainTextEdit(parent),
cu_p(cup), m_fpool(fp) {
}
void setSource(const QString & s);
public slots:
void onUpdate(const CuData& da);
private:
CumbiaPool *cu_p;
CuControlsFactoryPool m_fpool;
};
#endif // MYTEXTBOX_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment