Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to compare levels between two universes #326

Open
wants to merge 1 commit into
base: 3.0-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,12 @@ QString Preferences::GetUpdateIgnore() const
return settings.value(S_UPDATE_IGNORE, QString()).toString();
}

QString Preferences::GetFormattedValue(unsigned int nLevelInDecimal, bool decorated) const
QString Preferences::GetFormattedValue(int nLevelInDecimal, bool decorated) const
{
// Negative means "none"
if (nLevelInDecimal < 0)
return QStringLiteral("---");

Q_ASSERT(nLevelInDecimal <= 255);

switch (m_nDisplayFormat)
Expand Down
2 changes: 1 addition & 1 deletion src/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Preferences
bool GetRestartPending() const { return m_restartPending; }
void SetRestartPending() { m_restartPending = true; }

QString GetFormattedValue(unsigned int nLevelInDecimal, bool decorated = false) const;
QString GetFormattedValue(int nLevelInDecimal, bool decorated = false) const;

void savePreferences() const;

Expand Down
104 changes: 86 additions & 18 deletions src/ui/universeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ UniverseView::UniverseView(int universe, QWidget *parent) :
connect(univDisplay, &UniverseDisplay::showChannelPriorityChanged, ui->btnShowPriority, &QPushButton::setChecked);

connect(univDisplay, &UniverseDisplay::universeChanged, this, &UniverseView::refreshTitle);
connect(univDisplay, &UniverseDisplay::flickerFinderChanged, this, &UniverseView::refreshTitle);
connect(univDisplay, &UniverseDisplay::flickerFinderChanged, this, &UniverseView::onFlickerFinderChanged);
connect(univDisplay, &UniverseDisplay::compareToUniverseChanged, this, &UniverseView::onCompareUniverseChanged);

ui->btnGo->setEnabled(true);
ui->btnPause->setEnabled(false);
ui->sbUniverse->setMinimum(MIN_SACN_UNIVERSE);
ui->sbUniverse->setMaximum(MAX_SACN_UNIVERSE);
ui->sbUniverse->setRange(MIN_SACN_UNIVERSE, MAX_SACN_UNIVERSE);
ui->sbUniverse->setWrapping(true);
ui->sbUniverse->setEnabled(true);
ui->sbUniverse->setValue(universe);

ui->sbCompareUniverse->setRange(MIN_SACN_UNIVERSE, MAX_SACN_UNIVERSE);
ui->sbCompareUniverse->setWrapping(true);
ui->sbCompareUniverse->setEnabled(true);
ui->sbCompareUniverse->setValue(universe + 1);

m_sourceTableModel = new SACNSourceTableModel(this);
QSortFilterProxyModel* sortProxy = new QSortFilterProxyModel(this);
sortProxy->setSourceModel(m_sourceTableModel);
Expand All @@ -67,6 +70,9 @@ UniverseView::UniverseView(int universe, QWidget *parent) :
ui->tableView->setColumnHidden(SACNSourceTableModel::COL_TIME_SUMMARY, true);
// Maybe don't show the Secure column
ui->tableView->setColumnHidden(SACNSourceTableModel::COL_PATHWAY_SECURE, !Preferences::Instance().GetPathwaySecureRx());

// Not running
updateButtons(false);
}

UniverseView::~UniverseView()
Expand All @@ -76,9 +82,8 @@ UniverseView::~UniverseView()

void UniverseView::startListening(int universe)
{
ui->btnGo->setEnabled(false);
ui->btnPause->setEnabled(true);
ui->sbUniverse->setEnabled(false);
updateButtons(true);

m_listener = sACNManager::Instance().getListener(universe);
connect(m_listener.data(), &sACNListener::listenerStarted, this, &UniverseView::listenerStarted);
checkBind();
Expand All @@ -92,8 +97,10 @@ void UniverseView::startListening(int universe)
connect(m_listener.data(), &sACNListener::sourceChanged, this, &UniverseView::sourceChanged);
connect(m_listener.data(), &sACNListener::levelsChanged, this, &UniverseView::levelsChanged);

if(ui->sbUniverse->value()!=universe)
if (ui->sbUniverse->value() != universe)
ui->sbUniverse->setValue(universe);
if (ui->sbCompareUniverse->value() == universe)
ui->sbCompareUniverse->setValue(universe + 1);
}

void UniverseView::refreshTitle()
Expand All @@ -104,11 +111,13 @@ void UniverseView::refreshTitle()
return;
}

int universe = m_listener->universe();
bool flicker = ui->universeDisplay->getFlickerFinder();
const int universe = m_listener->universe();
const int compareToUniverse = ui->universeDisplay->getCompareToUniverse();

if (flicker)
if (ui->universeDisplay->getFlickerFinder())
setWindowTitle(tr("Universe %1 Flicker").arg(universe));
else if (compareToUniverse != UniverseDisplay::NO_UNIVERSE)
setWindowTitle(tr("Comparing Universe %1 to %2").arg(universe).arg(compareToUniverse));
else
setWindowTitle(tr("Universe %1 View").arg(universe));
}
Expand All @@ -134,13 +143,44 @@ void UniverseView::checkBind()
msgBox.exec();
}

