Skip to content

Commit

Permalink
Merge pull request #174 from docsteer/overall_snapshot_ind
Browse files Browse the repository at this point in the history
Add overall Snapshot match indicator
  • Loading branch information
docsteer authored Dec 16, 2018
2 parents cc3b498 + f59d652 commit be788ac
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/clssnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,14 @@ void clsSnapshot::levelsChanged()

if ((background == m_levelData) != m_backgroundMatches)
{
m_backgroundMatches = (background == m_levelData);

if (background == m_levelData)
emit snapshotMatches();
else
emit snapshotDiffers();
}

m_backgroundMatches = (background == m_levelData);
updateIcons();
}

2 changes: 2 additions & 0 deletions src/clssnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class clsSnapshot : public QWidget
QSpinBox *getSbPriority() {return m_sbPriority;}
QWidget *getControlWidget() {return m_controlWidget;}

bool isMatching() const {return m_backgroundMatches;}

enum e_icons {
ICON_NONE,
ICON_PLAY,
Expand Down
2 changes: 1 addition & 1 deletion src/gridwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
GridWidget::GridWidget(QWidget *parent)
: QWidget(parent)
, m_selectedAddress(-1)
, m_colors(CELL_COUNT, Qt::white)
, m_colors(CELL_COUNT, this->palette().color(QPalette::Base))
, m_cellHeight(CELL_HEIGHT)
{
for(int i=0; i<CELL_COUNT; i++)
Expand Down
31 changes: 29 additions & 2 deletions src/snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ void Snapshot::on_btnAddRow_clicked()
connect(snap, SIGNAL(senderStopped()), this, SLOT(senderStopped()));
connect(snap, SIGNAL(senderTimedOut()), this, SLOT(senderTimedOut()));
connect(snap, &clsSnapshot::snapshotTaken, [this]() { ui->btnPlay->setEnabled(true); });
connect(snap, SIGNAL(snapshotMatches()), this, SLOT(snapshotMatches()));
connect(snap, SIGNAL(snapshotDiffers()), this, SLOT(snapshotDiffers()));
connect(snap, SIGNAL(snapshotMatches()), this, SLOT(updateMatchIcon()));
connect(snap, SIGNAL(snapshotDiffers()), this, SLOT(updateMatchIcon()));
ui->tableWidget->setCellWidget(row, COL_BUTTON, snap->getControlWidget());
ui->tableWidget->setCellWidget(row, COL_UNIVERSE, snap->getSbUniverse());
ui->tableWidget->setCellWidget(row, COL_PRIORITY, snap->getSbPriority());
Expand Down Expand Up @@ -159,6 +159,8 @@ void Snapshot::setState(state s)
// Play Button Text and Icon
btnPlay_update();

updateMatchIcon();

switch(s)
{
case stSetup:
Expand Down Expand Up @@ -311,3 +313,28 @@ void Snapshot::on_tableWidget_itemSelectionChanged()
else
ui->btnRemoveRow->setEnabled(false);
}

void Snapshot::updateMatchIcon()
{
if(m_state == stPlayback)
{
bool allmatch = true;
foreach(auto s, m_snapshots)
{
allmatch &= s->isMatching();
}
if(allmatch)
{
ui->lblMatching->setPixmap(QPixmap(":/icons/ledgreen.png"));
ui->lblMatching->setToolTip(tr("All sources <i>match</i> the background levels"));
}
else
{
ui->lblMatching->setPixmap(QPixmap(":/icons/ledred.png"));
ui->lblMatching->setToolTip(tr("Not all sources match the background levels"));
}
}
else {
ui->lblMatching->setPixmap(QPixmap());
}
}
1 change: 1 addition & 0 deletions src/snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected slots:
void senderTimedOut();
void senderStopped();
void senderStarted();
void updateMatchIcon();
protected:
virtual void resizeEvent(QResizeEvent *event);

Expand Down
37 changes: 36 additions & 1 deletion ui/snapshot.ui
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,52 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblMatching">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
Expand Down

0 comments on commit be788ac

Please sign in to comment.