From 88aa47a2a565b73e9f106c813b302b99f1c4e046 Mon Sep 17 00:00:00 2001 From: Marcus Birkin Date: Tue, 19 May 2020 09:03:11 +0100 Subject: [PATCH] Move and colourise online column in universe view --- src/universeview.cpp | 22 ++++++++++++---------- src/universeview.h | 2 +- ui/universeview.ui | 10 +++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/universeview.cpp b/src/universeview.cpp index f8e13b95..801a3bb1 100644 --- a/src/universeview.cpp +++ b/src/universeview.cpp @@ -26,13 +26,6 @@ #include -QString onlineToString(bool value) -{ - if(value) - return QObject::tr("Online"); - return QObject::tr("Offline"); -} - QString protocolVerToString(int value) { switch(value) @@ -171,11 +164,20 @@ void UniverseView::sourceChanged(sACNSource *source) ui->twSources->cellWidget(row,COL_JUMPS)->layout()->itemAt(0)->widget()); lbl_SEQ_ERR->setText(QString::number(source->jumps)); } - if (source->doing_dmx) { - ui->twSources->item(row,COL_ONLINE)->setText(onlineToString(source->src_valid)); + + if (source->src_valid) { + if (source->doing_dmx) { + ui->twSources->item(row,COL_ONLINE)->setBackgroundColor(Qt::green); + ui->twSources->item(row,COL_ONLINE)->setText(tr("Online")); + } else { + ui->twSources->item(row,COL_ONLINE)->setBackgroundColor(Qt::yellow); + ui->twSources->item(row,COL_ONLINE)->setText(tr("No DMX")); + } } else { - ui->twSources->item(row,COL_ONLINE)->setText(source->src_valid ? tr("No DMX") : onlineToString(source->src_valid)); + ui->twSources->item(row,COL_ONLINE)->setBackgroundColor(Qt::red); + ui->twSources->item(row,COL_ONLINE)->setText(tr("Offline")); } + ui->twSources->item(row,COL_VER)->setText(protocolVerToString(source->protocol_version)); ui->twSources->item(row,COL_DD)->setText(source->doing_per_channel ? tr("Yes") : tr("No")); ui->twSources->item(row,COL_SLOTS)->setText(QString::number(source->slot_count)); diff --git a/src/universeview.h b/src/universeview.h index 338af926..f05ed789 100644 --- a/src/universeview.h +++ b/src/universeview.h @@ -57,6 +57,7 @@ protected slots: enum m_SC_ROWS { COL_NAME, + COL_ONLINE, COL_CID, COL_PRIO, COL_SYNC, @@ -65,7 +66,6 @@ protected slots: COL_FPS, COL_SEQ_ERR, COL_JUMPS, - COL_ONLINE, COL_VER, COL_DD, COL_SLOTS, diff --git a/ui/universeview.ui b/ui/universeview.ui index cb602fee..f7e02b91 100644 --- a/ui/universeview.ui +++ b/ui/universeview.ui @@ -228,6 +228,11 @@ Name + + + + Online + @@ -269,11 +274,6 @@ Jumps - - - Online - - Ver