void UniverseView::updateButtons(bool running)
{
// Enable/disable buttons
ui->btnGo->setEnabled(!running);
ui->btnPause->setEnabled(running);
ui->sbUniverse->setEnabled(!running);

ui->btnStartFlickerFinder->setEnabled(running);
ui->btnCompareUniverse->setEnabled(running);
}

void UniverseView::listenerStarted(int universe)
{
Q_UNUSED(universe);

checkBind();
}

void UniverseView::onFlickerFinderChanged()
{
if (ui->universeDisplay->getFlickerFinder())
ui->btnStartFlickerFinder->setText(tr("Stop Flicker Finder"));
else
ui->btnStartFlickerFinder->setText(tr("Start Flicker Finder"));

refreshTitle();
}

void UniverseView::onCompareUniverseChanged()
{
if (ui->universeDisplay->getCompareToUniverse() != UniverseDisplay::NO_UNIVERSE)
ui->btnCompareUniverse->setText(tr("Stop Delta Finder"));
else
ui->btnCompareUniverse->setText(tr("Start Delta Finder"));

refreshTitle();
}

void UniverseView::sourceChanged(sACNSource*/*source*/)
{
// Update select address details
Expand Down Expand Up @@ -271,11 +311,10 @@ void UniverseView::on_btnPause_clicked()
m_sourceTableModel->pause();

this->disconnect(m_listener.data());
ui->btnGo->setEnabled(true);
ui->btnPause->setEnabled(false);
ui->sbUniverse->setEnabled(true);
m_bindWarningShown = false;

updateButtons(false);

m_bindWarningShown = false;

setWindowTitle(tr("Universe View"));
}
Expand All @@ -285,7 +324,6 @@ void UniverseView::on_btnStartFlickerFinder_clicked()
if(ui->universeDisplay->getFlickerFinder())
{
ui->universeDisplay->setFlickerFinder(false);
ui->btnStartFlickerFinder->setText(tr("Start Flicker Finder"));
}
else
{
Expand All @@ -296,10 +334,40 @@ void UniverseView::on_btnStartFlickerFinder_clicked()
if(!result) return;
}
ui->universeDisplay->setFlickerFinder(true);
ui->btnStartFlickerFinder->setText(tr("Stop Flicker Finder"));
}
}

void UniverseView::on_btnCompareUniverse_clicked()
{
if (ui->universeDisplay->getCompareToUniverse() == UniverseDisplay::NO_UNIVERSE)
{
ui->universeDisplay->setCompareToUniverse(ui->sbCompareUniverse->value());
}
else
{
ui->universeDisplay->setCompareToUniverse(UniverseDisplay::NO_UNIVERSE);
}
}

void UniverseView::on_sbCompareUniverse_editingFinished()
{
int val = ui->sbCompareUniverse->value();

// Can't compare to same
const int univ = ui->sbUniverse->value();
if (val == univ)
{
val = univ + 1;
ui->sbCompareUniverse->setValue(val);
}

// Change if active and different
const int currentCompare = ui->universeDisplay->getCompareToUniverse();
if (currentCompare != UniverseDisplay::NO_UNIVERSE && currentCompare != val)
{
ui->universeDisplay->setCompareToUniverse(val);
}
}

void UniverseView::on_btnLogWindow_clicked()
{
Expand Down
7 changes: 7 additions & 0 deletions src/ui/universeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ protected slots:
void selectedAddressesChanged(QList<int> addresses);
void openBigDisplay(quint16 address);
void on_btnStartFlickerFinder_clicked();
void on_btnCompareUniverse_clicked();
void on_sbCompareUniverse_editingFinished();
void on_btnLogWindow_clicked();
void on_btnExportSourceList_clicked();
void listenerStarted(int universe);

void onFlickerFinderChanged();
void onCompareUniverseChanged();

protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void showEvent(QShowEvent *event);
Expand All @@ -65,6 +70,8 @@ protected slots:
bool m_bindWarningShown = false;
void checkBind();

void updateButtons(bool running);

QString prioText(const sACNSource *source, quint8 address) const;

Ui::UniverseView *ui = nullptr;
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/gridwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ void GridWidget::mouseDoubleClickEvent(QMouseEvent *event)
}
}

void GridWidget::setAllCellColor(const QColor& color)
{
m_colors.fill(color);
}

void GridWidget::setCellColor(int cell, const QColor &color)
{
m_colors[cell] = color;
Expand Down
1 change: 1 addition & 0 deletions src/widgets/gridwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class GridWidget : public QWidget
public:
explicit GridWidget(QWidget *parent = Q_NULLPTR);

void setAllCellColor(const QColor& color);
void setCellColor(int cell, const QColor &color);
/**
* @brief setCellValue - sets the value for a cell
Expand Down
Loading
Loading