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 @@ - + + config - - + + 0 0 @@ -9,54 +10,54 @@ 263 - - + + - - + + 0 - - + + &Network Interfaces: - + treeView - - + + false - + true - + true - + - - + + Update &interval: - + intervalSpinBox - + Qt::Horizontal - + 40 20 @@ -65,14 +66,14 @@ - - + + 1 - + 525600 - + 2 --- 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() << 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 #include @@ -48,14 +49,19 @@ private: Ui::config ui; + Ui::configAdv uiAdv; QStandardItemModel m_model; QStringList m_interfaces; QMap > 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); }; }