UX: Change port name color if local config is changed

Although the applyHint is also changed in this case, the applyHint is
visible only when the port is selected. Having the port name in a
different color is a visual hint to the user that Apply is pending
This commit is contained in:
Srivats P 2017-09-16 12:12:43 +05:30
parent 3aa44343f0
commit db77563466
6 changed files with 20 additions and 9 deletions

View File

@ -107,7 +107,7 @@ void Port::setDirty(bool dirty)
return; return;
dirty_ = dirty; dirty_ = dirty;
emit localConfigChanged(dirty_); emit localConfigChanged(mPortGroupId, mPortId, dirty_);
} }
void Port::recalculateAverageRates() void Port::recalculateAverageRates()

View File

@ -238,7 +238,7 @@ signals:
//! Used when local config changed //! Used when local config changed
//@{ //@{
void streamListChanged(int portGroupId, int portId); void streamListChanged(int portGroupId, int portId);
void localConfigChanged(bool changed); void localConfigChanged(int portGroupId, int portId, bool changed);
//@} //@}
}; };

View File

@ -347,6 +347,8 @@ void PortGroup::processPortIdList(PbRpcController *controller)
p = new Port(portIdList->port_id(i).id(), mPortGroupId); p = new Port(portIdList->port_id(i).id(), mPortGroupId);
connect(p, SIGNAL(portDataChanged(int, int)), connect(p, SIGNAL(portDataChanged(int, int)),
this, SIGNAL(portGroupDataChanged(int, int))); this, SIGNAL(portGroupDataChanged(int, int)));
connect(p, SIGNAL(localConfigChanged(int, int, bool)),
this, SIGNAL(portGroupDataChanged(int, int)));
qDebug("before port append\n"); qDebug("before port append\n");
mPorts.append(p); mPorts.append(p);
atConnectPortConfig_.append(NULL); // will be filled later atConnectPortConfig_.append(NULL); // will be filled later

View File

@ -187,6 +187,10 @@ QVariant PortModel::data(const QModelIndex &index, int role) const
{ {
return portIconFactory[port->linkState()][port->hasExclusiveControl()]; return portIconFactory[port->linkState()][port->hasExclusiveControl()];
} }
else if ((role == Qt::ForegroundRole))
{
return port->isDirty() ? QBrush(Qt::red) : QVariant();
}
else else
{ {
DBG0("Exit PortModel data 6\n"); DBG0("Exit PortModel data 6\n");

View File

@ -345,8 +345,10 @@ void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
{ {
disconnect(&(plm->port(previous)), SIGNAL(portRateChanged(int, int)), disconnect(&(plm->port(previous)), SIGNAL(portRateChanged(int, int)),
this, SLOT(updatePortRates())); this, SLOT(updatePortRates()));
disconnect(&(plm->port(previous)), SIGNAL(localConfigChanged(bool)), disconnect(&(plm->port(previous)),
this, SLOT(updateApplyHint(bool))); SIGNAL(localConfigChanged(int, int, bool)),
this,
SLOT(updateApplyHint(int, int, bool)));
} }
if (!current.isValid()) if (!current.isValid())
@ -366,10 +368,12 @@ void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
updatePortRates(); updatePortRates();
connect(&(plm->port(current)), SIGNAL(portRateChanged(int, int)), connect(&(plm->port(current)), SIGNAL(portRateChanged(int, int)),
SLOT(updatePortRates())); SLOT(updatePortRates()));
connect(&(plm->port(current)), SIGNAL(localConfigChanged(bool)), connect(&(plm->port(current)),
SLOT(updateApplyHint(bool))); SIGNAL(localConfigChanged(int, int, bool)),
SLOT(updateApplyHint(int, int, bool)));
if (plm->port(current).isDirty()) if (plm->port(current).isDirty())
updateApplyHint(true); updateApplyHint(plm->port(current).portGroupId(),
plm->port(current).id(), true);
else if (plm->port(current).numStreams()) else if (plm->port(current).numStreams())
applyHint->setText("Use the Statistics window to transmit " applyHint->setText("Use the Statistics window to transmit "
"packets"); "packets");
@ -522,7 +526,8 @@ void PortsWindow::updateStreamViewActions()
actionSave_Streams->setEnabled(tvStreamList->model()->rowCount() > 0); actionSave_Streams->setEnabled(tvStreamList->model()->rowCount() > 0);
} }
void PortsWindow::updateApplyHint(bool configChanged) void PortsWindow::updateApplyHint(int /*portGroupId*/, int /*portId*/,
bool configChanged)
{ {
if (configChanged) if (configChanged)
applyHint->setText("Configuration has changed - <b>click Apply</b> " applyHint->setText("Configuration has changed - <b>click Apply</b> "

View File

@ -66,7 +66,7 @@ public slots:
void showMyReservedPortsOnly(bool enabled); void showMyReservedPortsOnly(bool enabled);
private slots: private slots:
void updateApplyHint(bool configChanged); void updateApplyHint(int portGroupId, int portId, bool configChanged);
void updatePortViewActions(const QModelIndex& currentIndex); void updatePortViewActions(const QModelIndex& currentIndex);
void updateStreamViewActions(); void updateStreamViewActions();