[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets/system-monitor
From:       Petri Damstén <petri.damsten () kdemail ! net>
Date:       2009-02-22 9:28:06
Message-ID: 1235294886.910228.32672.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 929812 by pdamsten:

Add advanced config page:
* interface labels; patch by Shantanu Jha
* use background option
* configurable plotter colors

 M  +1 -1      CMakeLists.txt  
 A             net-config-adv.ui  
 M  +25 -24    net-config.ui  
 M  +44 -28    net.cpp  
 M  +7 -1      net.h  


--- trunk/KDE/kdebase/workspace/plasma/applets/system-monitor/CMakeLists.txt \
#929811:929812 @@ -36,7 +36,7 @@
 set(net_SRCS
     net.cpp
 )
-kde4_add_ui_files(net_SRCS net-config.ui)
+kde4_add_ui_files(net_SRCS net-config.ui net-config-adv.ui)
 kde4_add_plugin(plasma_applet_sm_net ${net_SRCS})
 target_link_libraries(plasma_applet_sm_net ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} \
plasma_applet-system-monitor)  
--- trunk/KDE/kdebase/workspace/plasma/applets/system-monitor/net-config.ui \
#929811:929812 @@ -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,54 @@
     <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>&amp;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" >
+    <layout class="QHBoxLayout">
      <item>
-      <widget class="QLabel" name="label_2" >
-       <property name="text" >
+      <widget class="QLabel" name="label_2">
+       <property name="text">
         <string>Update &amp;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 +66,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>
--- trunk/KDE/kdebase/workspace/plasma/applets/system-monitor/net.cpp #929811:929812
@@ -42,6 +42,12 @@
     setEngine(dataEngine("systemmonitor"));
     setInterval(cg.readEntry("interval", 2) * 1000);
     setTitle(i18n("Network"));
