some changes

This commit is contained in:
Dorian Zedler 2020-10-13 17:00:25 +02:00
parent fb7063de2c
commit 67ee3963a6
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
4 changed files with 45 additions and 6 deletions

View file

@ -96,9 +96,16 @@ void OmobiDisplayBackend::DataHandler(QString s){
}; };
for(QString key : textMap.toMap().keys()) { for(QString key : textMap.toMap().keys()) {
if(keyTranslations.contains(key)) if(keyTranslations.contains(key)) {
if(key == "color") {
QVariantMap colorMap = textMap.toMap()[key].toMap();
QColor color(colorMap["r"].toInt(), colorMap["g"].toInt(), colorMap["b"].toInt());
text.insert(keyTranslations[key], color.name());
}
else
text.insert(keyTranslations[key], textMap.toMap()[key]); text.insert(keyTranslations[key], textMap.toMap()[key]);
} }
}
texts.append(text); texts.append(text);
} }
@ -120,6 +127,12 @@ void OmobiDisplayBackend::handleDisplayTextModelDataChanged() {
QVariantHash textMap; QVariantHash textMap;
for(int key : text.keys()) { for(int key : text.keys()) {
if(key == OmobiDisplayTextModel::ColorRole) {
QColor color = QColor(text[key].toString());
color = color.toRgb();
QVariantMap colorMap = {{"r", color.red()}, {"g", color.green()}, {"b", color.blue()}};
}
else
textMap.insert(this->displayTextModel->roleNames()[key], text[key]); textMap.insert(this->displayTextModel->roleNames()[key], text[key]);
} }
@ -128,6 +141,8 @@ void OmobiDisplayBackend::handleDisplayTextModelDataChanged() {
QJsonDocument doc = QJsonDocument::fromVariant(textList); QJsonDocument doc = QJsonDocument::fromVariant(textList);
qDebug() << doc.toJson(QJsonDocument::Indented);
this->ble->sendData("SET_TEXTS:" + doc.toJson(QJsonDocument::Compact)); this->ble->sendData("SET_TEXTS:" + doc.toJson(QJsonDocument::Compact));
} }

View file

@ -27,6 +27,16 @@ public:
}; };
Q_ENUM(OmobiDisplayAppState) Q_ENUM(OmobiDisplayAppState)
typedef struct text_set_t
{
const char text[5];
uint time_ms;
uint color;
bool text_scroll;
uint text_scroll_pass;
bool active;
} text_set_t;
private: private:
OmobiDisplayAppState state; OmobiDisplayAppState state;
QBluetoothLeUart *ble; QBluetoothLeUart *ble;

View file

@ -47,6 +47,11 @@ void OmobiDisplayTextModel::append(
unsigned int scrollSpeed, unsigned int scrollSpeed,
unsigned int scrollCount unsigned int scrollCount
) { ) {
// the current Maximum is 5
if(this->texts.length() >= 5)
return;
QMap<int, QVariant> roles = { QMap<int, QVariant> roles = {
{ TextRole, text }, { TextRole, text },
{ ActiveRole, active }, { ActiveRole, active },

View file

@ -12,7 +12,7 @@ class OmobiDisplayTextModel : public QAbstractListModel
public: public:
friend class OmobiDisplayBackend; friend class OmobiDisplayBackend;
enum QBluetoothLeUartDeviceModelRole { enum OmobiDisplayTextModelRole {
TextRole = Qt::DisplayRole, TextRole = Qt::DisplayRole,
ActiveRole, ActiveRole,
RuntimeRole, RuntimeRole,
@ -23,7 +23,16 @@ public:
ScrollCountRole, ScrollCountRole,
IndexRole IndexRole
}; };
Q_ENUM(QBluetoothLeUartDeviceModelRole) Q_ENUM(OmobiDisplayTextModelRole)
enum text_align_t
{
AlignLeft,
AlignCenter,
AlignRignt
};
int rowCount(const QModelIndex & = QModelIndex()) const; int rowCount(const QModelIndex & = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;