Commit c3277e3d authored by Lamarque Vieira Souza's avatar Lamarque Vieira Souza
Browse files

Add option to show network speed in KB/s or KBits/s in interface details

widget.

BUG: 246327
FIXED-IN: nm09 branch
parent 89ec0858
......@@ -424,18 +424,45 @@ void InterfaceDetailsWidget::updateWidgets()
//kDebug() << s;
//m_traffic->setText(s);
double _r = m_rx.toDouble();
double _t = m_tx.toDouble();
double _r;
double _t;
QString r, t;
if (m_speedUnit == KNetworkManagerServicePrefs::KBits_s) {
_r = m_rx.toInt() << 3;
_t = m_tx.toInt() << 3;
if (_r < 1000) {
m_rxUnit = "KBit/s";
} else if (_r < 1000000) {
m_rxUnit = "MBit/s";
_r /= 1000;
_t /= 1000;
} else {
m_rxUnit = "GBit/s";
_r /= 1000000;
_t /= 1000000;
}
m_txUnit = m_rxUnit;
r = QString("%1 %2").arg(QString::number(_r, 'f', 0), m_rxUnit);
t = QString("%1 %2").arg(QString::number(_t, 'f', 0), m_txUnit);
} else {
_r = m_rx.toDouble();
_t = m_tx.toDouble();
r = KGlobal::locale()->formatByteSize(_r*1024);
r.append("/s");
t = KGlobal::locale()->formatByteSize(_t*1024);
t.append("/s");
}
QList<double> v;
v << _r << _t;
m_trafficPlotter->addSample(v);
m_trafficPlotter->setUnit(m_rxUnit);
//m_trafficPlotter->setTitle(i18nc("traffic, e.g. n KB/s / m KB/s", "%1 %2 %3 %4", m_rx, m_rxUnit, m_tx, m_txUnit));
QString r = KGlobal::locale()->formatByteSize(_r*1024);
r.append("/s");
QString t = KGlobal::locale()->formatByteSize(_t*1024);
t.append("/s");
QString s = i18nc("traffic, e.g. n KB/s\n m KB/s", "%1 %2", r, t);
m_trafficPlotter->setTitle(s);
......@@ -515,6 +542,8 @@ void InterfaceDetailsWidget::handleConnectionStateChange(int new_state, int old_
void InterfaceDetailsWidget::setInterface(Solid::Control::NetworkInterfaceNm09* iface, bool disconnectOld)
{
m_speedUnit = KNetworkManagerServicePrefs::self()->networkSpeedUnit();
if (m_iface == iface) {
return;
}
......
......@@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <Plasma/SignalPlotter>
#include "types.h"
#include "knmserviceprefs.h"
class RemoteActivatable;
class RemoteInterfaceConnection;
......@@ -96,6 +97,7 @@ Q_OBJECT
bool m_updateEnabled;
InterfaceDetails * details;
int m_speedUnit;
private Q_SLOTS:
void resetInterfaceDetails();
......
......@@ -56,7 +56,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "activatablelistwidget.h"
#include "interfacedetailswidget.h"
#include "uiutils.h"
#include "knmserviceprefs.h"
#include "paths.h"
NMPopup::NMPopup(RemoteActivatableList * activatableList, QGraphicsWidget* parent)
......
......@@ -32,6 +32,12 @@
<choice name="TypeNames"/>
</choices>
</entry>
<entry name="NetworkSpeedUnit" type="Enum">
<choices name="NetworkSpeedUnitChoices">
<choice name="KBytes_s"/>
<choice name="KBits_s"/>
</choices>
</entry>
</group>
<group name="SystemTray">
<entry name="IconCount" type="UInt">
......
#ifndef PLASMA_NM_VERSION_H
#define PLASMA_NM_VERSION_H
static const char * plasmaNmVersion = "nm09-20110702";
static const char * plasmaNmVersion = "nm09-20110707";
#endif
......@@ -108,7 +108,38 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="6" column="0">
<widget class="QLabel" name="interfaceDetailsLabel">
<property name="text">
<string>&lt;b&gt;Interface Details&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="networkSpeedLabel">
<property name="text">
<string>Show network speed in:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QComboBox" name="kcfg_NetworkSpeedUnit">
<item>
<property name="text">
<string>KBytes/s</string>
</property>
</item>
<item>
<property name="text">
<string>KBits/s</string>
</property>
</item>
</widget>
</item>
<item row="8" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -121,7 +152,7 @@
</property>
</spacer>
</item>
<item row="7" column="0">
<item row="9" column="0">
<widget class="QLabel" name="lblVersion">
</widget>
</item>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment