some changes
This commit is contained in:
parent
fb7063de2c
commit
67ee3963a6
4 changed files with 45 additions and 6 deletions
|
@ -96,9 +96,16 @@ void OmobiDisplayBackend::DataHandler(QString s){
|
|||
};
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
texts.append(text);
|
||||
}
|
||||
|
@ -120,6 +127,12 @@ void OmobiDisplayBackend::handleDisplayTextModelDataChanged() {
|
|||
QVariantHash textMap;
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
|
@ -128,6 +141,8 @@ void OmobiDisplayBackend::handleDisplayTextModelDataChanged() {
|
|||
|
||||
QJsonDocument doc = QJsonDocument::fromVariant(textList);
|
||||
|
||||
qDebug() << doc.toJson(QJsonDocument::Indented);
|
||||
|
||||
this->ble->sendData("SET_TEXTS:" + doc.toJson(QJsonDocument::Compact));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,16 @@ public:
|
|||
};
|
||||
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:
|
||||
OmobiDisplayAppState state;
|
||||
QBluetoothLeUart *ble;
|
||||
|
|
|
@ -47,6 +47,11 @@ void OmobiDisplayTextModel::append(
|
|||
unsigned int scrollSpeed,
|
||||
unsigned int scrollCount
|
||||
) {
|
||||
|
||||
// the current Maximum is 5
|
||||
if(this->texts.length() >= 5)
|
||||
return;
|
||||
|
||||
QMap<int, QVariant> roles = {
|
||||
{ TextRole, text },
|
||||
{ ActiveRole, active },
|
||||
|
|
|
@ -12,7 +12,7 @@ class OmobiDisplayTextModel : public QAbstractListModel
|
|||
public:
|
||||
friend class OmobiDisplayBackend;
|
||||
|
||||
enum QBluetoothLeUartDeviceModelRole {
|
||||
enum OmobiDisplayTextModelRole {
|
||||
TextRole = Qt::DisplayRole,
|
||||
ActiveRole,
|
||||
RuntimeRole,
|
||||
|
@ -23,7 +23,16 @@ public:
|
|||
ScrollCountRole,
|
||||
IndexRole
|
||||
};
|
||||
Q_ENUM(QBluetoothLeUartDeviceModelRole)
|
||||
Q_ENUM(OmobiDisplayTextModelRole)
|
||||
|
||||
|
||||
enum text_align_t
|
||||
{
|
||||
AlignLeft,
|
||||
AlignCenter,
|
||||
AlignRignt
|
||||
};
|
||||
|
||||
|
||||
int rowCount(const QModelIndex & = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
|
Loading…
Reference in a new issue