From db77563466adc732a447794216613a1b76eee112 Mon Sep 17 00:00:00 2001 From: Srivats P Date: Sat, 16 Sep 2017 12:12:43 +0530 Subject: [PATCH] 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 --- client/port.cpp | 2 +- client/port.h | 2 +- client/portgroup.cpp | 2 ++ client/portmodel.cpp | 4 ++++ client/portswindow.cpp | 17 +++++++++++------ client/portswindow.h | 2 +- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/client/port.cpp b/client/port.cpp index bf245c7..e9da599 100644 --- a/client/port.cpp +++ b/client/port.cpp @@ -107,7 +107,7 @@ void Port::setDirty(bool dirty) return; dirty_ = dirty; - emit localConfigChanged(dirty_); + emit localConfigChanged(mPortGroupId, mPortId, dirty_); } void Port::recalculateAverageRates() diff --git a/client/port.h b/client/port.h index c1141f5..c98b7ec 100644 --- a/client/port.h +++ b/client/port.h @@ -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); //@} }; diff --git a/client/portgroup.cpp b/client/portgroup.cpp index 8ebe1f5..b0af226 100644 --- a/client/portgroup.cpp +++ b/client/portgroup.cpp @@ -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 diff --git a/client/portmodel.cpp b/client/portmodel.cpp index cd1c9d7..e1e0f06 100644 --- a/client/portmodel.cpp +++ b/client/portmodel.cpp @@ -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"); diff --git a/client/portswindow.cpp b/client/portswindow.cpp index 551e438..430352f 100644 --- a/client/portswindow.cpp +++ b/client/portswindow.cpp @@ -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 - click Apply " diff --git a/client/portswindow.h b/client/portswindow.h index e67bcea..f072cc7 100644 --- a/client/portswindow.h +++ b/client/portswindow.h @@ -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();