+    
+    m_showTopBar = cg.readEntry("showTopBar", true);
+    m_showBackground = cg.readEntry("showBackground", true);
+    m_inColor = cg.readEntry("inColor", QColor("#d2d200"));
+    m_outColor = cg.readEntry("outColor", QColor("#f20000"));
+    
     if (engine()->sources().count() == 0) {
         connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(initLater(const \
QString)));  } else {
@@ -83,14 +89,12 @@
     QString interface = l[2];
     Plasma::Theme* theme = Plasma::Theme::defaultTheme();
     Plasma::SignalPlotter *plotter = new Plasma::SignalPlotter(this);
-    QColor color = theme->color(Plasma::Theme::TextColor);
-    plotter->addPlot(QColor(((color.red() - 128) * 0.65) + 128,
-                            ((color.green() - 128) * 0.65) + 128, 0, \
                color.alpha()));
-    plotter->addPlot(QColor(((color.red() - 128) * 0.90) + 128, 0, 0, \
color.alpha())); +    plotter->addPlot(m_inColor);
+    plotter->addPlot(m_outColor);
     plotter->setUseAutoRange(true);
     plotter->setThinFrame(false);
     plotter->setShowLabels(false);
-    plotter->setShowTopBar(true);
+    plotter->setShowTopBar(m_showTopBar);
     plotter->setShowVerticalLines(false);
     plotter->setShowHorizontalLines(false);
     plotter->setStackPlots(true);
@@ -101,7 +105,12 @@
     plotter->setHorizontalLinesColor(theme->color(Plasma::Theme::HighlightColor));
     plotter->setVerticalLinesColor(theme->color(Plasma::Theme::HighlightColor));
     plotter->setHorizontalLinesCount(4);
-    //plotter->setSvgBackground("widgets/plot-background");
+    if (m_showBackground) {
+        plotter->setSvgBackground("widgets/plot-background");
+    } else {
+        plotter->setSvgBackground(QString());
+        plotter->setBackgroundColor(Qt::transparent);
+    }
     plotter->setTitle(interface);
     plotter->setUnit("KiB/s");
     appendPlotter(interface, plotter);
@@ -114,13 +123,7 @@
 void SM::Net::themeChanged()
 {
     Plasma::Theme* theme = Plasma::Theme::defaultTheme();
-    QColor color = theme->color(Plasma::Theme::TextColor);
     foreach (Plasma::SignalPlotter *plotter, plotters().values()) {
-        plotter->removePlot(1);
-        plotter->removePlot(0);
-        plotter->addPlot(QColor(((color.red() - 128) * 0.65) + 128,
-                                ((color.green() - 128) * 0.65) + 128, 0, \
                color.alpha()));
-        plotter->addPlot(QColor(((color.red() - 128) * 0.90) + 128, 0, 0, \
                color.alpha()));
         plotter->setFontColor(theme->color(Plasma::Theme::HighlightColor));
         plotter->setHorizontalLinesColor(theme->color(Plasma::Theme::HighlightColor));
                
         plotter->setVerticalLinesColor(theme->color(Plasma::Theme::HighlightColor));
@@ -145,14 +148,13 @@
 
 void SM::Net::createConfigurationInterface(KConfigDialog *parent)
 {
-   QWidget *widget = new QWidget();
-   ui.setupUi(widget);
-   m_model.clear();
-   m_model.setHorizontalHeaderLabels(QStringList() << i18n("Network interface"));
-   QStandardItem *parentItem = m_model.invisibleRootItem();
+    QWidget *widget = new QWidget();
+    ui.setupUi(widget);
+    m_model.clear();
+    m_model.setHorizontalHeaderLabels(QStringList() << i18n("Network interface"));
+    QStandardItem *parentItem = m_model.invisibleRootItem();
 
-
-   foreach (const QString& interface, m_interfaces) {
+    foreach (const QString& interface, m_interfaces) {
         QString ifname = interface.split('/')[2];
         QStandardItem *item1 = new QStandardItem(ifname);
         item1->setEditable(false);
@@ -162,16 +164,24 @@
             item1->setCheckState(Qt::Checked);
         }
         parentItem->appendRow(QList<QStandardItem *>() << item1);
-   }
-   ui.treeView->setModel(&m_model);
-   ui.treeView->resizeColumnToContents(0);
-   ui.intervalSpinBox->setValue(interval() / 1000);
-   updateSpinBoxSuffix(interval() / 1000);
+    }
+    ui.treeView->setModel(&m_model);
+    ui.treeView->resizeColumnToContents(0);
+    ui.intervalSpinBox->setValue(interval() / 1000);
+    updateSpinBoxSuffix(interval() / 1000);
+    connect(ui.intervalSpinBox, SIGNAL(valueChanged(int)), this, \
SLOT(updateSpinBoxSuffix(int))); +    parent->addPage(widget, i18n("Interfaces"), \
"network-workgroup");  
-   parent->addPage(widget, i18n("Interfaces"), "network-workgroup");
-   connect(ui.intervalSpinBox, SIGNAL(valueChanged(int)), this, \
                SLOT(updateSpinBoxSuffix(int)));
-   connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
-   connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
+    widget = new QWidget();
+    uiAdv.setupUi(widget);
+    uiAdv.showTopBarCheckBox->setChecked(m_showTopBar);
+    uiAdv.showBackgroundCheckBox->setChecked(m_showBackground);
+    uiAdv.inColorCombo->setColor(m_inColor);
+    uiAdv.outColorCombo->setColor(m_outColor);
+    parent->addPage(widget, i18n("Advanced"), "preferences-other");
+
+    connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
+    connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
 }
 
 void SM::Net::updateSpinBoxSuffix(int interval)                                      \
 @@ -199,6 +209,12 @@
     cg.writeEntry("interval", interval);
     interval *= 1000;
     setInterval(interval);
+    
+    cg.writeEntry("showTopBar", m_showTopBar = \
uiAdv.showTopBarCheckBox->isChecked()); +    cg.writeEntry("showBackground", \
m_showBackground = uiAdv.showBackgroundCheckBox->isChecked()); +    \
cg.writeEntry("inColor", m_inColor = uiAdv.inColorCombo->color()); +    \
cg.writeEntry("outColor", m_outColor = uiAdv.outColorCombo->color()); +
     emit configNeedsSaving();
     connectToEngine();
 }
--- trunk/KDE/kdebase/workspace/plasma/applets/system-monitor/net.h #929811:929812
@@ -20,6 +20,7 @@
 #define NET_HEADER
 
 #include "ui_net-config.h"
+#include "ui_net-config-adv.h"
 #include "applet.h"
 #include <Plasma/DataEngine>
 #include <QStandardItemModel>
@@ -48,14 +49,19 @@
 
     private:
        Ui::config ui;
+       Ui::configAdv uiAdv;
        QStandardItemModel m_model;
        QStringList m_interfaces;
        QMap<QString, QList<double> > m_data;
+       bool m_showTopBar;
+       bool m_showBackground;
+       QColor m_inColor;
+       QColor m_outColor;
 
     private slots:
         void parseSources();
         void themeChanged();
-	void updateSpinBoxSuffix(int interval);
+        void updateSpinBoxSuffix(int interval);
 };
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic