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;
dirty_ = dirty;
emit localConfigChanged(dirty_);
emit localConfigChanged(mPortGroupId, mPortId, dirty_);
}
void Port::recalculateAverageRates()

View File

@ -238,7 +238,7 @@ signals:
//! Used when local config changed
//@{
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);
connect(p, SIGNAL(portDataChanged(int, int)),
this, SIGNAL(portGroupDataChanged(int, int)));
connect(p, SIGNAL(localConfigChanged(int, int, bool)),
this, SIGNAL(portGroupDataChanged(int, int)));
qDebug("before port append\n");
mPorts.append(p);
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()];
}
else if ((role == Qt::ForegroundRole))
{
return port->isDirty() ? QBrush(Qt::red) : QVariant();
}
else
{
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)),
this, SLOT(updatePortRates()));
disconnect(&(plm->port(previous)), SIGNAL(localConfigChanged(bool)),
this, SLOT(updateApplyHint(bool)));
disconnect(&(plm->port(previous)),
SIGNAL(localConfigChanged(int, int, bool)),
this,
SLOT(updateApplyHint(int, int, bool)));
}
if (!current.isValid())
@ -366,10 +368,12 @@ void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
updatePortRates();
connect(&(plm->port(current)), SIGNAL(portRateChanged(int, int)),
SLOT(updatePortRates()));
connect(&(plm->port(current)), SIGNAL(localConfigChanged(bool)),
SLOT(updateApplyHint(bool)));
connect(&(plm->port(current)),
SIGNAL(localConfigChanged(int, int, bool)),
SLOT(updateApplyHint(int, int, bool)));
if (plm->port(current).isDirty())
updateApplyHint(true);
updateApplyHint(plm->port(current).portGroupId(),
plm->port(current).id(), true);
else if (plm->port(current).numStreams())
applyHint->setText("Use the Statistics window to transmit "
"packets");
@ -522,7 +526,8 @@ void PortsWindow::updateStreamViewActions()
actionSave_Streams->setEnabled(tvStreamList->model()->rowCount() > 0);
}
void PortsWindow::updateApplyHint(bool configChanged)
void PortsWindow::updateApplyHint(int /*portGroupId*/, int /*portId*/,
bool configChanged)
{
if (configChanged)
applyHint->setText("Configuration has changed - <b>click Apply</b> "

View File

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