The attached patch applies to the directory kdebase/workspace/plasma/applets/system-monitor of trunk.
This patch adds functionality to the Plasma Applet System Monitor - Network so that It gives the user an option to display the interface name and instantaneous traffic above the respective interface's graph. This is useful as not having a title takes away meaning from any graph. The user can enable or disable this feature using the Settings Dialog. Please note that I've tested the build successfully against the latest SVN trunk build of kdebase, with the exception of kdebase/workspace/plasma/dataengines/systemmonitor/systemmonitor.cpp which I used as of revision 926166 . Because after this revision, systemmonitor.cpp is causing even the original applet to crash. -- Shantanu Tushar http://www.shantanutushar.com
Index: net-config.ui =================================================================== --- net-config.ui (revision 928407) +++ net-config.ui (working copy) @@ -1,7 +1,8 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>config</class> - <widget class="QWidget" name="config" > - <property name="geometry" > + <widget class="QWidget" name="config"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> @@ -9,54 +10,61 @@ <height>263</height> </rect> </property> - <property name="styleSheet" > - <string notr="true" /> + <property name="styleSheet"> + <string notr="true"/> </property> - <layout class="QVBoxLayout" > - <property name="margin" > + <layout class="QVBoxLayout"> + <property name="margin"> <number>0</number> </property> <item> - <widget class="QLabel" name="label" > - <property name="text" > + <widget class="QLabel" name="label"> + <property name="text"> <string>&Network Interfaces:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>treeView</cstring> </property> </widget> </item> <item> - <widget class="QTreeView" name="treeView" > - <property name="rootIsDecorated" > + <widget class="QTreeView" name="treeView"> + <property name="rootIsDecorated"> <bool>false</bool> </property> - <property name="uniformRowHeights" > + <property name="uniformRowHeights"> <bool>true</bool> </property> - <property name="sortingEnabled" > + <property name="sortingEnabled"> <bool>true</bool> </property> </widget> </item> <item> - <layout class="QHBoxLayout" > + <widget class="QCheckBox" name="showTopBarCheckBox"> + <property name="text"> + <string>Show Interface Name Above The Graph</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> <item> - <widget class="QLabel" name="label_2" > - <property name="text" > + <widget class="QLabel" name="label_2"> + <property name="text"> <string>Update &interval:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>intervalSpinBox</cstring> </property> </widget> </item> <item> <spacer> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>40</width> <height>20</height> @@ -65,14 +73,14 @@ </spacer> </item> <item> - <widget class="QSpinBox" name="intervalSpinBox" > - <property name="minimum" > + <widget class="QSpinBox" name="intervalSpinBox"> + <property name="minimum"> <number>1</number> </property> - <property name="maximum" > + <property name="maximum"> <number>525600</number> </property> - <property name="value" > + <property name="value"> <number>2</number> </property> </widget> Index: net.cpp =================================================================== --- net.cpp (revision 928407) +++ net.cpp (working copy) @@ -41,6 +41,7 @@ KConfigGroup cg = config(); setEngine(dataEngine("systemmonitor")); setInterval(cg.readEntry("interval", 2) * 1000); + setShowTopBar(cg.readEntry("showTopBar", false)); setTitle(i18n("Network")); if (engine()->sources().count() == 0) { connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(initLater(const QString))); @@ -90,7 +91,7 @@ plotter->setUseAutoRange(true); plotter->setThinFrame(false); plotter->setShowLabels(false); - plotter->setShowTopBar(false); + plotter->setShowTopBar(m_showTopBar); plotter->setShowVerticalLines(false); plotter->setShowHorizontalLines(false); plotter->setStackPlots(true); @@ -167,6 +168,7 @@ ui.treeView->resizeColumnToContents(0); ui.intervalSpinBox->setValue(interval() / 1000); updateSpinBoxSuffix(interval() / 1000); + ui.showTopBarCheckBox->setChecked( m_showTopBar ); parent->addPage(widget, i18n("Interfaces"), "network-workgroup"); connect(ui.intervalSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateSpinBoxSuffix(int))); @@ -199,6 +201,11 @@ cg.writeEntry("interval", interval); interval *= 1000; setInterval(interval); + bool showTopBar = ui.showTopBarCheckBox->isChecked(); + + cg.writeEntry("showTopBar", showTopBar); + setShowTopBar( showTopBar ); + emit configNeedsSaving(); connectToEngine(); } Index: net.h =================================================================== --- net.h (revision 928407) +++ net.h (working copy) @@ -39,6 +39,7 @@ virtual bool addMeter(const QString&); virtual void createConfigurationInterface(KConfigDialog *parent); virtual void setDetail(Detail detail); + void setShowTopBar( bool value ) { m_showTopBar = value; } public slots: void configAccepted(); @@ -51,6 +52,7 @@ QStandardItemModel m_model; QStringList m_interfaces; QMap<QString, QList<double> > m_data; + bool m_showTopBar; private slots: void parseSources();
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel