plasma: reimplement system-monitor applet

what is wrong with the old applet implementation? it uses two
dataengines which by itself is a huge performance penalty. the current
applet implementation is minimal - shows only the system CPU load and
that is about it but I intend to expand upon that

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-01 14:26:58 +03:00
parent 5a9481f9ec
commit 94c44c9b51
59 changed files with 249 additions and 7528 deletions

View file

@ -1,129 +1,26 @@
project(plasma-system-monitor) project(plasma-system-monitor)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} )
# lib set(systemmonitor_SRCS
set(lib_SRCS
monitoricon.cpp
applet.cpp
plotter.cpp
)
add_library(plasma_applet-system-monitor SHARED ${lib_SRCS})
target_link_libraries(plasma_applet-system-monitor
KDE4::plasma
KDE4::kdeui
)
set_target_properties(plasma_applet-system-monitor PROPERTIES
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
generate_export_header(plasma_applet-system-monitor BASE_NAME plasma_applet_system_monitor)
# HDD Space Monitor
set(hdd_SRCS
hdd.cpp
hdd-config.ui
)
kde4_add_plugin(plasma_applet_sm_hdd ${hdd_SRCS})
target_link_libraries(plasma_applet_sm_hdd KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# HDD Activity Monitor
set(hdd_activity_SRCS
hdd_activity.cpp
hdd_activity-config.ui
)
kde4_add_plugin(plasma_applet_sm_hdd_activity ${hdd_activity_SRCS})
target_link_libraries(plasma_applet_sm_hdd_activity KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# Temperature Monitor
set(temparature_SRCS
temperature.cpp
temperature-offset-delegate.cpp
temperature-config.ui
)
kde4_add_plugin(plasma_applet_sm_temperature ${temparature_SRCS})
target_link_libraries(plasma_applet_sm_temperature KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# Network Monitor
set(net_SRCS
net.cpp
net-config.ui
)
kde4_add_plugin(plasma_applet_sm_net ${net_SRCS})
target_link_libraries(plasma_applet_sm_net KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# CPU Monitor
set(cpu_SRCS
cpu.cpp
cpu-config.ui
)
kde4_add_plugin(plasma_applet_sm_cpu ${cpu_SRCS})
target_link_libraries(plasma_applet_sm_cpu KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# Harware Info
set(hwinfo_SRCS
hwinfo.cpp
)
kde4_add_plugin(plasma_applet_sm_hwinfo ${hwinfo_SRCS})
target_link_libraries(plasma_applet_sm_hwinfo KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# Ram Monitor
set(ram_SRCS
ram.cpp
ram-config.ui
)
kde4_add_plugin(plasma_applet_sm_ram ${ram_SRCS})
target_link_libraries(plasma_applet_sm_ram KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# Main applet
set(system-monitor_SRCS
system-monitor.cpp system-monitor.cpp
monitorbutton.cpp
) )
kde4_add_plugin(plasma_applet_system-monitor ${system-monitor_SRCS})
target_link_libraries(plasma_applet_system-monitor KDE4::plasma KDE4::kdeui plasma_applet-system-monitor)
# Install kde4_add_plugin(plasma_applet_system-monitor ${systemmonitor_SRCS})
install( target_link_libraries(plasma_applet_system-monitor
TARGETS plasma_applet-system-monitor KDE4::plasma
DESTINATION ${KDE4_LIB_INSTALL_DIR} KDE4::solid
ksgrd
) )
install( install(
TARGETS TARGETS plasma_applet_system-monitor
plasma_applet_sm_hdd_activity
plasma_applet_sm_hdd
plasma_applet_sm_temperature
plasma_applet_sm_hwinfo
plasma_applet_sm_net
plasma_applet_sm_cpu
plasma_applet_sm_ram
plasma_applet_system-monitor
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
) )
install( install(
FILES FILES plasma-applet-system-monitor.desktop
plasma-applet-sm_hdd_activity.desktop
plasma-applet-sm_hdd.desktop
plasma-applet-sm_temperature.desktop
plasma-applet-sm_hwinfo.desktop
plasma-applet-sm_net.desktop
plasma-applet-sm_cpu.desktop
plasma-applet-sm_ram.desktop
plasma-applet-system-monitor.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR} DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
) )
install( install(
FILES hdd_panel.svgz FILES hdd_panel.svgz
DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/system-monitor/ DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/system-monitor/

View file

@ -1,428 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "applet.h"
#include <math.h>
#include <Plasma/DataEngine>
#include <Plasma/Containment>
#include <Plasma/Frame>
#include <Plasma/IconWidget>
#include <Plasma/ToolTipManager>
#include <KIcon>
#include <KDebug>
#include <QGraphicsLinearLayout>
namespace SM {
Applet::Applet(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args),
m_interval(10000),
m_preferredItemHeight(42),
m_header(0),
m_engine(0),
m_orientation(Qt::Vertical),
m_noSourcesIcon(0),
m_mode(Desktop),
m_mainLayout(0),
m_configSource(0)
{
if (args.count() > 0 && args[0].toString() == "SM") {
m_mode = Monitor;
}
Plasma::ToolTipManager::self()->registerWidget(this);
}
Applet::~Applet()
{
removeLayout();
}
void Applet::constraintsEvent(Plasma::Constraints constraints)
{
if (constraints & Plasma::FormFactorConstraint) {
if (m_mode == Monitor) {
setBackgroundHints(NoBackground);
m_orientation = Qt::Vertical;
} else {
SM::Applet::Mode mode = m_mode;
switch (formFactor()) {
case Plasma::Planar:
case Plasma::MediaCenter:
mode = Desktop;
m_orientation = Qt::Vertical;
break;
case Plasma::Horizontal:
mode = Panel;
m_orientation = Qt::Horizontal;
break;
case Plasma::Vertical:
mode = Panel;
m_orientation = Qt::Vertical;
break;
}
if (mode != m_mode) {
m_mode = mode;
connectToEngine();
}
}
} else if (constraints & Plasma::SizeConstraint) {
checkGeometry();
}
}
void Applet::setTitle(const QString& title)
{
m_title = title;
if (m_header) {
m_header->setText(m_title);
}
}
QGraphicsLinearLayout* Applet::mainLayout()
{
if (!m_mainLayout) {
m_mainLayout = new QGraphicsLinearLayout(m_orientation);
m_mainLayout->setContentsMargins(0, 0, 0, 0);
m_mainLayout->setSpacing(5);
setLayout(m_mainLayout);
}
return m_mainLayout;
}
void Applet::removeLayout()
{
if (!m_mainLayout) {
return;
}
deleteVisualizations();
// reset it to no configuration
// assumes that this only gets called when there's
// > 0 sources.
setConfigurationRequired(false);
delete(m_noSourcesIcon);
m_noSourcesIcon = 0;
delete(m_header);
m_header = 0;
// We delete the layout since it seems to be only way to remove stretch set for some applets.
setLayout(0);
m_mainLayout = 0;
}
void Applet::configureLayout()
{
mainLayout()->setOrientation(m_orientation);
if (m_mode != Panel && !m_header) {
m_header = new Plasma::Frame(this);
m_header->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
m_header->setText(m_title);
mainLayout()->addItem(m_header);
}
}
void Applet::connectToEngine()
{
removeLayout();
configureLayout();
disconnectSources();
if (m_sources.isEmpty()){
displayNoAvailableSources();
constraintsEvent(Plasma::SizeConstraint);
return;
}
foreach (const QString &source, m_sources) {
if (addVisualization(source)) {
connectSource(source);
}
}
mainLayout()->activate();
constraintsEvent(Plasma::SizeConstraint);
}
void Applet::checkGeometry()
{
QSizeF min;
QSizeF pref;
QSizeF max;
int nb_items = 0;
nb_items = m_visualizations.count();
if (nb_items == 0)
nb_items = 1;
if (m_mode != Panel) {
qreal height = 0;
qreal width = MINIMUM;
if (m_header) {
height = m_header->minimumSize().height();
width = m_header->minimumSize().width();
}
min.setHeight(qMax(height + nb_items * MINIMUM,
mainLayout()->minimumSize().height()));
min.setWidth(width + MINIMUM);
pref.setHeight(height + nb_items * m_preferredItemHeight);
pref.setWidth(PREFERRED);
max = QSizeF();
if (m_mode != Monitor) {
min += size() - contentsRect().size();
pref += size() - contentsRect().size();
} else {
// Reset margins
setBackgroundHints(NoBackground);
}
//kDebug() << minSize << m_preferredItemHeight << height
// << m_minimumHeight << metaObject()->className();
setAspectRatioMode(Plasma::IgnoreAspectRatio);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
update();
} else {
int x = 1;
int y = 1;
QSizeF size = containment()->size();
qreal s;
if (m_orientation == Qt::Horizontal) {
x = nb_items;
s = size.height();
} else {
y = nb_items;
s = size.width();
}
min = QSizeF(16 * x, 16 * y);
max = pref = QSizeF(s * x, s * y);
setAspectRatioMode(Plasma::KeepAspectRatio);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
setMinimumSize(min);
setPreferredSize(pref);
setMaximumSize(max);
//kDebug() << min << pref << max << metaObject()->className();
emit geometryChecked();
}
void Applet::connectSource(const QString& source)
{
if (m_engine) {
m_engine->connectSource(source, this, m_interval);
m_connectedSources << source;
}
}
void Applet::disconnectSources()
{
if (m_engine) {
foreach (const QString &source, m_connectedSources) {
m_engine->disconnectSource(source, this);
}
}
m_connectedSources.clear();
}
void Applet::deleteVisualizations()
{
if (!m_mainLayout) {
return;
}
foreach (QWeakPointer<QGraphicsWidget> visualization, m_visualizations) {
delete visualization.data();
}
m_visualizations.clear();
m_toolTips.clear();
}
void Applet::clear()
{
disconnectSources();
removeLayout();
clearSources();
}
void Applet::displayNoAvailableSources()
{
KIcon appletIcon(icon());
m_noSourcesIcon = new Plasma::IconWidget(appletIcon, QString(), this);
mainLayout()->addItem(m_noSourcesIcon);
m_preferredItemHeight = MINIMUM;
setConfigurationRequired(true, i18n("No data sources being displayed"));
}
KConfigGroup Applet::config()
{
if (m_configSource) {
return m_configSource->config();
}
return Plasma::Applet::config();
}
void Applet::save(KConfigGroup &config) const
{
// work around for saveState being protected
if (m_mode != Monitor) {
Plasma::Applet::save(config);
}
}
void Applet::saveConfig(KConfigGroup &config)
{
// work around for saveState being protected
saveState(config);
}
QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (m_mode == Monitor && change == ItemParentHasChanged) {
QGraphicsWidget *parent = parentWidget();
Plasma::Applet *container = 0;
while (parent) {
container = qobject_cast<Plasma::Applet *>(parent);
if (container) {
break;
}
parent = parent->parentWidget();
}
if (container && container != containment()) {
m_configSource = container;
}
}
// We must be able to change position when in monitor even if not mutable
if (m_mode == Monitor && change == ItemPositionChange) {
return QGraphicsWidget::itemChange(change, value);
} else {
return Plasma::Applet::itemChange(change, value);
}
}
void Applet::toolTipAboutToShow()
{
if (mode() == SM::Applet::Panel) {
if (!m_toolTips.isEmpty()) {
QString html = "<table>";
foreach (const QString& s, m_toolTips.values()) {
if (!s.isEmpty()) {
html += s;
}
}
html += "</table>";
Plasma::ToolTipContent data(title(), html);
Plasma::ToolTipManager::self()->setContent(this, data);
} else {
Plasma::ToolTipManager::self()->clearContent(this);
}
}
}
void Applet::appendVisualization(const QString& source, QGraphicsWidget *visualization)
{
if (m_visualizations.contains(source) && m_visualizations.value(source)) {
delete(m_visualizations[source].data());
}
m_visualizations[source] = visualization;
mainLayout()->addItem(visualization);
connect(visualization, SIGNAL(destroyed(QObject*)), this, SLOT(visualizationDestroyed(QObject*)));
}
QGraphicsWidget * Applet::visualization(const QString& source)
{
return m_visualizations[source].data();
}
void Applet::visualizationDestroyed(QObject *visualization)
{
QString key;
QHash<QString, QWeakPointer<QGraphicsWidget> >::const_iterator i;
for (i = m_visualizations.constBegin(); i != m_visualizations.constEnd(); ++i) {
if (i.value().data() == static_cast<QGraphicsWidget *>(visualization)) {
key = i.key();
break;
}
}
if (!key.isEmpty()) {
m_visualizations.remove(key);
}
}
uint Applet::interval()
{
return m_interval;
}
void Applet::setInterval(uint interval)
{
m_interval = interval;
}
QString Applet::title()
{
return m_title;
}
SM::Applet::Mode Applet::mode()
{
return m_mode;
}
void Applet::setToolTip(const QString &source, const QString &tipContent)
{
m_toolTips.insert(source, tipContent);
if (Plasma::ToolTipManager::self()->isVisible(this)) {
toolTipAboutToShow();
}
}
void Applet::setEngine(Plasma::DataEngine* engine)
{
m_engine = engine;
}
Plasma::DataEngine* Applet::engine()
{
return m_engine;
}
bool Applet::addVisualization(const QString&)
{
return false;
}
QStringList Applet::connectedSources()
{
return m_connectedSources;
}
}

View file

@ -1,115 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SM_APPLET_HEADER
#define SM_APPLET_HEADER
#include <Plasma/Applet>
#include "plasma_applet_system_monitor_export.h"
#define MINIMUM 24
#define PREFERRED 200
#include <QGraphicsLinearLayout>
#include <QGraphicsWidget>
namespace Plasma {
class Frame;
class IconWidget;
}
namespace SM {
class PLASMA_APPLET_SYSTEM_MONITOR_EXPORT Applet : public Plasma::Applet
{
Q_OBJECT
public:
enum Mode { Monitor, Panel, Desktop };
enum Detail { High, Low };
Applet(QObject *parent, const QVariantList &args);
~Applet();
virtual void constraintsEvent(Plasma::Constraints constraints);
void save(KConfigGroup &config) const;
void saveConfig(KConfigGroup &config);
public Q_SLOTS:
void toolTipAboutToShow();
void visualizationDestroyed(QObject *visualization);
Q_SIGNALS:
void geometryChecked();
protected:
qreal preferredItemHeight() { return m_preferredItemHeight; };
void setPreferredItemHeight(qreal preferredItemHeight)
{ m_preferredItemHeight = preferredItemHeight; };
QStringList sources() { return m_sources; };
void appendSource(const QString& source) { m_sources.append(source); };
void setSources(const QStringList& sources) { m_sources = sources; };
void clearSources() { m_sources.clear(); };
void clear();
KConfigGroup config();
void configureLayout();
void removeLayout();
void connectToEngine();
void connectSource(const QString& source);
QStringList connectedSources();
void disconnectSources();
void checkGeometry();
QGraphicsLinearLayout* mainLayout();
Plasma::DataEngine* engine();
void setEngine(Plasma::DataEngine* engine);
uint interval();
void setInterval(uint interval);
QString title();
void setTitle(const QString& title);
QHash<QString, QString> tooltips() const;
void setToolTip(const QString &source, const QString &tipContent);
Mode mode();
QGraphicsWidget* visualization(const QString& source);
virtual bool addVisualization(const QString& source);
void appendVisualization(const QString& source, QGraphicsWidget *visualization);
virtual void deleteVisualizations();
void displayNoAvailableSources();
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
uint m_interval;
qreal m_preferredItemHeight;
QString m_title;
Plasma::Frame* m_header;
QStringList m_sources;
QStringList m_connectedSources;
Plasma::DataEngine *m_engine;
QHash<QString, QWeakPointer<QGraphicsWidget> > m_visualizations;
QHash<QString, QString> m_toolTips;
Qt::Orientation m_orientation;
Plasma::IconWidget *m_noSourcesIcon;
Mode m_mode;
QGraphicsLinearLayout *m_mainLayout;
Plasma::Applet *m_configSource;
};
}
#endif

View file

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>config</class>
<widget class="QWidget" name="config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>263</height>
</rect>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;CPUs:</string>
</property>
<property name="buddy">
<cstring>treeView</cstring>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="treeView">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Update &amp;interval:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>intervalSpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="intervalSpinBox">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>525600.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<connections/>
</ui>

View file

@ -1,181 +0,0 @@
/*
* Copyright (C) 2008 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "cpu.h"
#include <KDebug>
#include <Plasma/Theme>
#include <KConfigDialog>
#include <QTimer>
#include <QGraphicsLinearLayout>
#include "plotter.h"
SM::Cpu::Cpu(QObject *parent, const QVariantList &args)
: SM::Applet(parent, args)
, m_rx("^cpu/(\\w+)/TotalLoad$")
{
setHasConfigurationInterface(true);
resize(234 + 20 + 23, 135 + 20 + 25);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_sourceTimer.setSingleShot(true);
connect(&m_sourceTimer, SIGNAL(timeout()), this, SLOT(sourcesChanged()));
}
SM::Cpu::~Cpu()
{
}
void SM::Cpu::init()
{
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setEngine(dataEngine("systemmonitor"));
setTitle(i18n("CPU"));
/* At the time this method is running, not all source may be connected. */
connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(sourceChanged(QString)));
connect(engine(), SIGNAL(sourceRemoved(QString)), this, SLOT(sourceChanged(QString)));
foreach (const QString& source, engine()->sources()) {
sourceChanged(source);
}
}
void SM::Cpu::sourceChanged(const QString& name)
{
if (m_rx.indexIn(name) != -1) {
//kDebug() << m_rx.cap(1);
//kWarning() << name; // debug
m_cpus << name;
if (!m_sourceTimer.isActive()) {
m_sourceTimer.start(0);
}
}
}
void SM::Cpu::sourcesChanged()
{
configChanged();
}
void SM::Cpu::configChanged()
{
KConfigGroup cg = config();
QStringList default_cpus;
if(m_cpus.contains("cpu/system/TotalLoad"))
default_cpus << "cpu/system/TotalLoad";
else
default_cpus = m_cpus;
setInterval(cg.readEntry("interval", 2.0) * 1000.0);
setSources(cg.readEntry("cpus", default_cpus));
connectToEngine();
}
QString SM::Cpu::cpuTitle(const QString &name)
{
if (name == "system") {
return i18n("total");
}
return name;
}
bool SM::Cpu::addVisualization(const QString& source)
{
QStringList l = source.split('/');
if (l.count() < 3) {
return false;
}
QString cpu = l[1];
SM::Plotter *plotter = new SM::Plotter(this);
plotter->setMinMax(0.0, 100.0);
plotter->setTitle(cpuTitle(cpu));
plotter->setUnit("%");
appendVisualization(source, plotter);
setPreferredItemHeight(80);
return true;
}
void SM::Cpu::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
{
SM::Plotter *plotter = qobject_cast<SM::Plotter*>(visualization(source));
if (plotter) {
double value = data["value"].toDouble();
QString temp = KGlobal::locale()->formatNumber(value, 1);
plotter->addSample(QList<double>() << value);
if (mode() == SM::Applet::Panel) {
setToolTip(source, QString("<tr><td>%1&nbsp;</td><td>%2%</td></tr>")
.arg(plotter->title()).arg(temp));
}
}
}
void SM::Cpu::createConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
m_model.clear();
m_model.setHorizontalHeaderLabels(QStringList() << i18n("CPU"));
QStandardItem *parentItem = m_model.invisibleRootItem();
foreach (const QString& cpu, m_cpus) {
if (m_rx.indexIn(cpu) != -1) {
QStandardItem *item1 = new QStandardItem(cpuTitle(m_rx.cap(1)));
item1->setEditable(false);
item1->setCheckable(true);
item1->setData(cpu);
if (sources().contains(cpu)) {
item1->setCheckState(Qt::Checked);
}
parentItem->appendRow(QList<QStandardItem *>() << item1);
}
}
ui.treeView->setModel(&m_model);
ui.treeView->resizeColumnToContents(0);
ui.intervalSpinBox->setValue(interval() / 1000.0);
ui.intervalSpinBox->setSuffix(i18nc("second", " s"));
parent->addPage(widget, i18n("CPUs"), "cpu");
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(ui.treeView, SIGNAL(clicked(QModelIndex)), parent, SLOT(settingsModified()));
connect(ui.intervalSpinBox, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
}
void SM::Cpu::configAccepted()
{
KConfigGroup cg = config();
QStandardItem *parentItem = m_model.invisibleRootItem();
clear();
for (int i = 0; i < parentItem->rowCount(); ++i) {
QStandardItem *item = parentItem->child(i, 0);
if (item) {
if (item->checkState() == Qt::Checked) {
appendSource(item->data().toString());
}
}
}
cg.writeEntry("cpus", sources());
double interval = ui.intervalSpinBox->value();
cg.writeEntry("interval", interval);
emit configNeedsSaving();
}
#include "moc_cpu.cpp"

View file

@ -1,67 +0,0 @@
/*
* Copyright (C) 2008 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CPU_HEADER
#define CPU_HEADER
#include <ui_cpu-config.h>
#include "applet.h"
#include <Plasma/DataEngine>
#include <QStandardItemModel>
#include <QTimer>
#include <QRegExp>
#include <QStandardItemModel>
namespace SM {
class Cpu : public Applet
{
Q_OBJECT
public:
Cpu(QObject *parent, const QVariantList &args);
~Cpu();
virtual void init();
virtual bool addVisualization(const QString&);
virtual void createConfigurationInterface(KConfigDialog *parent);
public slots:
void dataUpdated(const QString &name,
const Plasma::DataEngine::Data &data);
void sourceChanged(const QString &name);
void sourcesChanged();
void configAccepted();
void configChanged();
protected:
QString cpuTitle(const QString &name);
private:
Ui::config ui;
QStandardItemModel m_model;
QStringList m_cpus;
QTimer m_sourceTimer;
QRegExp m_rx;
};
}
K_EXPORT_PLASMA_APPLET(sm_cpu, SM::Cpu)
#endif

View file

@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>config</class>
<widget class="QWidget" name="config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>263</height>
</rect>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Hard &amp;disks:</string>
</property>
<property name="buddy">
<cstring>treeView</cstring>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="treeView">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Update &amp;interval:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>intervalSpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="KIntSpinBox" name="intervalSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>525600</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,344 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "hdd.h"
#include "monitoricon.h"
#include <Plasma/Meter>
#include <Plasma/Containment>
#include <Plasma/Theme>
#include <Plasma/ToolTipManager>
#include <KConfigDialog>
#include <KColorUtils>
#include <QFileInfo>
#include <QGraphicsLinearLayout>
Hdd::Hdd(QObject *parent, const QVariantList &args)
: SM::Applet(parent, args)
{
setHasConfigurationInterface(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));
}
Hdd::~Hdd()
{
}
void Hdd::init()
{
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setEngine(dataEngine("soliddevice"));
setTitle(i18n("Disk Space"));
configChanged();
}
void Hdd::configChanged()
{
KConfigGroup cg = config();
QStringList sources = cg.readEntry("uuids", mounted());
setSources(sources);
setInterval(cg.readEntry("interval", 2) * 60 * 1000);
connectToEngine();
}
QStringList Hdd::mounted()
{
Plasma::DataEngine::Data data;
QString predicate("IS StorageVolume");
QStringList result;
foreach (const QString& uuid, engine()->query(predicate)[predicate].toStringList()) {
if (!isValidDevice(uuid, &data)) {
continue;
}
if (data["Accessible"].toBool()) {
result << uuid;
}
}
return result;
}
void Hdd::createConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
m_hddModel.clear();
m_hddModel.setHorizontalHeaderLabels(QStringList() << i18n("Mount Point")
<< i18n("Name"));
QStandardItem *parentItem = m_hddModel.invisibleRootItem();
Plasma::DataEngine::Data data;
QString predicateString("IS StorageVolume");
foreach (const QString& uuid, engine()->query(predicateString)[predicateString].toStringList()) {
if (!isValidDevice(uuid, &data)) {
continue;
}
QStandardItem *item1 = new QStandardItem(filePath(data));
item1->setEditable(false);
item1->setCheckable(true);
item1->setData(uuid);
if (sources().contains(uuid)) {
item1->setCheckState(Qt::Checked);
}
QStandardItem *item2 = new QStandardItem(hddTitle(uuid, data));
item2->setData(guessHddTitle(data));
item2->setEditable(true);
parentItem->appendRow(QList<QStandardItem *>() << item1 << item2);
}
ui.treeView->setModel(&m_hddModel);
ui.treeView->resizeColumnToContents(0);
ui.intervalSpinBox->setValue(interval() / 60 / 1000);
ui.intervalSpinBox->setSuffix(ki18np(" minute", " minutes"));
parent->addPage(widget, i18n("Partitions"), "drive-harddisk");
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(ui.treeView, SIGNAL(clicked(QModelIndex)), parent, SLOT(settingsModified()));
connect(ui.intervalSpinBox, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
}
void Hdd::configAccepted()
{
KConfigGroup cg = config();
KConfigGroup cgGlobal = globalConfig();
QStandardItem *parentItem = m_hddModel.invisibleRootItem();
clear();
for (int i = 0; i < parentItem->rowCount(); ++i) {
QStandardItem *item = parentItem->child(i, 0);
if (item) {
QStandardItem *child = parentItem->child(i, 1);
if (child->text() != child->data().toString()) {
cgGlobal.writeEntry(item->data().toString(), child->text());
}
if (item->checkState() == Qt::Checked) {
appendSource(item->data().toString());
}
}
}
cg.writeEntry("uuids", sources());
uint interval = ui.intervalSpinBox->value();
cg.writeEntry("interval", interval);
emit configNeedsSaving();
}
QString Hdd::hddTitle(const QString& uuid, const Plasma::DataEngine::Data &data)
{
KConfigGroup cg = globalConfig();
QString label = cg.readEntry(uuid, "");
if (label.isEmpty()) {
label = guessHddTitle(data);
}
return label;
}
QString Hdd::guessHddTitle(const Plasma::DataEngine::Data &data)
{
QString label = data["Label"].toString();
if (label.isEmpty()) {
QString path = data["File Path"].toString();
if (path == "/")
return i18nc("the root filesystem", "root");
QFileInfo fi(path);
label = fi.fileName();
if (label.isEmpty()) {
label = data["Device"].toString();
if (label.isEmpty()) {
label = i18n("Unknown filesystem");
}
}
}
return label;
}
QString Hdd::filePath(const Plasma::DataEngine::Data &data)
{
QString label = data["File Path"].toString();
QVariant accessible = data["Accessible"];
if (accessible.isValid()) {
if (accessible.canConvert(QVariant::Bool)) {
if (!accessible.toBool()) {
label = i18nc("hard disk label (not mounted or accessible)",
"%1 (not accessible)", label);
}
}
}
return label;
}
bool Hdd::addVisualization(const QString& source)
{
Plasma::Meter *w;
Plasma::DataEngine *engine = dataEngine("soliddevice");
Plasma::DataEngine::Data data;
if (!engine) {
return false;
}
if (!isValidDevice(source, &data)) {
// do not try to show hard drives and swap partitions.
return false;
}
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
layout->setContentsMargins(3, 3, 3, 3);
layout->setSpacing(5);
w = new Plasma::Meter(this);
w->setMeterType(Plasma::Meter::BarMeterHorizontal);
if (mode() != SM::Applet::Panel) {
MonitorIcon *icon = new MonitorIcon(this);
m_icons.insert(source, icon);
icon->setImage("drive-harddisk");
if (data["Accessible"].toBool()) {
QStringList overlays;
overlays << QString("emblem-mounted");
icon->setOverlays(overlays);
}
layout->addItem(icon);
} else {
w->setSvg("system-monitor/hdd_panel");
}
w->setLabel(0, hddTitle(source, data));
w->setLabelAlignment(0, Qt::AlignVCenter | Qt::AlignLeft);
w->setLabelAlignment(1, Qt::AlignVCenter | Qt::AlignRight);
w->setLabelAlignment(2, Qt::AlignVCenter | Qt::AlignCenter);
w->setMaximum(data["Size"].toULongLong() / (1024 * 1024));
applyTheme(w);
appendVisualization(source, w);
layout->addItem(w);
mainLayout()->addItem(layout);
dataUpdated(source, data);
setPreferredItemHeight(layout->preferredSize().height());
QString disk = data["Parent UDI"].toString();
m_diskMap[disk] << w;
if (!connectedSources().contains(disk)) {
data = engine->query(disk);
dataUpdated(disk, data);
connectSource(disk);
}
return true;
}
void Hdd::applyTheme(Plasma::Meter *w)
{
if (!w) {
return;
}
Plasma::Theme* theme = Plasma::Theme::defaultTheme();
QColor text = theme->color(Plasma::Theme::TextColor);
QColor bg = theme->color(Plasma::Theme::BackgroundColor);
QColor darkerText = KColorUtils::tint(text, bg, 0.4);
w->setLabelColor(0, text);
w->setLabelColor(1, darkerText);
w->setLabelColor(2, darkerText);
QFont font = theme->font(Plasma::Theme::DefaultFont);
font.setPointSize(9);
w->setLabelFont(0, font);
font.setPointSizeF(7.5);
w->setLabelFont(1, font);
w->setLabelFont(2, font);
}
void Hdd::themeChanged()
{
foreach (const QString& source, connectedSources()) {
applyTheme(qobject_cast<Plasma::Meter*>(visualization(source)));
}
}
void Hdd::deleteVisualizations()
{
foreach(MonitorIcon * icon, m_icons) {
delete(icon);
}
m_icons.clear();
Applet::deleteVisualizations();
m_diskMap.clear();
}
bool Hdd::isValidDevice(const QString& uuid, Plasma::DataEngine::Data* data)
{
Plasma::DataEngine *engine = dataEngine("soliddevice");
if (engine) {
*data = engine->query(uuid);
/*
kDebug() << uuid << data->value("Device").toString() <<
data->value("Usage").toString() <<
data->value("File System Type").toString() <<
data->value("Size").toString();
*/
if ((data->value("Usage").toString() != i18n("File System") &&
data->value("Usage").toString() != i18n("Raid")) ||
data->value("File System Type").toString() == "swap") {
QStringList list = sources();
list.removeAll(uuid);
setSources(list);
return false;
}
return true;
}
return false;
}
void Hdd::dataUpdated(const QString& source,
const Plasma::DataEngine::Data &data)
{
Plasma::Meter *w = qobject_cast<Plasma::Meter *>(visualization(source));
if (!w) {
return;
}
qulonglong size = qulonglong(data["Size"].toULongLong());
qlonglong availBytes = 0;
QVariant freeSpace = data["Free Space"];
if (freeSpace.isValid()) {
if (freeSpace.canConvert(QVariant::LongLong)) {
availBytes = qlonglong(freeSpace.toLongLong());
w->setValue((size / (1024 * 1024)) - (availBytes / (1024 * 1024)));
}
}
else {
w->setValue(0);
}
if (mode() != SM::Applet::Panel) {
w->setLabel(1, KGlobal::locale()->formatByteSize(availBytes));
QStringList overlays;
if (data["Accessible"].toBool()) {
overlays << "emblem-mounted";
}
m_icons[source]->setOverlays(overlays);
} else {
setToolTip(source, QString("<tr><td>%1</td><td>%2</td><td>/</td><td>%3</td></tr>")
.arg(w->label(0))
.arg(KGlobal::locale()->formatByteSize(availBytes))
.arg(KGlobal::locale()->formatByteSize(size)));
}
}
#include "moc_hdd.cpp"

View file

@ -1,73 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef HDD_HEADER
#define HDD_HEADER
#include <Plasma/DataEngine>
#include <QHash>
#include <QStandardItemModel>
#include <applet.h>
#include "ui_hdd-config.h"
namespace Plasma {
class Meter;
}
class MonitorIcon;
#include <QGraphicsLinearLayout>
class Hdd : public SM::Applet
{
Q_OBJECT
public:
Hdd(QObject *parent, const QVariantList &args);
~Hdd();
virtual void init();
virtual void createConfigurationInterface(KConfigDialog *parent);
public slots:
void configChanged();
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
protected:
QString hddTitle(const QString& uuid, const Plasma::DataEngine::Data &data);
QString guessHddTitle(const Plasma::DataEngine::Data &data);
QString filePath(const Plasma::DataEngine::Data &data);
bool addVisualization(const QString& source);
virtual void deleteVisualizations();
bool isValidDevice(const QString& uuid, Plasma::DataEngine::Data* data);
void applyTheme(Plasma::Meter *w);
protected slots:
void configAccepted();
void themeChanged();
private:
Ui::config ui;
QStandardItemModel m_hddModel;
QHash<const QString, MonitorIcon *> m_icons;
QHash<const QString, QGraphicsLinearLayout *> m_layouts;
QHash<QString, QList<Plasma::Meter *> > m_diskMap;
QStringList mounted();
};
K_EXPORT_PLASMA_APPLET(sm_hdd, Hdd)
#endif

View file

@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>config</class>
<widget class="QWidget" name="config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>263</height>
</rect>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Hard &amp;disks:</string>
</property>
<property name="buddy">
<cstring>treeView</cstring>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="treeView">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Update &amp;interval:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>intervalSpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="KIntSpinBox" name="intervalSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>525600</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,291 +0,0 @@
/*
* Copyright (C) 2011, 2012 Shaun Reich <shaun.reich@kdemail.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "hdd_activity.h"
#include "monitoricon.h"
#include "plotter.h"
#include <KDebug>
#include <KConfigDialog>
#include <KColorUtils>
#include <QFileInfo>
#include <QGraphicsLinearLayout>
#include <Plasma/Meter>
#include <Plasma/Containment>
#include <Plasma/Theme>
#include <Plasma/ToolTipManager>
/**
* Examples of what the regexp has to handle...
*
* Note actually it's now set to an inclusive-only mode, far cleaner.
*
* Included items only:
*
*
* RAID blocks (there *could* be more if not using mdadm, I think):
*
* disk/md<something>/Rate/rio
* disk/md<something>/Rate/wio
*
* SATA disks:
*
* disk/sd<something>/Rate/rio
* disk/sd<something>/Rate/wio
*
* IDE/PATA disks:
*
* disk/hd<something>/Rate/rio
* disk/hd<something>/Rate/wio
*
* Does NOT include partitions, since I don't think many people will use that.
*
* RAID regexp handling needs further testing, I have a feeling it works just for me.
*
*/
Hdd_Activity::Hdd_Activity(QObject *parent, const QVariantList &args)
: SM::Applet(parent, args),
m_regexp("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk|wblk)")
{
setHasConfigurationInterface(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
Hdd_Activity::~Hdd_Activity()
{
}
void Hdd_Activity::init()
{
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setEngine(dataEngine("systemmonitor"));
setTitle(i18n("Disk Activity"));
/* At the time this method is running, not all sources may be connected. */
connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(sourceChanged(QString)));
connect(engine(), SIGNAL(sourceRemoved(QString)), this, SLOT(sourceChanged(QString)));
foreach (const QString& source, engine()->sources()) {
sourceChanged(source);
}
configChanged();
}
void Hdd_Activity::sourceChanged(const QString& name)
{
//kDebug() << "######## sourceChanged name: " << name;
//kDebug() << "###### regexp captures: " << m_regexp.capturedTexts();
if (m_regexp.indexIn(name) != -1) {
m_possibleHdds.append(name);
}
}
void Hdd_Activity::sourcesChanged()
{
configChanged();
}
void Hdd_Activity::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
{
const double value = data["value"].toDouble();
QVector<double>& valueVector = m_data[source];
if (valueVector.size() < 2) {
valueVector.resize(2);
}
QString sneakySource = source;
// we're interested in all source for a device which are
// rblk and wblk. however, only 1 vis per that. so it wouldn't be unique and we'd only
// get the values for rblk.
// so add data to the hash, since we obtain the pair
// on separate dataUpdated calls, so we'll need to map them
if (sneakySource.endsWith("rblk")) {
valueVector[0] = value;
} else if (sneakySource.endsWith("wblk")) {
valueVector[1] = value;
//make the source *appear* to be a rblk.
sneakySource.remove("wblk");
sneakySource.append("rblk");
}
// we look up the visualization that is /...disk/rblk only. there is
// not a rblk vis, so one just holds all data.
SM::Plotter *plotter = qobject_cast<SM::Plotter*>(visualization(sneakySource));
// plotter is invalid if we're e.g. switching monitored stuff
if (!plotter) {
return;
}
//only graph it if it's got both rblk and wblk
if (valueVector.count() == 2) {
QString read = KGlobal::locale()->formatNumber(valueVector.at(0), 1);
QString write = KGlobal::locale()->formatNumber(valueVector.at(1), 1);
//FIXME: allow plotter->addSample overload for QVector.
plotter->addSample(valueVector.toList());
if (mode() == SM::Applet::Panel) {
const QString tooltip = QString("<tr><td>%1&nbsp;</td><td>rio: %2%</td><td>wio: %3</td></tr>")
.arg(plotter->title()).arg(read).arg(write);
setToolTip(source, tooltip);
}
}
}
void Hdd_Activity::createConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
m_hddModel.clear();
m_hddModel.setHorizontalHeaderLabels(QStringList() << i18n("Name"));
QStandardItem *parentItem = m_hddModel.invisibleRootItem();
foreach (const QString& hdd, m_possibleHdds) {
if (m_regexp.indexIn(hdd) != -1) {
if (hdd.endsWith("rblk")) {
// so the user only sees 1 device (which includes both rblk/wblk
QString trimmedHdd = hdd;
trimmedHdd.remove("rblk");
QStandardItem *item1 = new QStandardItem(trimmedHdd);
item1->setEditable(false);
item1->setCheckable(true);
// store the pair of real sources (rblk, wblk) into data
QStringList realSources;
realSources.append(trimmedHdd + "rblk");
realSources.append(trimmedHdd + "wblk");
item1->setData(realSources);
// but the behind the scenes still uses the source separation,
// so be sure to use that.
if (sources().contains(hdd)) {
item1->setCheckState(Qt::Checked);
}
parentItem->appendRow(QList<QStandardItem *>() << item1);
}
}
}
ui.treeView->setModel(&m_hddModel);
ui.treeView->resizeColumnToContents(0);
ui.intervalSpinBox->setValue(interval() / 1000.0);
ui.intervalSpinBox->setSuffix(i18nc("second", " s"));
parent->addPage(widget, i18n("Hard Disks"), "drive-harddisk");
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(ui.treeView, SIGNAL(clicked(QModelIndex)), parent, SLOT(settingsModified()));
connect(ui.intervalSpinBox, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
}
void Hdd_Activity::configChanged()
{
//kDebug() << "#### configChanged m_hdds:" << m_hdds;
KConfigGroup cg = config();
QStringList default_hdds = m_possibleHdds;
// default to 2 seconds (2000 ms interval
setInterval(cg.readEntry("interval", 2.0) * 1000.0);
setSources(cg.readEntry("hdds", default_hdds));
connectToEngine();
}
void Hdd_Activity::configAccepted()
{
KConfigGroup cg = config();
QStandardItem *parentItem = m_hddModel.invisibleRootItem();
clear();
for (int i = 0; i < parentItem->rowCount(); ++i) {
QStandardItem *item = parentItem->child(i, 0);
if (item) {
if (item->checkState() == Qt::Checked) {
QStringList actualSources = item->data().toStringList();
const QString& rblk = actualSources.at(0);
const QString& wblk = actualSources.at(1);
appendSource(rblk);
appendSource(wblk);
}
}
}
cg.writeEntry("hdds", sources());
uint interval = ui.intervalSpinBox->value();
cg.writeEntry("interval", interval);
emit configNeedsSaving();
}
bool Hdd_Activity::addVisualization(const QString& source)
{
QStringList splits = source.split('/');
// 0 == "disk" 1 == "sde_(8:64)" 2 == "Rate" 3 == "rblk"
Q_ASSERT(splits.count() == 4);
// only monitor rblk for each device. we watch all sources/connect to them
// but only need 1 vis per actual device (otherwise there'd be 1 for rblk, 1
// for wblk, which isn't what I have in mind -sreich
if (splits.at(3) == "rblk") {
QString hdd = source;
hdd = hdd.remove("rblk");
//kDebug() << "#### ADD VIS hdd: " << hdd;
SM::Plotter *plotter = new SM::Plotter(this);
plotter->setTitle(hdd);
// FIXME: localize properly..including units.
// ksysguard just gives us 1024 KiB for sources, we need to convert for anything else.
plotter->setUnit("KiB/s");
// should be read, write, respectively
plotter->setCustomPlots(QList<QColor>() << QColor("#0057AE") << QColor("#E20800"));
appendVisualization(source, plotter);
setPreferredItemHeight(80);
}
// if we return false here, it thinks we don't want
// source updates for this source
// which makes sense (since there's no vis). but not in
// this case.
return true;
}
#include "moc_hdd_activity.cpp"

View file

@ -1,82 +0,0 @@
/*
* Copyright (C) 2011, 2012 Shaun Reich <shaun.reich@kdemail.net>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef HDD_ACTIVITY_HEADER
#define HDD_ACTIVITY_HEADER
#include "ui_hdd_activity-config.h"
#include "applet.h"
#include <QTimer>
#include <QStandardItemModel>
#include <QRegExp>
#include <Plasma/DataEngine>
namespace Plasma {
}
#include <QGraphicsLinearLayout>
class Hdd_Activity : public SM::Applet
{
Q_OBJECT
public:
Hdd_Activity(QObject *parent, const QVariantList &args);
~Hdd_Activity();
virtual void init();
virtual bool addVisualization(const QString &source);
virtual void createConfigurationInterface(KConfigDialog *parent);
public slots:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
void sourceChanged(const QString &name);
void sourcesChanged();
void configAccepted();
void configChanged();
private:
Ui::config ui;
QStandardItemModel m_hddModel;
/**
* The hdd sources that would be interesting to watch.
* Does not necessarily mean they're being watched,
* sources() indicates that.
*/
QStringList m_possibleHdds;
/**
* For each raw hdd name source, stores
* reads at 0, writes at 1.
*
* Needed because we get those dataUpdated changes
* separately.
*/
QMap<QString, QVector<double> > m_data;
QRegExp m_regexp;
};
K_EXPORT_PLASMA_APPLET(sm_hdd_activity, Hdd_Activity)
#endif

View file

@ -1,156 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "hwinfo.h"
#include <Plasma/TextBrowser>
#include <Plasma/IconWidget>
#include <Plasma/Containment>
#include <Plasma/ToolTipManager>
#include <Plasma/Theme>
#include <KDebug>
#include <KStandardDirs>
#include <KIcon>
#include <QGraphicsLinearLayout>
#define START "<html><head><style type=\"text/css\">\
td { vertical-align: top; font-size:7pt; font-weight:normal; font-style:normal; color: %2; } \
</style></head><body>"
#define START_BASIC "<html><head></head><body>"
#define START_TABLE "<table>"
#define INFO_ROW "<tr><td>%1:</td><td>%2</td></tr>"
#define END_TABLE "</table>"
#define END "</body><html>"
HWInfo::HWInfo(QObject *parent, const QVariantList &args)
: SM::Applet(parent, args), m_info(0), m_icon(0)
{
resize(234 + 20 + 23, 135 + 20 + 25);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(updateHtml()));
}
HWInfo::~HWInfo()
{
}
void HWInfo::init()
{
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setTitle(i18n("Hardware Info"));
setEngine(dataEngine("soliddevice"));
setSources();
connectToEngine();
}
bool HWInfo::addVisualization(const QString& source)
{
if (mode() != SM::Applet::Panel) {
if (!m_info) {
m_info = new Plasma::TextBrowser(this);
m_info->nativeWidget()->setHtml(QString(START + i18n("Getting hardware information...") + END));
appendVisualization(source, m_info);
//m_info->nativeWidget()->document()->setTextWidth(contentsRect().width());
//setPreferredItemHeight(m_info->nativeWidget()->document()->size().height());
setPreferredItemHeight(135);
}
} else {
if (!m_icon) {
m_icon = new Plasma::IconWidget(KIcon(icon()), "", this);
appendVisualization(source, m_icon);
}
}
return true;
}
void HWInfo::deleteVisualizations()
{
SM::Applet::deleteVisualizations();
m_icon = 0;
m_info = 0;
}
void HWInfo::setSources()
{
m_cpus = engine()->query("IS Processor")["IS Processor"].toStringList();
foreach (const QString& id, m_cpus) {
appendSource(id);
}
m_networks = engine()->query("IS NetworkInterface")["IS NetworkInterface"].toStringList();
foreach (const QString& id, m_networks) {
appendSource(id);
}
m_audios = engine()->query("IS AudioInterface")["IS AudioInterface"].toStringList();
foreach (const QString& id, m_audios) {
appendSource(id);
}
m_gpus = engine()->query("IS Graphic")["IS Graphic"].toStringList();
foreach (const QString& id, m_gpus) {
appendSource(id);
}
}
void HWInfo::dataUpdated(const QString& source,
const Plasma::DataEngine::Data &data)
{
if (m_audios.contains(source) && !m_audioNames.contains(data["Name"].toString()) &&
!data["Name"].toString().isEmpty()) {
m_audioNames.append(data["Name"].toString());
} else if (m_networks.contains(source) && !m_networkNames.contains(data["Product"].toString()) &&
!data["Product"].toString().isEmpty()) {
m_networkNames.append(data["Product"].toString());
} else if (m_cpus.contains(source) && !m_cpuNames.contains(data["Product"].toString()) &&
!data["Product"].toString().isEmpty()) {
m_cpuNames.append(data["Product"].toString().trimmed());
} else if (m_gpus.contains(source) && !m_gpuNames.contains(data["Product"].toString()) &&
!data["Product"].toString().isEmpty()) {
m_gpuNames.append(data["Product"].toString());
}
updateHtml();
}
void HWInfo::updateHtml()
{
QString html;
foreach(const QString& cpu, m_cpuNames) {
html += QString(INFO_ROW).arg(i18n("CPU")).arg(cpu);
}
foreach(const QString& gpu, m_gpuNames) {
html += QString(INFO_ROW).arg(i18n("GPU")).arg(gpu);
}
foreach(const QString& audio, m_audioNames) {
html += QString(INFO_ROW).arg(i18n("Audio")).arg(audio);
}
foreach(const QString& network, m_networkNames) {
html += QString(INFO_ROW).arg(i18n("Network")).arg(network);
}
html += END_TABLE END;
if (m_info) {
Plasma::Theme* theme = Plasma::Theme::defaultTheme();
html = QString(START START_TABLE)
.arg(theme->color(Plasma::Theme::TextColor).name()) + html;
m_info->nativeWidget()->setHtml(html);
} else if (m_icon) {
html = START_BASIC START_TABLE + html;
Plasma::ToolTipContent data(i18n("Hardware Info"), html);
Plasma::ToolTipManager::self()->setContent(m_icon, data);
}
}
#include "moc_hwinfo.cpp"

View file

@ -1,68 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef HWINFO_HEADER
#define HWINFO_HEADER
#include <applet.h>
#include <Plasma/DataEngine>
namespace Plasma {
class TextBrowser;
class IconWidget;
}
class HWInfo : public SM::Applet
{
Q_OBJECT
public:
HWInfo(QObject *parent, const QVariantList &args);
~HWInfo();
virtual void init();
virtual bool addVisualization(const QString&);
public slots:
void dataUpdated(const QString &name,
const Plasma::DataEngine::Data &data);
private slots:
void updateHtml();
protected:
virtual void deleteVisualizations();
private:
void setSources();
Plasma::TextBrowser *m_info;
Plasma::IconWidget *m_icon;
QStringList m_gpus;
QStringList m_gpuNames;
QStringList m_cpus;
QStringList m_cpuNames;
QStringList m_networks;
QStringList m_networkNames;
QStringList m_audios;
QStringList m_audioNames;
};
K_EXPORT_PLASMA_APPLET(sm_hwinfo, HWInfo)
#endif

View file

@ -1,120 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "monitorbutton.h"
#include <QIcon>
#include <QPainter>
#include <QTimeLine>
#include <KDebug>
#include <KIcon>
#include <KPushButton>
#include <Plasma/PaintUtils>
#define MARGIN 2
class MonitorButton::Private
{
public:
Private() : imageSize(32, 32)
{
}
QSize imageSize;
QString image;
KIcon icon;
QTimeLine highlighter;
};
MonitorButton::MonitorButton(QGraphicsWidget *parent) :
Plasma::PushButton(parent),
d(new Private)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setPreferredSize(d->imageSize.width() + 2 * MARGIN, d->imageSize.height() + 2 * MARGIN);
d->highlighter.setDuration(100);
d->highlighter.setFrameRange(0, 10);
d->highlighter.setEasingCurve(QEasingCurve(QEasingCurve::InCurve));
connect(&d->highlighter, SIGNAL(valueChanged(qreal)), this, SLOT(highlight()));
}
MonitorButton::~MonitorButton()
{
delete d;
}
QString MonitorButton::image() const
{
return d->image;
}
void MonitorButton::setImage(const QString &image)
{
d->image = image;
d->icon = KIcon(image);
update();
}
void MonitorButton::highlight()
{
update();
}
void MonitorButton::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
Q_UNUSED(event)
d->highlighter.setDirection(QTimeLine::Forward);
if (d->highlighter.currentValue() < 1 &&
d->highlighter.state() == QTimeLine::NotRunning) {
d->highlighter.start();
}
}
void MonitorButton::hoverLeaveEvent(QGraphicsSceneHoverEvent * event)
{
Q_UNUSED(event)
d->highlighter.setDirection(QTimeLine::Backward);
if (d->highlighter.currentValue() > 0 &&
d->highlighter.state() == QTimeLine::NotRunning) {
d->highlighter.start();
}
}
void MonitorButton::paint(QPainter *p,
const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
QPixmap icon = Plasma::PaintUtils::transition(d->icon.pixmap(d->imageSize, QIcon::Disabled),
d->icon.pixmap(d->imageSize, QIcon::Normal),
isChecked() ? 1 : d->highlighter.currentValue());
p->drawPixmap(QPointF((size().width() - d->imageSize.width()) / 2,
(size().height() - d->imageSize.height()) / 2),
icon);
}
#include "moc_monitorbutton.cpp"

View file

@ -1,53 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef MONITORBUTTON_HEADER
#define MONITORBUTTON_HEADER
#include <Plasma/PushButton>
#include "plasma_applet_system_monitor_export.h"
class PLASMA_APPLET_SYSTEM_MONITOR_EXPORT MonitorButton : public Plasma::PushButton
{
Q_OBJECT
Q_PROPERTY(QString image READ image WRITE setImage)
public:
explicit MonitorButton(QGraphicsWidget *parent = 0);
virtual ~MonitorButton();
QString image() const;
void setImage(const QString &image);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
virtual void paint(QPainter *p,
const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
private slots:
void highlight();
private:
class Private;
Private * const d;
};
#endif

View file

@ -1,86 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "monitoricon.h"
#include <kdebug.h>
#include <QPainter>
#include <KIcon>
#include <KIconLoader>
#define MARGIN 5
class MonitorIcon::Private
{
public:
Private() : imageSize(22, 22) { }
QSizeF imageSize;
QString image;
QStringList overlays;
};
MonitorIcon::MonitorIcon(QGraphicsItem *parent) :
QGraphicsWidget(parent),
d(new Private)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setPreferredSize(d->imageSize.width() + 2 * MARGIN, d->imageSize.height() + 2 * MARGIN);
}
MonitorIcon::~MonitorIcon()
{
delete d;
}
QString MonitorIcon::image() const
{
return d->image;
}
void MonitorIcon::setImage(const QString &image)
{
d->image = image;
update();
}
QStringList MonitorIcon::overlays() const
{
return d->overlays;
}
void MonitorIcon::setOverlays( const QStringList & overlays )
{
d->overlays = overlays;
update();
}
void MonitorIcon::paint(QPainter *p,
const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
p->drawPixmap(QPointF((size().width() - d->imageSize.width()) / 2,
(size().height() - d->imageSize.height()) / 2),
KIcon(d->image, KIconLoader::global(),
d->overlays).pixmap(d->imageSize.toSize()));
}
#include "moc_monitoricon.cpp"

View file

@ -1,49 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef MONITORICON_HEADER
#define MONITORICON_HEADER
#include <QGraphicsWidget>
#include "plasma_applet_system_monitor_export.h"
class PLASMA_APPLET_SYSTEM_MONITOR_EXPORT MonitorIcon : public QGraphicsWidget
{
Q_OBJECT
Q_PROPERTY(QString image READ image WRITE setImage)
public:
explicit MonitorIcon(QGraphicsItem *parent = 0);
virtual ~MonitorIcon();
QString image() const;
void setImage(const QString &image);
QStringList overlays() const;
void setOverlays( const QStringList & overlays );
protected:
virtual void paint(QPainter *p,
const QStyleOptionGraphicsItem *option,
QWidget *widget = 0);
private:
class Private;
Private * const d;
};
#endif

View file

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>config</class>
<widget class="QWidget" name="config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>263</height>
</rect>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Network interfaces:</string>
</property>
<property name="buddy">
<cstring>treeView</cstring>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="treeView">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Update &amp;interval:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>intervalSpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="intervalSpinBox">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>525600.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<connections/>
</ui>

View file

@ -1,199 +0,0 @@
/*
* Copyright (C) 2008 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "net.h"
#include <Plasma/Theme>
#include <Plasma/ToolTipManager>
#include <KConfigDialog>
#include <QGraphicsLinearLayout>
#include <plotter.h>
SM::Net::Net(QObject *parent, const QVariantList &args)
: SM::Applet(parent, args)
, m_rx("^network/interfaces/(\\w+)/transmitter/data$")
{
setHasConfigurationInterface(true);
resize(234 + 20 + 23, 135 + 20 + 25);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_sourceTimer.setSingleShot(true);
connect(&m_sourceTimer, SIGNAL(timeout()), this, SLOT(sourcesAdded()));
}
SM::Net::~Net()
{
}
void SM::Net::init()
{
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setEngine(dataEngine("systemmonitor"));
setTitle(i18n("Network"));
connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(sourceAdded(QString)));
connect(engine(), SIGNAL(sourceRemoved(QString)),
this, SLOT(sourceRemoved(QString)));
foreach (const QString& source, engine()->sources()) {
sourceAdded(source);
}
}
void SM::Net::configChanged()
{
KConfigGroup cg = config();
setInterval(cg.readEntry("interval", 2.0) * 1000);
setSources(cg.readEntry("interfaces", m_interfaces));
connectToEngine();
}
void SM::Net::sourceAdded(const QString& name)
{
if (m_rx.indexIn(name) != -1) {
//kDebug() << m_rx.cap(1);
if (m_rx.cap(1) != "lo") {
m_interfaces << name;
if (!m_sourceTimer.isActive()) {
m_sourceTimer.start(0);
}
}
}
}
void SM::Net::sourcesAdded()
{
configChanged();
}
void SM::Net::sourceRemoved(const QString& name)
{
m_interfaces.removeAll(name);
}
bool SM::Net::addVisualization(const QString& source)
{
QStringList l = source.split('/');
if (l.count() < 3) {
return false;
}
QString interface = l[2];
SM::Plotter *plotter = new SM::Plotter(this);
plotter->setTitle(interface);
plotter->setUnit("KiB/s");
plotter->setCustomPlots(QList<QColor>() << QColor("#0099ff") << QColor("#91ff00"));
//plotter->setStackPlots(false);
appendVisualization(interface, plotter);
connectSource("network/interfaces/" + interface + "/receiver/data");
setPreferredItemHeight(80);
return true;
}
void SM::Net::dataUpdated(const QString& source,
const Plasma::DataEngine::Data &data)
{
QStringList splitted = source.split('/');
if (splitted.length() < 4) {
return;
}
QString interface = splitted[2];
int index = (splitted[3] == "receiver") ? 0 : 1;
if (!m_data.contains(interface)) {
m_data[interface] = QList<double>() << -1 << -1;
}
m_data[interface][index] = qMax(0.0, data["value"].toDouble());
if (!m_data[interface].contains(-1)) {
SM::Plotter *plotter = qobject_cast<SM::Plotter*>(visualization(interface));
if (plotter) {
plotter->addSample(m_data[interface]);
if (mode() == SM::Applet::Panel) {
const double downstream = m_data[interface][0];
const double upstream = m_data[interface][1];
QString tooltip = QString::fromUtf8("<b>%1</b> <br /> ⇧ &nbsp; %2 <br />⇩ &nbsp; %3<br />");
setToolTip(interface, tooltip.arg(plotter->title())
.arg(KGlobal::locale()->formatByteSize(upstream*1024))
.arg(KGlobal::locale()->formatByteSize(downstream*1024)));
}
}
m_data[interface] = QList<double>() << -1 << -1;
}
}
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();
foreach (const QString& interface, m_interfaces) {
QString ifname = interface.split('/')[2];
QStandardItem *item1 = new QStandardItem(ifname);
item1->setEditable(false);
item1->setCheckable(true);
item1->setData(interface);
if (sources().contains(interface)) {
item1->setCheckState(Qt::Checked);
}
parentItem->appendRow(QList<QStandardItem *>() << item1);
}
ui.treeView->setModel(&m_model);
ui.treeView->resizeColumnToContents(0);
ui.intervalSpinBox->setValue(interval() / 1000.0);
ui.intervalSpinBox->setSuffix(i18nc("second", " s"));
parent->addPage(widget, i18n("Interfaces"), "network-workgroup");
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(ui.treeView, SIGNAL(clicked(QModelIndex)), parent, SLOT(settingsModified()));
connect(ui.intervalSpinBox, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
}
void SM::Net::configAccepted()
{
KConfigGroup cg = config();
QStandardItem *parentItem = m_model.invisibleRootItem();
clear();
for (int i = 0; i < parentItem->rowCount(); ++i) {
QStandardItem *item = parentItem->child(i, 0);
if (item) {
if (item->checkState() == Qt::Checked) {
appendSource(item->data().toString());
}
}
}
cg.writeEntry("interfaces", sources());
double interval = ui.intervalSpinBox->value();
cg.writeEntry("interval", interval);
emit configNeedsSaving();
}
#include "moc_net.cpp"

View file

@ -1,66 +0,0 @@
/*
* Copyright (C) 2008 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef NET_HEADER
#define NET_HEADER
#include <ui_net-config.h>
#include "applet.h"
#include <Plasma/DataEngine>
#include <QStandardItemModel>
#include <QTimer>
#include <QRegExp>
#include <QStandardItemModel>
namespace SM {
class Net : public Applet
{
Q_OBJECT
public:
Net(QObject *parent, const QVariantList &args);
~Net();
virtual void init();
virtual bool addVisualization(const QString&);
virtual void createConfigurationInterface(KConfigDialog *parent);
public slots:
void configAccepted();
void configChanged();
void dataUpdated(const QString &name,
const Plasma::DataEngine::Data &data);
void sourceAdded(const QString &name);
void sourcesAdded();
void sourceRemoved(const QString &name);
private:
Ui::config ui;
QStandardItemModel m_model;
QStringList m_interfaces;
QMap<QString, QList<double> > m_data;
QTimer m_sourceTimer;
QRegExp m_rx;
};
}
K_EXPORT_PLASMA_APPLET(sm_net, SM::Net)
#endif

View file

@ -1,152 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=CPU Monitor
Name[ar]=مراقب استعمال المعالج
Name[ast]=Monitor de CPU
Name[bg]=Наблюдение на процесора
Name[bs]=nadzor procesora
Name[ca]=Controlador de la CPU
Name[ca@valencia]=Controlador de la CPU
Name[cs]=Monitor CPU
Name[da]=CPU-overvågning
Name[de]=Überwachungsmonitor für Prozessoren
Name[el]=Επόπτης ΚΜΕ
Name[en_GB]=CPU Monitor
Name[es]=Monitor de CPU
Name[et]=Protsessori jälgija
Name[eu]=PUZaren monitorea
Name[fi]=Suoritinkäyttö
Name[fr]=Surveillance du processeur
Name[ga]=Monatóir an LAP
Name[gl]=Vixilante da CPU
Name[gu]=CPU િ
Name[he]=מוניטור המעבד
Name[hi]=
Name[hr]=Nadzornik CPU-a
Name[hu]=Processzorfigyelő
Name[ia]=Monitor de CPU
Name[id]=Monitor CPU
Name[is]=Eftirlit með notkun örgjörva
Name[it]=Monitor del processore
Name[ja]=CPU
Name[kk]=Процссорды бақылау
Name[km]=
Name[kn]=CPU ಿ
Name[ko]=CPU
Name[lt]=CPU apkrovos stebėtojas
Name[lv]=Procesora novērotājs
Name[mr]=CPU ि
Name[nb]=prosessor-overvåker
Name[nds]=CPU-Kieker
Name[nl]=Monitor voor CPU-gebruik
Name[pa]=CPU ਿ
Name[pl]=Monitor procesora
Name[pt]=Monitor do CPU
Name[pt_BR]=Monitor da CPU
Name[ro]=Monitor de procesor
Name[ru]=Использование процессора
Name[si]=CPU
Name[sk]=Monitor CPU
Name[sl]=Nadzornik procesorja
Name[sr]=надзор процесора
Name[sr@ijekavian]=надзор процесора
Name[sr@ijekavianlatin]=nadzor procesora
Name[sr@latin]=nadzor procesora
Name[sv]=Övervakning av processoranvändning
Name[tg]=Монитори CPU
Name[th]=
Name[tr]=İşlemci İzleyici
Name[ug]=CPU كۆزەتكۈچ
Name[uk]=Використання процесора
Name[vi]=Trình qun lý CPU
Name[wa]=Corwaitoe CPU
Name[x-test]=xxCPU Monitorxx
Name[zh_CN]=CPU
Name[zh_TW]=CPU
Comment=A CPU usage monitor
Comment[ar]=مراقب استعمال المعالج
Comment[ast]=Monitor d'usu de la CPU
Comment[be@latin]=Nazirańnik zaniataści CPU
Comment[bg]=Наблюдение натоварването на процесора
Comment[bs]=Nadgledanje upotrebe procesora
Comment[ca]=Un controlador d'ús de la CPU
Comment[ca@valencia]=Un controlador d'ús de la CPU
Comment[cs]=Monitor vytížení CPU
Comment[csb]=Mònitór brëkùnkù CPU
Comment[da]=Overvågning af CPU-forbrug
Comment[de]=Ein Überwachungsmonitor für Prozessoren
Comment[el]=Ένας επόπτης χρήσης ΚΜΕ
Comment[en_GB]=A CPU usage monitor
Comment[eo]=Monitoro de procezila uzo
Comment[es]=Monitor de uso de la CPU
Comment[et]=Protsessori kasutuse jälgija
Comment[eu]=PUZaren erabilera-monitorea
Comment[fi]=Näyttää suoritinten käytön
Comment[fr]=Une surveillance de l'usage du processeur
Comment[fy]=In CPU brûkme monitor
Comment[ga]=Monatóir úsáid an LAP
Comment[gl]=Un vixilante da utilización da CPU
Comment[gu]=CPU
Comment[he]=מנטר שימוש במעבד
Comment[hi]=
Comment[hne]=
Comment[hr]=Nadzor korištenja procesora
Comment[hsb]=Monitor, kiž pokazuje wućeženosć procesora
Comment[hu]=Kijelzi a CPU állapotát
Comment[ia]=Un monitor del usage de CPU
Comment[id]=Monitor penggunaan CPU
Comment[is]=Eftirlit með notkun örgjörva
Comment[it]=Indica l'uso della CPU
Comment[ja]=CPU 使
Comment[kk]=Процессордың жүктелісін бақылау
Comment[km]=
Comment[kn]= CPU ಿ
Comment[ko]=CPU
Comment[lt]=CPU apkrovos stebėtojas
Comment[lv]=Procesora noslogojuma novērotājs
Comment[mk]=Монитор на користењето на процесорот
Comment[ml]=ിി ി
Comment[mr]=CPU ि
Comment[nb]=En overvåker for prosessorbruk
Comment[nds]=En Kieker för den CPU-Bruuk
Comment[nl]=Volgt het CPU-gebruik
Comment[nn]=Overvaking av prosessorbruk
Comment[or]=ି CPU ିି ିି
Comment[pa]= CPU
Comment[pl]=Monitor użycia procesora
Comment[pt]=Um monitor da utilização do CPU
Comment[pt_BR]=Um monitor de utilização da CPU
Comment[ro]=Monitor de utilizare a procesorului
Comment[ru]=Монитор использования процессора
Comment[si]=CPU
Comment[sk]=Monitor využitia CPU
Comment[sl]=Nadzornik obremenjenosti procesorja
Comment[sr]=Надгледање употребе процесора
Comment[sr@ijekavian]=Надгледање употребе процесора
Comment[sr@ijekavianlatin]=Nadgledanje upotrebe procesora
Comment[sr@latin]=Nadgledanje upotrebe procesora
Comment[sv]=Övervakning av processoranvändning
Comment[ta]=A CPU usage monitor
Comment[tg]=Монитори истифодабарии манбаъи система
Comment[th]=
Comment[tr]=Bir işlemci kullanımı izleyici
Comment[ug]=CPU ئىشلىتىشنى كۆزەتكۈچ
Comment[uk]=Монітор використання процесора
Comment[wa]=On corwaitoe di l' eployaedje del CPU
Comment[x-test]=xxA CPU usage monitorxx
Comment[zh_CN]=CPU
Comment[zh_TW]=CPU 使
Type=Service
Icon=cpu
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_sm_cpu
X-KDE-PluginInfo-Author=Petri Damstén
X-KDE-PluginInfo-Email=damu@iki.fi
X-KDE-PluginInfo-Name=sm_cpu
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,107 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Hard Disk Space Usage
Name[bs]=Iskorisenost Hard diska
Name[ca]=Ús d'espai de disc dur
Name[ca@valencia]=Ús d'espai de disc dur
Name[cs]=Využití místa na pevném disku
Name[da]=Brug af harddiskplads
Name[de]=Festplattenbelegung
Name[el]=Χρήση χώρου σκληρού δίσκου
Name[en_GB]=Hard Disk Space Usage
Name[es]=Espacio usado en el disco duro
Name[et]=Kõvaketta ruumikasutus
Name[eu]=Disko gogorreko lekuaren erabilera
Name[fi]=Kiintolevyjen tilankäyttö
Name[fr]=Utilisation de l'espace des disques dur
Name[gl]=Uso do espazo do disco duro
Name[he]=השימוש בדיסק
Name[hu]=Lemezterület használat
Name[ia]=Usage de spatio del disco dur
Name[it]=Spazio del disco fisso
Name[kk]=Қатқыл дискідегі пайдаланған орын
Name[km]=
Name[ko]=
Name[lt]=Kietojo disko panaudojimas
Name[mr]= ि
Name[nb]=Plassbruk for harddisk
Name[nds]=Fastplaat-Bruuk
Name[nl]=Ruimtegebruik van de harde schijf
Name[pa]= ਿ
Name[pl]=Wykorzystanie przestrzeni dysku twardego
Name[pt]=Utilização do Disco Rígido
Name[pt_BR]=Uso do espaço do disco rígido
Name[ro]=Utilizarea spațiului pe discul dur
Name[ru]=Использование места на диске
Name[sk]=Využitie miesta na pevnom disku
Name[sl]=Uporaba prostora na trdem disku
Name[sr]=заузеће хард диска
Name[sr@ijekavian]=заузеће хард диска
Name[sr@ijekavianlatin]=zauzeće hard diska
Name[sr@latin]=zauzeće hard diska
Name[sv]=Utrymmesanvändning för hårddisk
Name[tr]=Sabit Disk Alanı Kullanımı
Name[uk]=Використання місця на диску
Name[vi]=S dng không gian đĩa
Name[x-test]=xxHard Disk Space Usagexx
Name[zh_CN]=使
Name[zh_TW]=使
Comment=An applet that monitors hard disk space usage and percentage
Comment[bs]=Aplet koji prati hard korištenje prostora na disku i postotak
Comment[ca]=Una miniaplicació que controla l'ús d'espai del disc dur i el tant per cent
Comment[ca@valencia]=Una miniaplicació que controla l'ús d'espai del disc dur i el tant per cent
Comment[cs]=Aplet, jenž monitoruje zaplnění místa na disku
Comment[da]=En applet som overvåger brug af harddiskplads og procent ledig plads
Comment[de]=Ein Miniprogramm, das die Festplattenbelegung absolut und in Prozent überwacht
Comment[el]=Μικροεφαρμογή που εποπτεύει την ποσοτική και ποσοστιαία χρήση χώρου του σκληρού δίσκου
Comment[en_GB]=An applet that monitors hard disk space usage and percentage
Comment[es]=Una miniaplicación que monitoriza el uso y porcentaje del espacio en disco duro
Comment[et]=Kõvaketta ruumikasutust ja protsenti jälgiv aplett
Comment[eu]=Disko gogorreko lekuaren erabilera eta ehunekoa kontrolatzen dituen miniaplikazio bat
Comment[fi]=Sovelma, joka näyttää kiintolevyjen tilankäytön ja sen prosenttiosuuden
Comment[fr]=Une applet surveillant l'utilisation de l'espace des disques durs et donnant des pourcentages
Comment[gl]=Unha applet que vixía o espazo usado do disco duro e a porcentaxe
Comment[hu]=Egy kisalkalmazás, amely figyeli a merevlemez használatot és százalékot
Comment[ia]=Un applet que monitora usage e percentage de spatio de disco dur
Comment[it]=Un'applet che controlla l'uso dello spazio su disco fisso
Comment[kk]=Қатқыл дискідегі пайдаланған орын және пайызын бақылау аплеті
Comment[km]=
Comment[ko]= 릿
Comment[lt]=Programėlė, kuri stebi disko vietos panaudojimą ir procentinį santykį
Comment[mr]= ि ि
Comment[nb]=Et miniprogram som overvåker bruk av plass på harddisk, og prosentvis
Comment[nds]=En Lüttprogramm, dat den Fastplaat-Bruuk afsluuts un in Perzent beluert
Comment[nl]=Een applet die het ruimtegebruik van de harde schijf volgt
Comment[pa]=ਿ, ਿ ਿ ਿ
Comment[pl]=Aplet, który monitoruje wykorzystaną przestrzeń i procent wykorzystania dysku twardego
Comment[pt]=Uma 'applet' que vigia a utilização e percentagem do disco
Comment[pt_BR]=Monitora o uso do espaço do disco rígido e a porcentagem
Comment[ro]=Miniaplicație ce monitorizează gradul de utilizare a discului dur
Comment[ru]=Мониторинг используемого дискового пространства
Comment[sk]=Applet, ktorý monitoruje použitie miesta na pevnom disku a percentá
Comment[sl]=Aplet, ki nadzoruje uporabo prostora na trdem disku
Comment[sr]=Аплет за надгледање заузећа хард диска
Comment[sr@ijekavian]=Аплет за надгледање заузећа хард диска
Comment[sr@ijekavianlatin]=Aplet za nadgledanje zauzeća hard diska
Comment[sr@latin]=Aplet za nadgledanje zauzeća hard diska
Comment[sv]=Ett miniprogram som övervakar hårddiskutrymme och procent
Comment[tr]=Sabit disk kullanımını izleyen ve yüzde olarak gösteren bir programcık
Comment[uk]=Аплет, який стежить за використанням місця на диску
Comment[vi]=Mt ng dng nh qun lý phn trăm s dng không gian đĩa
Comment[x-test]=xxAn applet that monitors hard disk space usage and percentagexx
Comment[zh_CN]=使
Comment[zh_TW]=使
Type=Service
Icon=drive-harddisk
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_sm_hdd
X-KDE-PluginInfo-Author=Petri Damstén
X-KDE-PluginInfo-Email=damu@iki.fi
X-KDE-PluginInfo-Name=sm_hdd
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,110 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Hard Disk I/O Monitor
Name[bs]=Hard Disk I/O Monitor
Name[ca]=Controlador d'E/S de disc dur
Name[ca@valencia]=Controlador d'E/S de disc dur
Name[cs]=Monitor I/O pevného disku
Name[da]=Overvågning af harddisk-I/O
Name[de]=Überwachungsmonitor für Festplattenein- und ausgabe
Name[el]=Επόπτης χρήσης του σκληρού δίσκου
Name[en_GB]=Hard Disk I/O Monitor
Name[es]=Monitor de E/S del disco duro
Name[et]=Kõvaketta sisendi/väljundi jälgija
Name[eu]=Disko gogorreko S/I monitorea
Name[fi]=Kiintolevyjen käyttöilmaisin
Name[fr]=Une surveillance des entrées / sorties des disques durs
Name[ga]=Monatóir I/A Diosca Crua
Name[gl]=Vixilante da E/S do disco duro
Name[he]=מנטר שימוש בכונן הקשיח
Name[hu]=Merevlemez I/O monitor
Name[ia]=Monitor de I/E del disco dur
Name[it]=Uso del disco fisso
Name[kk]=Қатқыл дискінің Е/Ш бақылауы
Name[km]= I/O
Name[ko]= I/O
Name[lt]=Kietojo disko I/O stebėtojas
Name[mr]= ि I/O ि
Name[nb]=En overvåker for disk-I/U
Name[nds]=Fastplaat-I/O-Beluern
Name[nl]=Volgt de activiteit van de harde schijf
Name[pa]= ਿ I/O
Name[pl]=Monitor WE/WY dysku twardego
Name[pt]=Monitor de E/S do Disco
Name[pt_BR]=Monitor de E/S do disco rígido
Name[ro]=Monitor pentru utilizarea discului dur
Name[ru]=Монитор ввода-вывода жестких дисков
Name[sk]=Monitor I/O pevného disku
Name[sl]=Nadzornik V/I trdega diska
Name[sr]=Надгледање У/Ија харддиска
Name[sr@ijekavian]=Надгледање У/Ија харддиска
Name[sr@ijekavianlatin]=Nadgledanje U/Ija harddiska
Name[sr@latin]=Nadgledanje U/Ija harddiska
Name[sv]=Övervakning av in- och utmatning för hårddisk
Name[tr]=Sabit Disk G/Ç İzleyici
Name[uk]=Монітор роботи жорсткого диска
Name[vi]=Trình qun lý I/O đĩa cng
Name[x-test]=xxHard Disk I/O Monitorxx
Name[zh_CN]= I/O
Name[zh_TW]=使 I/O
Comment=An applet that monitors hard disk throughput and input/output
Comment[bs]=Aplet koji prati hard disk protok ulaz / izlaz
Comment[ca]=Una miniaplicació que controla la velocitat de transferència de dades del disc dur i l'entrada/sortida
Comment[ca@valencia]=Una miniaplicació que controla la velocitat de transferència de dades del disc dur i l'entrada/eixida
Comment[cs]=Aplet, jenž monitoruje propustnost disku a vstup/výstup
Comment[da]=En applet som overvåger gennemgang og input/output for harddisken
Comment[de]=Ein Miniprogramm, das den Festplattendurchsatz und die Festplattenein- und -ausgabe überwacht
Comment[el]=Μικροεφαρμογή που εποπτεύει τη ρυθμοαπόδοση και την είσοδο/έξοδο του σκληρού δίσκου
Comment[en_GB]=An applet that monitors hard disk throughput and input/output
Comment[es]=Una miniaplicación que monitoriza el rendimiento y la entrada/salida del disco duro
Comment[et]=Kõvaketta läbilaset ja sisendit/väljundit jälgiv aplett
Comment[eu]=Disko gogorraren errendimendua eta sarrera/irteera kontrolatzen dituen miniaplikazio bat
Comment[fi]=Sovelma joka tarkkailee kiintolevyjen suoritustehoa ja siirtomäärää
Comment[fr]=Une applet surveillant l'activité des disques durs et de leurs entrées / sorties
Comment[gl]=Unha applet que vixía o rendemento e a entrada/saída
Comment[hu]=Egy kisalkalmazás, amely figyeli a merevlemez átvitelét és a bemenetet/kimenetet
Comment[ia]=Un applet que que monitora le prestation (throughput) e ingresso/egresso de disco dur
Comment[it]=Un'applet che controlla le prestazioni e l'uso del disco fisso
Comment[kk]=Дискінің белсендігі және енгізу/шығаруды бақылау апплеті
Comment[km]= /
Comment[ko]= I/O 릿
Comment[lt]=Programėlė, kuri stebi disko apkrovimą ir įvestį/išvestį
Comment[mr]= ि ि
Comment[nb]=Et miniprogram som overvåker dataflyt til og fra harddisk
Comment[nds]=En Lüttprogramm, dat den Fastplaat-Dörsatz un de In- un Utgaven beluert
Comment[nl]=Een applet die de activiteit van de harde schijf volgt
Comment[pa]= ਿ / ਿ ਿ
Comment[pl]=Aplet, który monitoruje przepustowość wejścia/wyjścia dysku twardego
Comment[pt]=Uma 'applet' que vigia o rendimento e o fluxo de entrada-saída do disco
Comment[pt_BR]=Monitora a taxa de transferência e entrada/saída do disco rígido
Comment[ro]=Miniaplicație ce monitorizează traficul de intrare și cel de ieșire pentru discul dur
Comment[ru]=Мониторинг пропускной способности и процессов ввода/вывода жестких дисков
Comment[sk]=Applet, ktorý monitoruje priepustnosť pevného disku a vstup/výstup
Comment[sl]=Aplet, ki nadzoruje prepustnost in vhod/izhod trdega diska
Comment[sr]=Аплет за надгледање пропусности и улаза/излаза харддиска
Comment[sr@ijekavian]=Аплет за надгледање пропусности и улаза/излаза харддиска
Comment[sr@ijekavianlatin]=Aplet za nadgledanje propusnosti i ulaza/izlaza harddiska
Comment[sr@latin]=Aplet za nadgledanje propusnosti i ulaza/izlaza harddiska
Comment[sv]=Ett miniprogram som övervakar hårddiskprestanda samt in- och utmatning
Comment[tr]=Sabit diski girdi/çıktı olarak izleyen bir programcık
Comment[uk]=Аплет, який стежить за даними, які записуються на жорсткий диск та читаються з жорсткого диска
Comment[vi]=Mt ng dng nh qun lý d liu vào/ra trên đĩa cng
Comment[x-test]=xxAn applet that monitors hard disk throughput and input/outputxx
Comment[zh_CN]=
Comment[zh_TW]= I/O
Type=Service
Icon=drive-harddisk
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_sm_hdd_activity
X-KDE-PluginInfo-Author=Shaun Reich
X-KDE-PluginInfo-Email=shaun.reich@kdemail.net
X-KDE-PluginInfo-Name=sm_hdd_activity
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,154 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Hardware Info
Name[ar]=معلومات العتاد
Name[ast]=Información del hardware
Name[bg]=Хардуерни данни
Name[bs]=podaci o hardveru
Name[ca]=Informació del maquinari
Name[ca@valencia]=Informació del maquinari
Name[cs]=Informace o hardware
Name[da]=Hardwareinfo
Name[de]=Hardwareinformationen
Name[el]=Πληροφορίες υλικού
Name[en_GB]=Hardware Info
Name[es]=Información del hardware
Name[et]=Riistvara teave
Name[eu]=Hardwareari buruzko informazioa
Name[fi]=Laitteistotiedot
Name[fr]=Informations sur le matériel
Name[ga]=Faisnéis Crua-Earraí
Name[gl]=Información do hardware
Name[gu]=
Name[he]=מידע אודות חומרה
Name[hi]=
Name[hr]=Informacije o hardveru
Name[hu]=Hardverjellemzők
Name[ia]=Info de hardware
Name[id]=Info Peranti Keras
Name[is]=Vélbúnaðarupplýsingar
Name[it]=Informazioni sull'hardware
Name[ja]=
Name[kk]=Жабдық мәліметі
Name[km]=
Name[kn]= ಿಿ
Name[ko]=
Name[lt]=Aparatinės įrangos informacija
Name[lv]=Aparatūras informācija
Name[mr]= ि
Name[nb]=Maskinvareinformasjon
Name[nds]=Reedschap-Informatschonen
Name[nl]=Hardware-informatie
Name[pa]=
Name[pl]=Informacje o sprzęcie
Name[pt]=Informação do 'Hardware'
Name[pt_BR]=Informações do hardware
Name[ro]=Informații echipament
Name[ru]=Оборудование компьютера
Name[si]=
Name[sk]=Informácie o hardvéri
Name[sl]=Podatki o strojni opremi
Name[sr]=подаци о хардверу
Name[sr@ijekavian]=подаци о хардверу
Name[sr@ijekavianlatin]=podaci o hardveru
Name[sr@latin]=podaci o hardveru
Name[sv]=Hårdvaruinformation
Name[tg]=Иттилооти сахтафзор
Name[th]=
Name[tr]=Donanım Bilgileri
Name[ug]=قاتتىق دېتال ئۇچۇرى
Name[uk]=Відомості про обладнання
Name[vi]=Thông tin phn cng
Name[wa]=Info so l' éndjolreye
Name[x-test]=xxHardware Infoxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Show hardware info
Comment[ar]=يظهر معلومات العتاد
Comment[ast]=Amosar información d'hardware
Comment[be@latin]=Pakazvaje źviestki pra aparaturu
Comment[bg]=Показване на данни за хардуера
Comment[bn]=
Comment[bs]=Podaci o hardveru
Comment[ca]=Mostra la informació del maquinari
Comment[ca@valencia]=Mostra la informació del maquinari
Comment[cs]=Zobrazit informace o hardwaru
Comment[csb]=Wëskrzëniô wëdowiédzã ò hardwôrze
Comment[da]=Vis hardwareinformation
Comment[de]=Zeigt Informationen zu bestimmten Geräten an.
Comment[el]=Εμφάνιση πληροφοριών υλικού
Comment[en_GB]=Show hardware info
Comment[eo]=Montri aparatajn informojn
Comment[es]=Mostrar información de hardware
Comment[et]=Riistvarainfo näitamine
Comment[eu]=Erakutsi hardwareari buruzko informazioa
Comment[fi]=Näyttää laitteistotiedot
Comment[fr]=Affiche des informations sur le matériel
Comment[fy]=Hardware ynfo sjen litte
Comment[ga]=Taispeáin eolas faoi na crua-earraí
Comment[gl]=Mostra información acerca do hardware
Comment[gu]= િ
Comment[he]=משמש להצגת מידע אודות חומרה
Comment[hi]= ि
Comment[hne]=
Comment[hr]=Prikaz informacija o hardveru
Comment[hsb]=Pokazuje informaciju wo hardware
Comment[hu]=Hardverjellemzők
Comment[ia]=Monstra info del hardware
Comment[id]=Tampilkan info peranti keras
Comment[is]=Sýna upplýsingar um vélbúnað
Comment[it]=Mostra informazioni sull'hardware
Comment[ja]=
Comment[kk]=Жабдықтар мәліметін қарау
Comment[km]=
Comment[kn]= ಿಿ ಿ
Comment[ko]=
Comment[lt]=Rodyti aparatinės įrangos informaciją
Comment[lv]=Rāda aparatūras informāciju
Comment[mk]=Прикажува информации за хардверот
Comment[ml]= ി ി
Comment[mr]= ि
Comment[nb]=Vis maskinvareinformasjon
Comment[nds]=Hardware-Infos wiesen
Comment[nl]=Geeft informatie over uw hardware
Comment[nn]=Vis maskinvareinfo
Comment[or]=
Comment[pa]=
Comment[pl]=Pokazywanie informacji o sprzęcie
Comment[pt]=Mostrar informações sobre o 'hardware'
Comment[pt_BR]=Mostra informações do hardware
Comment[ro]=Afișează informații despre echipamentul fizic
Comment[ru]=Показ сведений об оборудовании
Comment[si]=
Comment[sk]=Zobrazenie informácií o hardvéri
Comment[sl]=Prikaz podatkov o strojni opremi
Comment[sr]=Подаци о хардверу
Comment[sr@ijekavian]=Подаци о хардверу
Comment[sr@ijekavianlatin]=Podaci o hardveru
Comment[sr@latin]=Podaci o hardveru
Comment[sv]=Visa hårdvaruinformation
Comment[ta]=Show hardware info
Comment[te]=
Comment[tg]=Намоиши иттилооти сахтафзор
Comment[th]=
Comment[tr]=Donanım bilgilerini göster
Comment[ug]=قاتتىق دېتال ئۇچۇرىنى كۆرسەت
Comment[uk]=Показати інформацію про обладнання
Comment[wa]=Mostrer les pondants et les djondants di l' éndjolreye
Comment[x-test]=xxShow hardware infoxx
Comment[zh_CN]=
Comment[zh_TW]=
Type=Service
Icon=hwinfo
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_sm_hwinfo
X-KDE-PluginInfo-Author=Petri Damstén
X-KDE-PluginInfo-Email=damu@iki.fi
X-KDE-PluginInfo-Name=sm_hwinfo
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,153 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Network Monitor
Name[ar]=مراقب الشبكة
Name[ast]=Monitor de rede
Name[bg]=Наблюдение на мрежата
Name[bs]=nadzor mreže
Name[ca]=Controlador de la xarxa
Name[ca@valencia]=Controlador de la xarxa
Name[cs]=Monitor sítě
Name[da]=Netværksovervågning
Name[de]=Netzwerküberwachung
Name[el]=Επίβλεψη δικτύου
Name[en_GB]=Network Monitor
Name[es]=Monitor de red
Name[et]=Võrgujälgija
Name[eu]=Sareko monitorea
Name[fi]=Verkon käyttö
Name[fr]=Surveillance du réseau
Name[ga]=Monatóir an Líonra
Name[gl]=Vixilante da rede
Name[gu]= િ
Name[he]=מוניטור רשת
Name[hi]=
Name[hr]=Nadzornik mreže
Name[hu]=Hálózatfigyelő
Name[ia]=Monitor de Rete
Name[id]=Monitor Jaringan
Name[is]=Netkerfisvaktari
Name[it]=Monitor di rete
Name[ja]=
Name[kk]=Желіні бақылау
Name[km]=
Name[kn]= ಿ
Name[ko]=
Name[lt]=Tinklo stebėjimo priemonė
Name[lv]=Tīkla monitors
Name[mr]= ि
Name[nb]=Nettverksovervåker
Name[nds]=Nettwark-Kieker
Name[nl]=Netwerkmonitor
Name[nn]=Nettverksovervaking
Name[pa]= ਿ
Name[pl]=Monitor sieci
Name[pt]=Monitor da Rede
Name[pt_BR]=Monitor da rede
Name[ro]=Monitor de rețea
Name[ru]=Сетевой монитор
Name[se]=Fierbmi
Name[si]=
Name[sk]=Monitor siete
Name[sl]=Nadzornik omrežja
Name[sr]=надзор мреже
Name[sr@ijekavian]=надзор мреже
Name[sr@ijekavianlatin]=nadzor mreže
Name[sr@latin]=nadzor mreže
Name[sv]=Nätverksövervakning
Name[tg]=Монитори шабака
Name[th]=
Name[tr]=Ağ İzleyici
Name[ug]=تور كۆزەتكۈچ
Name[uk]=Монітор мережі
Name[wa]=Corwaitoe del rantoele
Name[x-test]=xxNetwork Monitorxx
Name[zh_CN]=
Name[zh_TW]=
Comment=A network usage monitor
Comment[ar]=يراقب استعمال الشبكة
Comment[ast]=Monitor d'usu de la rede
Comment[be@latin]=Nazirańnik zaniataści sietki
Comment[bg]=Наблюдение на изпозлването на мрежата
Comment[bs]=Nadgledanje upotrebe mreže
Comment[ca]=Un controlador d'ús de la xarxa
Comment[ca@valencia]=Un controlador d'ús de la xarxa
Comment[cs]=Monitor využití sítě
Comment[csb]=Mònitór brëkòwaniô sécë
Comment[da]=Overvågning af netværkstrafik
Comment[de]=Ein Überwachungsmonitor für Netzwerke
Comment[el]=Ένας επόπτης χρήσης του δικτύου
Comment[en_GB]=A network usage monitor
Comment[es]=Monitor de uso de la red
Comment[et]=Võrgukasutuse jälgija
Comment[eu]=Sarearen erabileraren monitorea
Comment[fi]=Näyttää verkon käytön
Comment[fr]=Surveillance de l'usage réseau
Comment[fy]=In netwurk brûkme monitor
Comment[ga]=Monatóir úsáide an líonra
Comment[gl]=Un vixilante do estado da rede
Comment[gu]= િિ
Comment[he]=משמש לניטור השימוש ברשת
Comment[hi]=
Comment[hne]=
Comment[hr]=Nadzor korištenja mreže
Comment[hsb]=Monitor, kiž pokazuje wućeženosć syće
Comment[hu]=Kijelzi a hálózat állapotát
Comment[ia]=Un monitor de usage de rete
Comment[id]=Monitor penggunaan jaringan
Comment[is]=Eftirlit með notkun netsins
Comment[it]=Indica l'uso della rete
Comment[ja]=
Comment[kk]=Желі пайдалануын бақылау
Comment[km]=
Comment[kn]= ಿ
Comment[ko]=
Comment[ku]=Temaşekerê rewşa torê
Comment[lt]=Tinklo naudojimo stebėtojas
Comment[lv]=Tīkla noslogojuma novērotājs
Comment[mk]=Монитор на користењето на мрежата
Comment[ml]= ി
Comment[mr]= ि
Comment[nb]=En overvåker for nettverksbruk
Comment[nds]=En Kieker för den Nettwark-Bruuk
Comment[nl]=Toont het netwerkgebruik
Comment[nn]=Overvaking av nettverksbruk
Comment[or]=ି ିି ିି
Comment[pa]=
Comment[pl]=Monitor wykorzystania sieci
Comment[pt]=Um monitor da utilização da rede
Comment[pt_BR]=Um monitor de utilização da rede
Comment[ro]=Monitor de utilizare a rețelei
Comment[ru]=Монитор сетевой активности
Comment[si]=
Comment[sk]=Monitor využitia siete
Comment[sl]=Nadzornik uporabe omrežja
Comment[sr]=Надгледање употребе мреже
Comment[sr@ijekavian]=Надгледање употребе мреже
Comment[sr@ijekavianlatin]=Nadgledanje upotrebe mreže
Comment[sr@latin]=Nadgledanje upotrebe mreže
Comment[sv]=Övervakning av nätverksanvändning
Comment[ta]=ி
Comment[tg]=Состояние сервера Samba
Comment[th]=
Comment[tr]=Bir ağ kullanımı izleyici
Comment[ug]=تور ئىشلىتىشنى كۆزەتكۈچ
Comment[uk]=Монітор використання мережі
Comment[wa]=On corwaitoe di l' eployaedje del rantoele
Comment[x-test]=xxA network usage monitorxx
Comment[zh_CN]=
Comment[zh_TW]=使
Type=Service
Icon=network-workgroup
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_sm_net
X-KDE-PluginInfo-Author=Petri Damstén
X-KDE-PluginInfo-Email=damu@iki.fi
X-KDE-PluginInfo-Name=sm_net
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,147 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Memory Status
Name[ar]=حالة الذاكرة
Name[ast]=Estáu de la memoria
Name[bg]=Състояние на паметта
Name[bs]=stanje memorije
Name[ca]=Estat de la memòria
Name[ca@valencia]=Estat de la memòria
Name[cs]=Stav paměti
Name[da]=Hukommelsesstatus
Name[de]=Speicherstatus
Name[el]=Κατάσταση μνήμης
Name[en_GB]=Memory Status
Name[es]=Estado de la memoria
Name[et]=Mälu olek
Name[eu]=Memoria-egoera
Name[fi]=Muistin käyttö
Name[fr]=État de la mémoire
Name[ga]=Stádas Cuimhne
Name[gl]=Estado da memoria
Name[gu]= િિિ
Name[he]=מצב הזיכרון
Name[hi]= िि
Name[hr]=Stanje memorije
Name[hu]=Memóriaállapot
Name[ia]=Stato de memoria
Name[id]=Memori Status
Name[is]=Staða minnis
Name[it]=Stato della memoria
Name[ja]=
Name[kk]=Жад күй-жайы
Name[km]=
Name[kn]=ಿ (ಿ) ಿಿ
Name[ko]=
Name[lt]=Atminties būsena
Name[lv]=Atmiņas statuss
Name[mr]=ि िि
Name[nb]=Minnestatus
Name[nds]=Spieker-Status
Name[nl]=Geheugen-status
Name[pa]=
Name[pl]=Stan pamięci
Name[pt]=Estado da Memória
Name[pt_BR]=Status da memória
Name[ro]=Stare memorie
Name[ru]=Использование памяти
Name[si]=
Name[sk]=Stav pamäte
Name[sl]=Stanje pomnilnika
Name[sr]=стање меморије
Name[sr@ijekavian]=стање меморије
Name[sr@ijekavianlatin]=stanje memorije
Name[sr@latin]=stanje memorije
Name[sv]=Minnesstatus
Name[tg]=Ҳолати хотира
Name[th]=
Name[tr]=Bellek Durumu
Name[ug]=ئەسلەك ھالىتى
Name[uk]=Стан памяті
Name[wa]=Estat del memwere
Name[x-test]=xxMemory Statusxx
Name[zh_CN]=
Name[zh_TW]=
Comment=A RAM usage monitor
Comment[ar]=مراقب استعمال الذاكرة العشوائية
Comment[ast]=Monitor d'usu de la RAM
Comment[bg]=Изпозлване на оперативната памет (RAM)
Comment[bs]=Nadgledanje upotrebe RAMa
Comment[ca]=Un controlador d'ús de la RAM
Comment[ca@valencia]=Un controlador d'ús de la RAM
Comment[cs]=Monitor využití RAM
Comment[csb]=Mònitór brëkòwaniô pamiãcë RAM
Comment[da]=Overvågning af ram-forbrug
Comment[de]=Ein Überwachungsmonitor für den Arbeitsspeicher
Comment[el]=Ένας επόπτης χρήσης μνήμης RAM
Comment[en_GB]=A RAM usage monitor
Comment[eo]=RAM uzada rigardilo
Comment[es]=Monitor de uso de la RAM
Comment[et]=RAM-i kasutuse jälgija
Comment[eu]=RAMaen erabileraren monitorea
Comment[fi]=Näyttää muistin käytön
Comment[fr]=Une surveillance de l'usage de la mémoire vive
Comment[fy]=In RAM brûkme monitor
Comment[ga]=Monatóir úsáid RAM
Comment[gl]=Un vixilante do utilización da memoria RAM
Comment[gu]=
Comment[he]=משמש לניטור השימוש בזיכרון ה־RAM
Comment[hi]=
Comment[hr]=Nadzor korištenja RAM memorije
Comment[hu]=Memóriahasználat-figyelő
Comment[ia]=Un monitor del usage de RAM
Comment[id]=Monitor penggunaan RAM
Comment[is]=Eftirlit með notkun vinnsluminnis
Comment[it]=Indica l'uso della RAM
Comment[ja]=RAM 使
Comment[kk]=Жадыны пайдалануын бақылау
Comment[km]=
Comment[kn]=RAM ಿ
Comment[ko]=RAM
Comment[lt]=RAM naudojimo stebėtojas
Comment[lv]=Atmiņas izmantotāja novērotājs
Comment[mai]=
Comment[mk]=Монитор на користењето на меморијата
Comment[ml]= ി
Comment[mr]=RAM ि
Comment[nb]=En overvåker for RAM-bruk
Comment[nds]=En Kieker för den RAM-Bruuk
Comment[nl]=Volgt het RAM-gebruik
Comment[nn]=Overvaking av minnebruk
Comment[pa]= RAM
Comment[pl]=Monitor wykorzystania pamięci RAM
Comment[pt]=Um monitor da utilização da RAM
Comment[pt_BR]=Um monitor de utilização da RAM
Comment[ro]=Monitor pentru utilizarea memoriei
Comment[ru]=Монитор использования оперативной памяти
Comment[si]=RAM
Comment[sk]=Monitor využitia RAM
Comment[sl]=Nadzornik porabe pomnilnika
Comment[sr]=Надгледање употребе РАМа
Comment[sr@ijekavian]=Надгледање употребе РАМа
Comment[sr@ijekavianlatin]=Nadgledanje upotrebe RAMa
Comment[sr@latin]=Nadgledanje upotrebe RAMa
Comment[sv]=Övervakning av minnesanvändning
Comment[tg]=Монитори истифодабарии манбаъи система
Comment[th]=
Comment[tr]=Bir bellek kullanımı izleyici
Comment[ug]=RAM ئىشلىتىشنى كۆزەتكۈچ
Comment[uk]=Монітор використання памяті
Comment[wa]=On corwaitoe di l' eployaedje del RAM
Comment[x-test]=xxA RAM usage monitorxx
Comment[zh_CN]=RAM
Comment[zh_TW]=使
Type=Service
Icon=media-flash
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_sm_ram
X-KDE-PluginInfo-Author=Petri Damstén
X-KDE-PluginInfo-Email=damu@iki.fi
X-KDE-PluginInfo-Name=sm_ram
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,152 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Hardware Temperature
Name[ar]=حرارة العتاد
Name[ast]=Temperatura del hardware
Name[bg]=Температура на хардуера
Name[bs]=temperatura hardvera
Name[ca]=Temperatura del maquinari
Name[ca@valencia]=Temperatura del maquinari
Name[cs]=Teplota hardwaru
Name[da]=Hardwaretemperatur
Name[de]=Hardwaretemperatur
Name[el]=Θερμοκρασία Υλικού
Name[en_GB]=Hardware Temperature
Name[es]=Temperatura del hardware
Name[et]=Riistvara temperatuur
Name[eu]=Hardwarearen tenperatura
Name[fi]=Laitteiston lämpötilat
Name[fr]=Température du matériel
Name[ga]=Teocht na gCrua-Earraí
Name[gl]=Temperatura do hardware
Name[he]=טמפרטורת חומרה
Name[hi]=
Name[hr]=Temperatura hardvera
Name[hu]=Hardverhőmérséklet
Name[ia]=Temperatura Hardware
Name[id]=Temperatur Peranti Keras
Name[is]=Hitastig vélbúnaðar
Name[it]=Temperatura dell'hardware
Name[ja]=
Name[kk]=Жабдықтың температурасы
Name[km]=
Name[kn]=
Name[ko]=
Name[lt]=Techninės įrangos temperatūra
Name[lv]=Aparatūras temperatūra
Name[mr]=
Name[nb]=Maskintemperatur
Name[nds]=Reedschap-Temperatuur
Name[nl]=Hardware temperatuur
Name[pa]=
Name[pl]=Temperatura sprzętu
Name[pt]=Temperatura do 'Hardware'
Name[pt_BR]=Temperatura do hardware
Name[ro]=Temperatură echipament
Name[ru]=Температурные датчики
Name[si]=
Name[sk]=Teplota hardvéru
Name[sl]=Temperatura strojne opreme
Name[sr]=температура хардвера
Name[sr@ijekavian]=температура хардвера
Name[sr@ijekavianlatin]=temperatura hardvera
Name[sr@latin]=temperatura hardvera
Name[sv]=Hårdvarutemperatur
Name[tg]=Ҳарорати сахтафзор
Name[th]=
Name[tr]=Donanım Sıcaklığı
Name[ug]=قاتتىق دېتال تېمپېراتۇرىسى
Name[uk]=Температура обладнання
Name[vi]=Nhit đ phn cng
Name[wa]=Tchåleur di l' éndjolreye
Name[x-test]=xxHardware Temperaturexx
Name[zh_CN]=
Name[zh_TW]=
Comment=A system temperature monitor
Comment[ar]=يراقب حرارة النظام
Comment[ast]=Monitor de la temperatura del sistema
Comment[be@latin]=Nazirańnik za temperaturaju systemy
Comment[bg]=Наблюдение на температурата на компютъра
Comment[bs]=Nadgledanje temperature sistema
Comment[ca]=Un controlador de la temperatura del sistema
Comment[ca@valencia]=Un controlador de la temperatura del sistema
Comment[cs]=Monitor teploty systému
Comment[csb]=Mònitór temperaturë systemë
Comment[da]=Overvågning af systemtemperatur
Comment[de]=Ein Überwachungsmonitor für Temperatursensoren
Comment[el]=Ένας επόπτης θερμοκρασίας του συστήματος
Comment[en_GB]=A system temperature monitor
Comment[eo]=Systema temperatura rigardilo
Comment[es]=Monitor de la temperatura del sistema
Comment[et]=Süsteemi temperatuuri jälgija
Comment[eu]=Sistemaren tenperaturaren monitorea
Comment[fi]=Näyttää järjestelmän lämpötilat
Comment[fr]=Une surveillance de la température du système
Comment[fy]=In systeemtempratuer monitor
Comment[ga]=Monatóir theocht an chórais
Comment[gl]=Un vixilante da temperatura do sistema
Comment[gu]=િ
Comment[he]=משמש לניטור טמפרטורת המערכת
Comment[hi]=
Comment[hne]=
Comment[hr]=Nadzor temperature sustava
Comment[hsb]=Monitor za systemowu temparaturu
Comment[hu]=Kijelzi a rendszer jellemző hőmérsékleteit
Comment[ia]=Un monitor de temperatura de systema
Comment[id]=Monitor temperatur sistem
Comment[is]=Eftirlit með hitastigi í kerfinu
Comment[it]=Indica la temperatura del sistema
Comment[ja]=
Comment[kk]=Жүйек температурасын бақылау
Comment[km]=
Comment[kn]= ಿ
Comment[ko]=
Comment[lt]=Sistemos temperatūros stebėtojas
Comment[lv]=Sistēmas temperatūras novērotājs
Comment[mk]=Монитор на температурата на системот
Comment[ml]=ി ി ി
Comment[mr]= ि
Comment[nb]=En overvåker for systemtemperaturen
Comment[nds]=En Wachter för de Systeemtemperatuur
Comment[nl]=Volgt de systeemtemperatuur
Comment[nn]=Overvaking av systemtemperaturen
Comment[or]= ିି
Comment[pa]= ਿ
Comment[pl]=Monitor temperatury komputera
Comment[pt]=Um monitor da temperatura do sistema
Comment[pt_BR]=Um monitor da temperatura do sistema
Comment[ro]=Monitor de temperatură a sistemului
Comment[ru]=Монитор температуры разных узлов компьютера
Comment[si]=
Comment[sk]=Monitor teploty systému
Comment[sl]=Nadzornik temperature v sistemu
Comment[sr]=Надгледање температуре система
Comment[sr@ijekavian]=Надгледање температуре система
Comment[sr@ijekavianlatin]=Nadgledanje temperature sistema
Comment[sr@latin]=Nadgledanje temperature sistema
Comment[sv]=Övervakning av systemtemperatur
Comment[ta]=A system temperature monitor
Comment[tg]=Системный монитор KDE
Comment[th]=
Comment[tr]=Bir sistem sıcaklığı izleyici
Comment[ug]=سىستېما تېمپېراتۇرىسىنى كۆزەتكۈچ
Comment[uk]=Монітор системної температури
Comment[vi]=Mt trình qun lý nhit đ h thng
Comment[wa]=On corwaitoe del tchåleur do sistinme
Comment[x-test]=xxA system temperature monitorxx
Comment[zh_CN]=
Comment[zh_TW]=
Type=Service
Icon=view-statistics
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_sm_temperature
X-KDE-PluginInfo-Author=Petri Damstén
X-KDE-PluginInfo-Email=damu@iki.fi
X-KDE-PluginInfo-Name=sm_temperature
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,267 +0,0 @@
/*
* Copyright (C) 2010 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "plotter.h"
#include <Plasma/SignalPlotter>
#include <Plasma/Meter>
#include <Plasma/Theme>
#include <Plasma/Frame>
#include <KColorUtils>
#include <KGlobalSettings>
#include <QGraphicsLinearLayout>
#include <QWidget>
namespace SM {
Plotter::Plotter(QGraphicsItem* parent, Qt::WindowFlags wFlags)
: QGraphicsWidget(parent, wFlags)
, m_layout(nullptr)
, m_plotter(nullptr)
, m_meter(nullptr)
, m_plotCount(1)
, m_min(0.0)
, m_max(0.0)
, m_overlayFrame(nullptr)
, m_showAnalogValue(false)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
createWidgets();
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));
}
Plotter::~Plotter()
{
}
void Plotter::setAnalog(bool analog)
{
if (analog && m_layout->count() < 2) {
m_meter = new Plasma::Meter(this);
m_meter->setMeterType(Plasma::Meter::AnalogMeter);
m_meter->setLabelAlignment(1, Qt::AlignCenter);
m_layout->insertItem(0, m_meter);
m_meter->setMinimum(m_min);
m_meter->setMaximum(m_max);
m_meter->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
themeChanged();
} else if (m_layout->count() > 1) {
m_layout->removeAt(0);
delete m_meter;
m_meter = 0;
}
}
void Plotter::setMinMax(double min, double max)
{
if (m_meter) {
m_meter->setMinimum(min);
m_meter->setMaximum(max);
}
m_plotter->setUseAutoRange(false);
m_plotter->setVerticalRange(min, max);
m_min = min;
m_max = max;
}
const QString& Plotter::title()
{
return m_title;
}
void Plotter::setTitle(const QString& title)
{
m_plotter->setTitle(title);
if (m_meter) {
m_meter->setLabel(0, title);
}
m_title = title;
}
void Plotter::setUnit(const QString& unit)
{
m_plotter->setUnit(unit);
m_unit = unit;
}
void Plotter::setScale(qreal scale)
{
m_plotter->scale(scale);
}
void Plotter::setStackPlots(bool stack)
{
m_plotter->setStackPlots(stack);
}
void Plotter::setPlotCount(int count)
{
for (int i = 0; i < m_plotCount; ++i) {
m_plotter->removePlot(0);
}
m_plotCount = count;
Plasma::Theme* theme = Plasma::Theme::defaultTheme();
QColor text = theme->color(Plasma::Theme::TextColor);
QColor bg = theme->color(Plasma::Theme::BackgroundColor);
for (int i = 0; i < m_plotCount; ++i) {
QColor color = KColorUtils::tint(text, bg, 0.4 + ((double)i / 2.5));
m_plotter->addPlot(color);
}
}
void Plotter::setCustomPlots(const QList<QColor>& colors)
{
for (int i = 0; i < m_plotCount; ++i) {
m_plotter->removePlot(0);
}
m_plotCount = colors.count();
foreach (const QColor& color, colors) {
m_plotter->addPlot(color);
}
}
void Plotter::createWidgets()
{
m_layout = new QGraphicsLinearLayout(Qt::Horizontal);
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setSpacing(5);
setLayout(m_layout);
m_plotter = new Plasma::SignalPlotter(this);
m_plotter->setThinFrame(false);
m_plotter->setShowLabels(false);
m_plotter->setShowTopBar(true);
m_plotter->setShowVerticalLines(false);
m_plotter->setShowHorizontalLines(false);
m_plotter->setUseAutoRange(true);
m_plotter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_layout->addItem(m_plotter);
themeChanged();
setPlotCount(m_plotCount);
}
void Plotter::themeChanged()
{
Plasma::Theme* theme = Plasma::Theme::defaultTheme();
if (m_meter) {
m_meter->setLabelColor(0, theme->color(Plasma::Theme::TextColor));
m_meter->setLabelColor(0, theme->color(Plasma::Theme::TextColor));
m_meter->setLabelColor(1, QColor("#000"));
}
m_plotter->setFontColor(theme->color(Plasma::Theme::TextColor));
m_plotter->setSvgBackground("widgets/plot-background");
QColor linesColor = theme->color(Plasma::Theme::TextColor);
linesColor.setAlphaF(0.4);
m_plotter->setHorizontalLinesColor(linesColor);
m_plotter->setVerticalLinesColor(linesColor);
resizeEvent(0);
}
void Plotter::addSample(const QList<double>& values)
{
m_plotter->addSample(values);
QStringList list;
foreach (double value, values) {
double v = value / m_plotter->scaledBy();
list << QString("%1 %2").arg(v, 0, 'f', (v > 1000.0) ? 0 : 1).arg(m_unit);
}
setOverlayText(list.join(" / "));
if (m_meter) {
m_meter->setValue(values[0]);
}
}
void Plotter::setOverlayText(const QString& text)
{
if (!m_overlayFrame) {
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, m_plotter);
m_plotter->setLayout(layout);
m_overlayFrame = new Plasma::Frame(m_plotter);
m_overlayFrame->setZValue(10);
m_overlayFrame->resize(m_overlayFrame->size().height() * 2.5,
m_overlayFrame->size().height());
layout->addStretch();
QGraphicsLinearLayout* layout2 = new QGraphicsLinearLayout(Qt::Horizontal, layout);
layout2->addStretch();
layout2->addItem(m_overlayFrame);
layout2->addStretch();
layout->addItem(layout2);
resizeEvent(0);
}
m_overlayFrame->setText(text);
if (m_meter) {
if (m_showAnalogValue) {
m_meter->setLabel(1, text);
} else {
m_meter->setLabel(1, QString());
}
}
}
void Plotter::resizeEvent(QGraphicsSceneResizeEvent* event)
{
Q_UNUSED(event)
qreal h = size().height();
qreal fontHeight = h / (7.0 * 1.5); // Seven rows
Plasma::Theme* theme = Plasma::Theme::defaultTheme();
QFont font = theme->font(Plasma::Theme::DefaultFont);
QFont smallest = KGlobalSettings::smallestReadableFont();
bool show = false;
QFontMetrics metrics(font);
QStringList list;
for (int i = 0; i < m_plotCount; ++i) {
list << QString("888.0 %2").arg(m_unit);
}
QString valueText = list.join(" / ");
font.setPointSizeF(smallest.pointSizeF());
forever {
metrics = QFontMetrics(font);
if (metrics.height() > fontHeight) {
break;
}
font.setPointSizeF(font.pointSizeF() + 0.5);
show = true;
}
m_plotter->setFont(font);
m_plotter->setShowTopBar(metrics.height() < h / 6);
m_plotter->setShowLabels(show);
m_plotter->setShowHorizontalLines(show);
if (m_overlayFrame) {
m_overlayFrame->setVisible(metrics.height() < h / 3 &&
metrics.width(valueText) < size().width() * 0.8);
m_overlayFrame->setFont(font);
}
if (m_meter) {
m_meter->setLabelFont(0, font);
m_meter->setLabelFont(1, font);
// Make analog meter square
m_meter->setMinimumSize(h, 8);
m_showAnalogValue = (m_meter->size().width() * 0.7 > metrics.width(valueText));
if (m_meter->size().width() * 0.9 > metrics.width(m_title)) {
m_meter->setLabel(0, m_title);
} else {
m_meter->setLabel(0, QString());
}
m_meter->setLabel(1, QString());
}
}
} // namespace
#include "moc_plotter.cpp"

View file

@ -1,77 +0,0 @@
/*
* Copyright (C) 2010 Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SM_PLOTTER_HEADER
#define SM_PLOTTER_HEADER
#include <QGraphicsWidget>
#include "plasma_applet_system_monitor_export.h"
#include <QGraphicsLinearLayout>
namespace Plasma {
class Meter;
class SignalPlotter;
class Frame;
}
namespace SM {
class PLASMA_APPLET_SYSTEM_MONITOR_EXPORT Plotter : public QGraphicsWidget
{
Q_OBJECT
public:
Plotter(QGraphicsItem* parent = 0, Qt::WindowFlags wFlags = 0);
~Plotter();
void addSample(const QList<double>& values);
void setAnalog(bool analog);
void setMinMax(double min, double max);
const QString& title();
void setTitle(const QString& title);
void setUnit(const QString& unit);
void setPlotCount(int count);
void setCustomPlots(const QList<QColor>& colors);
void setScale(qreal scale);
void setStackPlots(bool stack);
protected slots:
void themeChanged();
protected:
void createWidgets();
void setOverlayText(const QString& text);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
private:
QGraphicsLinearLayout *m_layout;
Plasma::SignalPlotter *m_plotter;
Plasma::Meter *m_meter;
int m_plotCount;
QString m_title;
QString m_unit;
double m_min;
double m_max;
Plasma::Frame* m_overlayFrame;
bool m_showAnalogValue;
};
}
#endif

View file

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>config</class>
<widget class="QWidget" name="config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>263</height>
</rect>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Memory:</string>
</property>
<property name="buddy">
<cstring>treeView</cstring>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="treeView">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Update &amp;interval:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>intervalSpinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="intervalSpinBox">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>525600.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<connections/>
</ui>

View file

@ -1,276 +0,0 @@
/*
* Copyright (C) 2008 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "ram.h"
#include <Plasma/Theme>
#include <Plasma/ToolTipManager>
#include <KConfigDialog>
#include <QTimer>
#include <QGraphicsLinearLayout>
#include "plotter.h"
/* All sources we are interested in. */
static const char phys_source[] = "mem/physical/application";
static const char swap_source[] = "mem/swap/used";
SM::Ram::Ram(QObject *parent, const QVariantList &args)
: SM::Applet(parent, args)
{
setHasConfigurationInterface(true);
resize(234 + 20 + 23, 135 + 20 + 25);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
SM::Ram::~Ram()
{
}
void SM::Ram::init()
{
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setEngine(dataEngine("systemmonitor"));
setTitle(i18n("RAM"));
/* At the time this method is running, not all source may be connected. */
connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(sourceAdded(QString)));
foreach (const QString& source, engine()->sources()) {
sourceAdded(source);
}
}
void SM::Ram::configChanged()
{
KConfigGroup cg = config();
setInterval(cg.readEntry("interval", 2.0) * 1000.0);
// sanity check
QStringList memories = cg.readEntry("memories", m_memories);
foreach (QString source, memories) {
if (source != phys_source && source != swap_source)
memories.removeAt(memories.indexOf(source));
}
setSources(memories);
m_max.clear();
connectToEngine();
}
void SM::Ram::sourceAdded(const QString& name)
{
if ((name == phys_source || name == swap_source) && !m_memories.contains(name)) {
m_memories << name;
if (m_memories.count() == 2) {
// all sources are ready
QTimer::singleShot(0, this, SLOT(sourcesAdded()));
}
}
}
void SM::Ram::sourcesAdded()
{
configChanged();
}
bool SM::Ram::addVisualization(const QString& source)
{
QStringList l = source.split('/');
if (l.count() < 3) {
return false;
}
QString ram = l[1];
SM::Plotter *plotter = new SM::Plotter(this);
// 'ram' should be "physical" or "swap". I'm not aware of other values
// for it, but who knows.
if (ram == "physical") {
ram = i18nc("noun, hardware, physical RAM/memory", "physical");
} else if (ram == "swap") {
ram = i18nc("noun, hardware, swap file/partition", "swap");
}
plotter->setTitle(ram);
plotter->setUnit("B");
appendVisualization(source, plotter);
setPreferredItemHeight(80);
return true;
}
double SM::Ram::preferredBinaryUnit()
{
KLocale::BinaryUnitDialect binaryUnit = KGlobal::locale()->binaryUnitDialect();
// this makes me feel all dirty inside. but it's the only way I could find
// which will let us know what we should be scaling our graph by, independent
// of how locale settings are configured.
switch (binaryUnit) {
case KLocale::IECBinaryDialect:
//fallthrough
case KLocale::JEDECBinaryDialect:
return 1024;
break;
case KLocale::MetricBinaryDialect:
return 1000;
break;
default:
// being careful..I'm sure some genius will invent a new byte unit system ;-)
Q_ASSERT_X(0, "preferredBinaryUnit", "invalid binary preference enum returned");
return 0;
}
}
QStringList SM::Ram::preferredUnitsList()
{
QStringList units;
KLocale::BinaryUnitDialect binaryUnit = KGlobal::locale()->binaryUnitDialect();
switch (binaryUnit) {
case KLocale::IECBinaryDialect:
units << "B" << "KiB" << "MiB" << "GiB" << "TiB";
break;
case KLocale::JEDECBinaryDialect:
units << "B" << "KB" << "MB" << "GB" << "TB";
break;
case KLocale::MetricBinaryDialect:
units << "B" << "kB" << "MB" << "GB" << "TB";
break;
default:
Q_ASSERT_X(0, "preferredBinaryUnit", "invalid binary preference enum returned");
}
return units;
}
void SM::Ram::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
{
SM::Plotter *plotter = qobject_cast<SM::Plotter*>(visualization(source));
if (plotter) {
/* A factor to convert from default units to bytes.
* If units is not "KB", assume it is bytes.
* NOTE: the dataengine refers to KB == 1024. so it's KiB as well.
* Though keep in mind, KB does not imply 1024 and can be KB == 1000 as well.
*/
const double preferredUnit = preferredBinaryUnit();
const double factor = (data["units"].toString() == "KB") ? preferredUnit : 1.0;
const double value_b = data["value"].toDouble() * factor;
const double max_b = data["max"].toDouble() * factor;
const QStringList units = preferredUnitsList();
if (value_b > m_max[source]) {
m_max[source] = max_b;
plotter->setMinMax(0.0, max_b);
qreal scale = 1.0;
int i = 0;
while (max_b / scale > factor && i < units.size()) {
scale *= factor;
++i;
}
plotter->setUnit(units[i]);
plotter->setScale(scale);
}
plotter->addSample(QList<double>() << value_b);
QString temp = KGlobal::locale()->formatByteSize(value_b);
if (mode() == SM::Applet::Panel) {
setToolTip(source, QString("<tr><td>%1</td><td>%2</td><td>of</td><td>%3</td></tr>")
.arg(plotter->title())
.arg(temp)
.arg(KGlobal::locale()->formatByteSize(m_max[source])));
}
}
}
void SM::Ram::createConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
m_model.clear();
m_model.setHorizontalHeaderLabels(QStringList() << i18n("RAM"));
QStandardItem *parentItem = m_model.invisibleRootItem();
QRegExp rx("mem/(\\w+)/.*");
QString ramName;
foreach (const QString& ram, m_memories) {
if (rx.indexIn(ram) != -1) {
ramName = rx.cap(1);
// 'ram' should be "physical" or "swap". I'm not aware of other values
// for it, but who knows. (see also addVisualization)
if (ramName == "physical") {
ramName = i18nc("noun, hardware, physical RAM/memory", "physical");
} else if (ramName == "swap") {
ramName = i18nc("noun, hardware, swap file/partition", "swap");
}
QStandardItem *ramItem = new QStandardItem(ramName);
ramItem->setEditable(false);
ramItem->setCheckable(true);
ramItem->setData(ram);
if (sources().contains(ram)) {
ramItem->setCheckState(Qt::Checked);
}
parentItem->appendRow(ramItem);
}
}
ui.treeView->setModel(&m_model);
ui.treeView->resizeColumnToContents(0);
ui.intervalSpinBox->setValue(interval() / 1000.0);
ui.intervalSpinBox->setSuffix(i18nc("second", " s"));
parent->addPage(widget, i18n("RAM"), "media-flash");
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(ui.treeView, SIGNAL(clicked(QModelIndex)), parent, SLOT(settingsModified()));
connect(ui.intervalSpinBox, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
}
void SM::Ram::configAccepted()
{
KConfigGroup cg = config();
QStandardItem *parentItem = m_model.invisibleRootItem();
clear();
for (int i = 0; i < parentItem->rowCount(); ++i) {
QStandardItem *item = parentItem->child(i, 0);
if (item) {
if (item->checkState() == Qt::Checked) {
// data() is the untranslated string
// for use with sources
appendSource(item->data().toString());
}
}
}
// note we write and read non-translated
// version to config file.
cg.writeEntry("memories", sources());
double interval = ui.intervalSpinBox->value();
cg.writeEntry("interval", interval);
emit configNeedsSaving();
}
#include "moc_ram.cpp"

View file

@ -1,80 +0,0 @@
/*
* Copyright (C) 2008 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef RAM_HEADER
#define RAM_HEADER
#include <ui_ram-config.h>
#include "applet.h"
#include <Plasma/DataEngine>
#include <QStandardItemModel>
#include <QStandardItemModel>
namespace SM {
class Ram : public Applet
{
Q_OBJECT
public:
Ram(QObject *parent, const QVariantList &args);
~Ram();
virtual void init();
virtual bool addVisualization(const QString&);
virtual void createConfigurationInterface(KConfigDialog *parent);
public slots:
void dataUpdated(const QString &name,
const Plasma::DataEngine::Data &data);
void sourceAdded(const QString &name);
void sourcesAdded();
void configAccepted();
void configChanged();
private:
// below methods exist because KLocale has no nice
// way of getting this info :(
// thought about adding it to the api, but perhaps this
// code is the only one that uses it?
/**
* The preferred binary unit byte value
* e.g. KiB, kiB, KIB, etc.
* @return double 1024 or 1000
*/
double preferredBinaryUnit();
/**
* The preferred binary unit abbreviations.
* @return QStringList B, KiB, MiB, GiB, TiB.\
* or whatever is best fit for current binary unit
* settings via klocale.
*/
QStringList preferredUnitsList();
Ui::config ui;
QStandardItemModel m_model;
QStringList m_memories;
QHash<QString, double> m_max;
};
}
K_EXPORT_PLASMA_APPLET(sm_ram, SM::Ram)
#endif

View file

@ -1,296 +1,233 @@
/* /*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi> This file is part of the KDE project
* Copyright (C) 2024 Ivailo Monev <xakepa10@gmail.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as This library is free software; you can redistribute it and/or
* published by the Free Software Foundation modify it under the terms of the GNU Library General Public
* License version 2, as published by the Free Software Foundation.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of This library is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the You should have received a copy of the GNU Library General Public License
* Free Software Foundation, Inc., along with this library; see the file COPYING.LIB. If not, write to
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
*/ Boston, MA 02110-1301, USA.
*/
#include "system-monitor.h" #include "system-monitor.h"
#include "monitorbutton.h" #include "ksysguard/ksgrd/SensorClient.h"
#include "applet.h" #include "ksysguard/ksgrd/SensorManager.h"
#include <QTimer>
#include <QGraphicsLinearLayout> #include <QGraphicsLinearLayout>
#include <Plasma/Theme>
#include <Plasma/SignalPlotter>
#include <KDebug> #include <KDebug>
#include <KPushButton>
#include <Plasma/Containment> typedef QList<QByteArray> SystemMonitorSensors;
#include <Plasma/Corona>
#include <Plasma/ToolTipManager> static const int s_monitorsid = -1;
static const char* const s_systemuptimesensor = "system/uptime";
static const char* const s_cpusystemloadsensor = "cpu/system/TotalLoad";
static const int s_updatetimeout = 1000;
static QColor kCPUVisualizerColor()
{
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
}
class SystemMonitorClient : public QObject, public KSGRD::SensorClient
{
Q_OBJECT
public:
SystemMonitorClient(QObject *parent);
~SystemMonitorClient();
SystemMonitorSensors sensors() const;
void requestValue(const QByteArray &sensor) const;
Q_SIGNALS:
void sensorValue(const QByteArray &sensor, const float value);
private Q_SLOTS:
void slotUpdate();
protected:
void answerReceived(int id, const QList<QByteArray> &answer) final;
void sensorLost(int id) final;
private:
SystemMonitorSensors m_sensors;
};
SystemMonitorClient::SystemMonitorClient(QObject *parent)
: QObject(parent)
{
KSGRD::SensorMgr = new KSGRD::SensorManager(this);
KSGRD::SensorMgr->engage("localhost", "", "ksysguardd");
connect(KSGRD::SensorMgr, SIGNAL(update()), this, SLOT(slotUpdate()));
slotUpdate();
}
SystemMonitorClient::~SystemMonitorClient()
{
}
SystemMonitorSensors SystemMonitorClient::sensors() const
{
return m_sensors;
}
void SystemMonitorClient::requestValue(const QByteArray &sensor) const
{
const int sensorid = m_sensors.indexOf(sensor);
if (sensorid < 0) {
// this can actually happen if there was no answer yet for "monitors"
kWarning() << "unmapped sensor" << sensor;
return;
}
const QString sensorname = QString::fromLatin1(sensor.constData(), sensor.size());
KSGRD::SensorMgr->sendRequest("localhost", sensorname, (KSGRD::SensorClient*)this, sensorid);
}
void SystemMonitorClient::slotUpdate()
{
KSGRD::SensorMgr->sendRequest("localhost", "monitors", (KSGRD::SensorClient*)this, s_monitorsid);
}
void SystemMonitorClient::answerReceived(int id, const QList<QByteArray> &answer)
{
if (id == s_monitorsid) {
foreach (const QByteArray &sensoranswer, answer) {
const QList<QByteArray> splitsensoranswer = sensoranswer.split('\t');
if (splitsensoranswer.size() != 2) {
kWarning() << "invalid sensor answer" << sensoranswer;
continue;
}
const QByteArray sensortype = splitsensoranswer.at(1);
if (sensortype != "integer" && sensortype != "float") {
continue;
}
const QByteArray sensorname = splitsensoranswer.at(0);
kDebug() << "mapping sensor" << sensorname << sensortype;
m_sensors.append(sensorname);
}
} else if (id < m_sensors.size()) {
foreach (const QByteArray &sensoranswer, answer) {
const QByteArray sensorname = m_sensors.at(id);
const float sensorvalue = sensoranswer.toFloat();
kDebug() << "got sensor value" << id << sensorname << sensorvalue;
emit sensorValue(sensorname, sensorvalue);
}
} else {
kWarning() << "invalid sensor ID" << id;
}
}
void SystemMonitorClient::sensorLost(int id)
{
kDebug() << "sensor lost" << id;
slotUpdate();
}
class SystemMonitorWidget : public QGraphicsWidget
{
Q_OBJECT
public:
SystemMonitorWidget(SystemMonitor* systemmonitor);
~SystemMonitorWidget();
private Q_SLOTS:
void slotRequestValues();
void slotSensorValue(const QByteArray &sensor, const float value);
private:
SystemMonitor* m_systemmonitor;
QGraphicsLinearLayout* m_layout;
SystemMonitorClient* m_systemmonitorclient;
Plasma::SignalPlotter* m_cpuplotter;
};
SystemMonitorWidget::SystemMonitorWidget(SystemMonitor* systemmonitor)
: QGraphicsWidget(systemmonitor),
m_systemmonitor(systemmonitor),
m_layout(nullptr)
{
m_layout = new QGraphicsLinearLayout(Qt::Vertical, this);
m_systemmonitorclient = new SystemMonitorClient(this);
connect(
m_systemmonitorclient, SIGNAL(sensorValue(QByteArray,float)),
this, SLOT(slotSensorValue(QByteArray,float))
);
m_cpuplotter = new Plasma::SignalPlotter(this);
m_cpuplotter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_cpuplotter->setTitle(i18n("CPU"));
m_cpuplotter->setUnit("%");
m_cpuplotter->setShowTopBar(false);
m_cpuplotter->setShowLabels(true);
m_cpuplotter->setShowVerticalLines(false);
m_cpuplotter->setShowHorizontalLines(false);
m_cpuplotter->setThinFrame(false);
m_cpuplotter->setUseAutoRange(false);
m_cpuplotter->setVerticalRange(0.0, 100.0);
m_cpuplotter->addPlot(kCPUVisualizerColor());
m_layout->addItem(m_cpuplotter);
setLayout(m_layout);
slotRequestValues();
}
SystemMonitorWidget::~SystemMonitorWidget()
{
}
void SystemMonitorWidget::slotRequestValues()
{
m_systemmonitorclient->requestValue(s_systemuptimesensor);
m_systemmonitorclient->requestValue(s_cpusystemloadsensor);
QTimer::singleShot(s_updatetimeout, this, SLOT(slotRequestValues()));
}
void SystemMonitorWidget::slotSensorValue(const QByteArray &sensor, const float value)
{
if (sensor == s_cpusystemloadsensor) {
m_cpuplotter->addSample(QList<double>() << double(value));
}
}
SystemMonitor::SystemMonitor(QObject *parent, const QVariantList &args) SystemMonitor::SystemMonitor(QObject *parent, const QVariantList &args)
: Plasma::PopupApplet(parent, args), m_layout(0), m_buttons(0), m_widget(0) : Plasma::PopupApplet(parent, args),
m_systemmonitorwidget(nullptr)
{ {
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setAspectRatioMode(Plasma::IgnoreAspectRatio); setAspectRatioMode(Plasma::IgnoreAspectRatio);
m_systemmonitorwidget = new SystemMonitorWidget(this);
setPopupIcon("utilities-system-monitor");
} }
SystemMonitor::~SystemMonitor() SystemMonitor::~SystemMonitor()
{ {
} delete m_systemmonitorwidget;
void SystemMonitor::saveState(KConfigGroup &group) const
{
QStringList appletNames;
foreach (SM::Applet *applet, m_applets) {
applet->saveConfig(group);
appletNames << applet->objectName();
}
group.writeEntry("applets", appletNames);
}
void SystemMonitor::createConfigurationInterface(KConfigDialog *parent)
{
foreach (Plasma::Applet *applet, m_applets) {
applet->createConfigurationInterface(parent);
}
} }
void SystemMonitor::init() void SystemMonitor::init()
{ {
KConfigGroup cg = config();
QStringList appletNames = cg.readEntry("applets", QStringList());
m_widget = new QGraphicsWidget(this);
m_layout = new QGraphicsLinearLayout(Qt::Vertical);
m_layout->setContentsMargins(0, 0, 0, 0);
m_buttons = new QGraphicsLinearLayout(Qt::Horizontal);
m_buttons->setContentsMargins(0, 0, 0, 0);
m_buttons->setSpacing(5);
QMap<QString, KPluginInfo> appletsFound;
KPluginInfo::List appletList = listAppletInfo("System Information");
foreach (const KPluginInfo &pluginInfo, appletList) {
if (pluginInfo.pluginName().startsWith("sm_") && !pluginInfo.isHidden()) {
appletsFound.insert(pluginInfo.pluginName(), pluginInfo);
}
}
foreach (const KPluginInfo &pluginInfo, appletsFound) {
MonitorButton *button = new MonitorButton(m_widget);
button->setObjectName(pluginInfo.pluginName());
Plasma::ToolTipContent data;
data.setMainText(pluginInfo.name());
data.setImage(KIcon(pluginInfo.icon()).pixmap(IconSize(KIconLoader::Desktop)));
Plasma::ToolTipManager::self()->setContent(button, data);
button->setCheckable(true);
button->setImage(pluginInfo.icon());
if (appletNames.contains(pluginInfo.pluginName())) {
button->setChecked(true);
}
connect(button, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
m_buttons->addItem(button);
m_monitorButtons << button;
// this does not work
KGlobal::locale()->insertCatalog(pluginInfo.pluginName());
}
m_layout->addItem(m_buttons);
foreach (const QString& appletName, appletNames) {
if (appletsFound.contains(appletName)) {
Applet * applet = addApplet(appletName);
if (applet) {
Plasma::Constraints constraints(Plasma::ImmutableConstraint |
Plasma::StartupCompletedConstraint);
applet->updateConstraints(constraints);
applet->flushPendingConstraintsEvents();
}
}
}
m_widget->setLayout(m_layout);
checkGeometry();
setPopupIcon("utilities-system-monitor");
}
void SystemMonitor::toggled(bool toggled)
{
removeApplet(sender()->objectName());
if (toggled) {
SM::Applet * applet = addApplet(sender()->objectName());
if (applet) {
Plasma::Constraints constraints(Plasma::ImmutableConstraint |
Plasma::StartupCompletedConstraint);
applet->updateConstraints(constraints);
applet->flushPendingConstraintsEvents();
}
}
}
void SystemMonitor::configChanged()
{
KConfigGroup cg = config();
QStringList appletNames = cg.readEntry("applets", QStringList());
QStringList oldAppletNames;
foreach (SM::Applet *applet, m_applets) {
oldAppletNames << applet->objectName();
}
if (appletNames == oldAppletNames) {
foreach (SM::Applet *applet, m_applets)
applet->configChanged();
} else {
QMap<QString, KPluginInfo> appletsFound;
KPluginInfo::List appletList = listAppletInfo("System Information");
foreach (const KPluginInfo &pluginInfo, appletList) {
if (pluginInfo.pluginName().startsWith("sm_") && !pluginInfo.isHidden()) {
appletsFound.insert(pluginInfo.pluginName(), pluginInfo);
}
}
foreach (MonitorButton *button, m_monitorButtons) {
button->setChecked(false);
}
foreach (const QString& appletName, appletNames) {
if (appletsFound.contains(appletName)) {
foreach (MonitorButton* button, m_monitorButtons) {
if (button->objectName() == appletName)
button->setChecked(true);
}
}
}
checkGeometry();
}
}
SM::Applet *SystemMonitor::addApplet(const QString &name)
{
if (name.isEmpty()) {
return 0;
}
Plasma::Applet* plasmaApplet = Plasma::Applet::load(name, 0, QVariantList() << "SM");
SM::Applet* applet = qobject_cast<SM::Applet*>(plasmaApplet);
if (applet) {
applet->setParentItem(m_widget);
m_applets.append(applet);
connect(applet, SIGNAL(geometryChecked()), this, SLOT(checkGeometry()));
connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletRemoved(QObject*)));
applet->setFlag(QGraphicsItem::ItemIsMovable, false);
applet->setBackgroundHints(Plasma::Applet::NoBackground);
applet->setObjectName(name);
connect(applet, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
m_layout->addItem(applet);
applet->init();
KConfigGroup cg = config();
saveState(cg);
emit configNeedsSaving();
} else if (plasmaApplet) {
delete plasmaApplet;
}
return applet;
}
void SystemMonitor::removeApplet(const QString &name)
{
foreach (SM::Applet *applet, m_applets) {
if (applet->objectName() == name) {
applet->destroy();
}
}
}
void SystemMonitor::appletRemoved(QObject *object)
{
SM::Applet *applet = static_cast<SM::Applet*>(object);
foreach (SM::Applet *a, m_applets) {
if (a == applet) {
m_layout->removeItem(applet);
m_applets.removeAll(applet);
checkGeometry();
KConfigGroup cg = config();
saveState(cg);
emit configNeedsSaving();
}
}
// sanity check the buttons
QSet<QString> running;
foreach (SM::Applet *a, m_applets) {
running << a->objectName();
}
foreach (MonitorButton* button, m_monitorButtons) {
if (!running.contains(button->objectName())) {
kDebug() << "unchecking" << button->objectName();
button->setChecked(false);
}
}
}
void SystemMonitor::checkGeometry()
{
qreal minHeight = m_buttons->minimumHeight();
//kDebug() << minHeight;
foreach (SM::Applet *applet, m_applets) {
//kDebug() << applet->minSize() << applet->minimumSize()
// << applet->metaObject()->className() << applet->size() - applet->contentsRect().size();
minHeight += applet->preferredSize().height() + m_layout->spacing();
}
update();
/*
kDebug() << m_widget->size().height() << m_layout->geometry().height();
foreach (SM::Applet *applet, m_applets) {
kDebug() << applet->metaObject()->className() << applet->size().height();
}
for (int i = 0; i < m_layout->count(); ++i) {
kDebug() << m_layout->itemAt(i)->geometry().top() << m_layout->itemAt(i)->geometry().height();
}
*/
} }
QGraphicsWidget *SystemMonitor::graphicsWidget() QGraphicsWidget *SystemMonitor::graphicsWidget()
{ {
return m_widget; return m_systemmonitorwidget;
} }
void SystemMonitor::constraintsEvent(Plasma::Constraints constraints) K_EXPORT_PLASMA_APPLET(system-monitor_applet, SystemMonitor)
{
Plasma::Constraints passOn = Plasma::NoConstraint;
if (constraints & Plasma::ImmutableConstraint) {
foreach (MonitorButton* button, m_monitorButtons) {
button->setEnabled(immutability() == Plasma::Mutable);
}
passOn |= Plasma::ImmutableConstraint;
}
if (constraints & Plasma::StartupCompletedConstraint) {
passOn |= Plasma::StartupCompletedConstraint;
}
if (passOn != Plasma::NoConstraint) {
foreach (Plasma::Applet *applet, m_applets) {
applet->updateConstraints(passOn);
if (passOn & Plasma::StartupCompletedConstraint) {
applet->flushPendingConstraintsEvents();
}
}
}
PopupApplet::constraintsEvent(constraints);
}
#include "moc_system-monitor.cpp" #include "moc_system-monitor.cpp"
#include "system-monitor.moc"

View file

@ -1,67 +1,42 @@
/* /*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi> This file is part of the KDE project
* Copyright (C) 2024 Ivailo Monev <xakepa10@gmail.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SYSTEM_MONITOR_HEADER This library is free software; you can redistribute it and/or
#define SYSTEM_MONITOR_HEADER modify it under the terms of the GNU Library General Public
License version 2, as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef SYSTEM_MONITOR_H
#define SYSTEM_MONITOR_H
#include <Plasma/PopupApplet> #include <Plasma/PopupApplet>
#include <Plasma/DataEngine>
namespace SM { class SystemMonitorWidget;
class Applet;
}
class MonitorButton;
#include <QGraphicsLinearLayout>
class SystemMonitor : public Plasma::PopupApplet class SystemMonitor : public Plasma::PopupApplet
{ {
Q_OBJECT Q_OBJECT
public: public:
SystemMonitor(QObject *parent, const QVariantList &args); SystemMonitor(QObject *parent, const QVariantList &args);
virtual ~SystemMonitor(); ~SystemMonitor();
void init(); void init();
virtual QGraphicsWidget *graphicsWidget(); QGraphicsWidget *graphicsWidget();
virtual void constraintsEvent(Plasma::Constraints constraints);
public slots: private:
void checkGeometry(); friend SystemMonitorWidget;
SystemMonitorWidget *m_systemmonitorwidget;
protected slots:
void toggled(bool toggled);
void appletRemoved(QObject *object);
void configChanged();
protected:
SM::Applet *addApplet(const QString &name);
void removeApplet(const QString &name);
void saveState(KConfigGroup &group) const;
void createConfigurationInterface(KConfigDialog *parent);
private:
QGraphicsLinearLayout *m_layout;
QGraphicsLinearLayout *m_buttons;
QList<SM::Applet*> m_applets;
QList<MonitorButton*> m_monitorButtons;
QGraphicsWidget *m_widget;
}; };
K_EXPORT_PLASMA_APPLET(system-monitor_applet, SystemMonitor) #endif // SYSTEM_MONITOR_H
#endif

View file

@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>config</class>
<widget class="QWidget" name="config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>383</width>
<height>323</height>
</rect>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Available temperatures:</string>
</property>
<property name="buddy">
<cstring>treeView</cstring>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="treeView">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Update &amp;interval:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>intervalSpinBox</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="intervalSpinBox">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>525600.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Unit:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>unitComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="unitComboBox">
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<connections/>
</ui>

View file

@ -1,61 +0,0 @@
/*
* Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "temperature-offset-delegate.h"
#include <knuminput.h>
TemperatureOffsetDelegate::TemperatureOffsetDelegate(QObject *parent) : QItemDelegate(parent)
{
}
QWidget *TemperatureOffsetDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option);
Q_UNUSED(index);
KDoubleNumInput *input = new KDoubleNumInput(parent);
input->setMinimum(-1000);
input->setMaximum(1000);
input->setDecimals(1);
input->setSingleStep(0.1);
input->setSliderEnabled(false);
return input;
}
void TemperatureOffsetDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
KDoubleNumInput *input = static_cast<KDoubleNumInput*>(editor);
input->setValue(index.model()->data(index, Qt::EditRole).toDouble());
}
void TemperatureOffsetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
KDoubleNumInput *input = static_cast<KDoubleNumInput*>(editor);
model->setData(index, input->value(), Qt::EditRole);
}
void TemperatureOffsetDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(index);
editor->setGeometry(option.rect);
}

View file

@ -1,47 +0,0 @@
/*
* Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TEMPERATURE_OFFSET_DELEGATE_H
#define TEMPERATURE_OFFSET_DELEGATE_H
#include <QItemDelegate>
/**
* Item delegate that uses a spinbox to edit real numbers.
*/
class TemperatureOffsetDelegate : public QItemDelegate
{
Q_OBJECT
public:
TemperatureOffsetDelegate(QObject *parent = 0);
/// reimplemented from QItemDelegate.
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
/// reimplemented from QItemDelegate.
void setEditorData(QWidget *editor, const QModelIndex &index) const;
/// reimplemented from QItemDelegate.
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
/// reimplemented from QItemDelegate.
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
#endif // TEMPERATURE_OFFSET_DELEGATE_H

View file

@ -1,253 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2008 Marco Martin <notmart@gmail.com>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
* Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "temperature.h"
#include "plotter.h"
#include "temperature-offset-delegate.h"
#include <Plasma/Meter>
#include <Plasma/Containment>
#include <Plasma/Theme>
#include <KConfigDialog>
#include <QGraphicsLinearLayout>
#include <QTimer>
#include <cmath>
Temperature::Temperature(QObject *parent, const QVariantList &args)
: SM::Applet(parent, args)
, m_tempModel(0)
, m_rx(".*temp.*", Qt::CaseInsensitive)
{
setHasConfigurationInterface(true);
resize(215 + 20 + 23, 109 + 20 + 25);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
m_sourceTimer.setSingleShot(true);
connect(&m_sourceTimer, SIGNAL(timeout()), this, SLOT(sourcesAdded()));
}
Temperature::~Temperature()
{
}
void Temperature::init()
{
KGlobal::locale()->insertCatalog("plasma_applet_system-monitor");
setEngine(dataEngine("systemmonitor"));
setTitle(i18n("Temperature"));
/* At the time this method is running, not all source may be connected. */
connect(engine(), SIGNAL(sourceAdded(QString)), this, SLOT(sourceAdded(QString)));
foreach (const QString& source, engine()->sources()) {
sourceAdded(source);
}
}
void Temperature::configChanged()
{
KConfigGroup cg = config();
setInterval(cg.readEntry("interval", 2.0) * 1000.0);
setSources(cg.readEntry("temps", m_sources.mid(0, 5)));
connectToEngine();
}
void Temperature::sourceAdded(const QString& name)
{
if (m_rx.indexIn(name) != -1) {
//kDebug() << m_rx.cap(1);
m_sources << name;
if (!m_sourceTimer.isActive()) {
m_sourceTimer.start(0);
}
}
}
void Temperature::sourcesAdded()
{
configChanged();
}
void Temperature::createConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
m_tempModel.clear();
m_tempModel.setHorizontalHeaderLabels(QStringList() << i18n("Sensor")
<< i18n("Name")
<< i18n("Offset"));
QStandardItem *parentItem = m_tempModel.invisibleRootItem();
foreach (const QString& temp, m_sources) {
QStandardItem *item1 = new QStandardItem(temp);
item1->setEditable(false);
item1->setCheckable(true);
if (sources().contains(temp)) {
item1->setCheckState(Qt::Checked);
}
QStandardItem *item2 = new QStandardItem(temperatureTitle(temp));
item2->setEditable(true);
QStandardItem *item3 = new QStandardItem(
KGlobal::locale()->formatNumber(temperatureOffset(temp), 1));
item3->setEditable(true);
parentItem->appendRow(QList<QStandardItem *>() << item1 << item2 << item3);
}
ui.treeView->setModel(&m_tempModel);
ui.treeView->resizeColumnToContents(0);
ui.treeView->setItemDelegateForColumn(2, new TemperatureOffsetDelegate());
ui.intervalSpinBox->setValue(interval() / 1000.0);
ui.intervalSpinBox->setSuffix(i18nc("second", " s"));
for (int i = 0; i < KTemperature::UnitCount; i++) {
KTemperature::KTempUnit unit = static_cast<KTemperature::KTempUnit>(i);
ui.unitComboBox->addItem(KTemperature::unitDescription(unit), unit);
}
ui.unitComboBox->setCurrentIndex(static_cast<int>(temperatureUnit()));
parent->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
parent->addPage(widget, i18n("Temperature"), "view-statistics");
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(ui.treeView, SIGNAL(clicked(QModelIndex)), parent, SLOT(settingsModified()));
connect(ui.intervalSpinBox, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
connect(ui.unitComboBox, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
}
void Temperature::configAccepted()
{
KConfigGroup cg = config();
KConfigGroup cgGlobal = globalConfig();
QStandardItem *parentItem = m_tempModel.invisibleRootItem();
clear();
for (int i = 0; i < parentItem->rowCount(); ++i) {
QStandardItem *item = parentItem->child(i, 0);
if (item) {
cgGlobal.writeEntry(item->text(),
parentItem->child(i, 1)->text());
cgGlobal.writeEntry(item->text() + "_offset", QString::number(
parentItem->child(i, 2)->data(Qt::EditRole).toDouble(), 'f', 1));
if (item->checkState() == Qt::Checked) {
appendSource(item->text());
}
}
}
cg.writeEntry("temps", sources());
uint interval = ui.intervalSpinBox->value();
cg.writeEntry("interval", interval);
KTemperature temp(0.0, static_cast<KTemperature::KTempUnit>(ui.unitComboBox->currentIndex()));
cg.writeEntry("unit", temp.unit());
emit configNeedsSaving();
}
QString Temperature::temperatureTitle(const QString& source)
{
KConfigGroup cg = globalConfig();
return cg.readEntry(source, source.mid(source.lastIndexOf('/') + 1).replace('_',' '));
}
double Temperature::temperatureOffset(const QString& source)
{
KConfigGroup cg = globalConfig();
return cg.readEntry(source + "_offset", 0.0);
}
KTemperature::KTempUnit Temperature::temperatureUnit()
{
// TODO: optimize, this is called on data update
QString defaultunit;
if (KGlobal::locale()->measureSystem() == QLocale::MetricSystem) {
defaultunit = QString::fromUtf8("°C");
} else {
defaultunit = QString::fromUtf8("°F");
}
KConfigGroup cg = config();
const QString unit = cg.readEntry("unit", defaultunit);
KTemperature temp(0.0, unit);
return temp.unitEnum();
}
bool Temperature::addVisualization(const QString& source)
{
Plasma::DataEngine *engine = dataEngine("systemmonitor");
if (!engine) {
return false;
}
SM::Plotter *plotter = new SM::Plotter(this);
plotter->setTitle(temperatureTitle(source));
plotter->setAnalog(mode() != SM::Applet::Panel);
switch (temperatureUnit()) {
case KTemperature::Celsius: {
plotter->setMinMax(0, 110);
plotter->setUnit(QString::fromUtf8("°C"));
break;
}
case KTemperature::Kelvin: {
plotter->setMinMax(64, 384);
plotter->setUnit(QString::fromUtf8("K"));
break;
}
case KTemperature::Fahrenheit:
default: {
plotter->setMinMax(32, 230);
plotter->setUnit(QString::fromUtf8("°F"));
break;
}
}
appendVisualization(source, plotter);
Plasma::DataEngine::Data data = engine->query(source);
dataUpdated(source, data);
setPreferredItemHeight(80);
return true;
}
void Temperature::dataUpdated(const QString& source,
const Plasma::DataEngine::Data &data)
{
if (!sources().contains(source)) {
return;
}
SM::Plotter *plotter = qobject_cast<SM::Plotter*>(visualization(source));
const QString unit = data["units"].toString();
const double doubleValue = data["value"].toDouble() + temperatureOffset(source);
KTemperature temp(doubleValue, unit);
const KTemperature::KTempUnit tempunit = temperatureUnit();
const double sampleValue = KTemperature::round(temp.convertTo(tempunit), 1);
if (plotter) {
plotter->addSample(QList<double>() << sampleValue);
}
if (mode() == SM::Applet::Panel) {
const QString stringSample = KTemperature(sampleValue, tempunit).toString();
setToolTip(
source,
QString("<tr><td>%1</td><td>%2</td></tr>").arg(temperatureTitle(source)).arg(stringSample)
);
}
}
#include "moc_temperature.cpp"

View file

@ -1,69 +0,0 @@
/*
* Copyright (C) 2007 Petri Damsten <damu@iki.fi>
* Copyright (C) 2010 Michel Lafon-Puyo <michel.lafonpuyo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TEMPERATURE_HEADER
#define TEMPERATURE_HEADER
#include <applet.h>
#include "ui_temperature-config.h"
#include <KUnitConversion>
#include <Plasma/DataEngine>
#include <QStandardItemModel>
#include <QTimer>
namespace Plasma {
class Meter;
}
class Temperature : public SM::Applet
{
Q_OBJECT
public:
Temperature(QObject *parent, const QVariantList &args);
~Temperature();
virtual void init();
public slots:
void configChanged();
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
void createConfigurationInterface(KConfigDialog *parent);
private slots:
void configAccepted();
void sourceAdded(const QString& name);
void sourcesAdded();
private:
Ui::config ui;
QStandardItemModel m_tempModel;
QStringList m_sources;
QTimer m_sourceTimer;
QRegExp m_rx;
QString temperatureTitle(const QString& source);
double temperatureOffset(const QString& source);
KTemperature::KTempUnit temperatureUnit();
bool addVisualization(const QString& source);
bool isValidDevice(const QString& uuid, Plasma::DataEngine::Data* data);
};
K_EXPORT_PLASMA_APPLET(sm_temperature, Temperature)
#endif

View file

@ -2,7 +2,5 @@ add_subdirectory(applicationjobs)
add_subdirectory(apps) add_subdirectory(apps)
add_subdirectory(dict) add_subdirectory(dict)
add_subdirectory(notifications) add_subdirectory(notifications)
add_subdirectory(soliddevice)
add_subdirectory(time) add_subdirectory(time)
add_subdirectory(systemmonitor)

View file

@ -1,19 +0,0 @@
set(soliddevice_engine_SRCS
soliddeviceengine.cpp
devicesignalmapper.cpp
devicesignalmapmanager.cpp
soliddeviceservice.cpp
soliddevicejob.cpp
)
kde4_add_plugin(plasma_engine_soliddevice ${soliddevice_engine_SRCS})
target_link_libraries(plasma_engine_soliddevice
KDE4::kdecore
KDE4::solid
${QT_QTNETWORK_LIBRARY}
KDE4::plasma
KDE4::kio
)
install(TARGETS plasma_engine_soliddevice DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
install(FILES plasma-dataengine-soliddevice.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})

View file

@ -1,2 +0,0 @@
#!/bin/bash
$XGETTEXT `find . -name \*.cpp` -o $podir/plasma_engine_soliddevice.pot

View file

@ -1,114 +0,0 @@
/*
* Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "devicesignalmapmanager.h"
DeviceSignalMapManager::DeviceSignalMapManager(QObject *parent) : QObject(parent)
{
user = parent;
}
DeviceSignalMapManager::~DeviceSignalMapManager()
{
}
void DeviceSignalMapManager::mapDevice(Solid::AcAdapter *ac, const QString &udi)
{
AcAdapterSignalMapper *map=0;
if (!signalmap.contains(Solid::DeviceInterface::AcAdapter)) {
map = new AcAdapterSignalMapper(this);
signalmap[Solid::DeviceInterface::AcAdapter] = map;
connect(map, SIGNAL(deviceChanged(QString,QString,QVariant)), user, SLOT(deviceChanged(QString,QString,QVariant)));
} else {
map = (AcAdapterSignalMapper*)signalmap[Solid::DeviceInterface::AcAdapter];
}
connect(ac, SIGNAL(plugStateChanged(bool,QString)), map, SLOT(plugStateChanged(bool)));
map->setMapping(ac, udi);
}
void DeviceSignalMapManager::mapDevice(Solid::Battery *battery, const QString &udi)
{
BatterySignalMapper *map=0;
if (!signalmap.contains(Solid::DeviceInterface::Battery)) {
map = new BatterySignalMapper(this);
signalmap[Solid::DeviceInterface::Battery] = map;
connect(map, SIGNAL(deviceChanged(QString,QString,QVariant)), user, SLOT(deviceChanged(QString,QString,QVariant)));
} else {
map = (BatterySignalMapper*)signalmap[Solid::DeviceInterface::Battery];
}
connect(battery, SIGNAL(chargePercentChanged(int,QString)), map, SLOT(chargePercentChanged(int)));
connect(battery, SIGNAL(chargeStateChanged(int,QString)), map, SLOT(chargeStateChanged(int)));
connect(battery, SIGNAL(plugStateChanged(bool,QString)), map, SLOT(plugStateChanged(bool)));
connect(battery, SIGNAL(powerSupplyStateChanged(bool,QString)), map, SLOT(powerSupplyStateChanged(bool)));
connect(battery, SIGNAL(capacityChanged(int,QString)), map, SLOT(capacityChanged(bool)));
map->setMapping(battery, udi);
}
void DeviceSignalMapManager::mapDevice(Solid::StorageAccess *storageaccess, const QString &udi)
{
StorageAccessSignalMapper *map=0;
if (!signalmap.contains(Solid::DeviceInterface::StorageAccess)) {
map = new StorageAccessSignalMapper(this);
signalmap[Solid::DeviceInterface::StorageAccess] = map;
connect(map, SIGNAL(deviceChanged(QString,QString,QVariant)), user, SLOT(deviceChanged(QString,QString,QVariant)));
} else {
map = (StorageAccessSignalMapper*)signalmap[Solid::DeviceInterface::StorageAccess];
}
connect(storageaccess, SIGNAL(accessibilityChanged(bool,QString)), map, SLOT(accessibilityChanged(bool)));
map->setMapping(storageaccess, udi);
}
void DeviceSignalMapManager::unmapDevice(Solid::AcAdapter *ac)
{
AcAdapterSignalMapper *map = (AcAdapterSignalMapper*)signalmap.value(Solid::DeviceInterface::AcAdapter);
if (!map) {
return;
}
disconnect(ac, SIGNAL(plugStateChanged(bool,QString)), map, SLOT(plugStateChanged(bool)));
disconnect(map, SIGNAL(deviceChanged(QString,QString,QVariant)), user, SLOT(deviceChanged(QString,QString,QVariant)));
}
void DeviceSignalMapManager::unmapDevice(Solid::Battery *battery)
{
BatterySignalMapper *map = (BatterySignalMapper*)signalmap.value(Solid::DeviceInterface::Battery);
if (!map) {
return;
}
disconnect(battery, SIGNAL(chargePercentChanged(int,QString)), map, SLOT(chargePercentChanged(int)));
disconnect(battery, SIGNAL(chargeStateChanged(int,QString)), map, SLOT(chargeStateChanged(int)));
disconnect(battery, SIGNAL(plugStateChanged(bool,QString)), map, SLOT(plugStateChanged(bool)));
disconnect(battery, SIGNAL(powerSupplyStateChanged(bool,QString)), map, SLOT(powerSupplyStateChanged(bool)));
disconnect(battery, SIGNAL(capacityChanged(int,QString)), map, SLOT(capacityChanged(bool)));
}
void DeviceSignalMapManager::unmapDevice(Solid::StorageAccess *storageaccess)
{
StorageAccessSignalMapper *map = (StorageAccessSignalMapper*)signalmap.value(Solid::DeviceInterface::StorageAccess);
if (!map) {
return;
}
disconnect(storageaccess, SIGNAL(accessibilityChanged(bool,QString)), map, SLOT(accessibilityChanged(bool)));
}
#include "moc_devicesignalmapmanager.cpp"

View file

@ -1,47 +0,0 @@
/*
* Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef DEVICE_SIGNALMAP_MANAGER_H
#define DEVICE_SIGNALMAP_MANAGER_H
#include <KDebug>
#include "devicesignalmapper.h"
class DeviceSignalMapManager : public QObject
{
Q_OBJECT
public:
DeviceSignalMapManager(QObject *parent=0);
~DeviceSignalMapManager();
void mapDevice(Solid::AcAdapter *ac, const QString &udi);
void mapDevice(Solid::Battery *battery, const QString &udi);
void mapDevice(Solid::StorageAccess *storageaccess, const QString &udi);
void unmapDevice(Solid::AcAdapter *ac);
void unmapDevice(Solid::Battery *battery);
void unmapDevice(Solid::StorageAccess *storageaccess);
private:
QMap<Solid::DeviceInterface::Type, DeviceSignalMapper*> signalmap;
QObject *user;
};
#endif

View file

@ -1,95 +0,0 @@
/*
* Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "devicesignalmapper.h"
DeviceSignalMapper::DeviceSignalMapper(QObject *parent) : QSignalMapper(parent)
{
}
DeviceSignalMapper::~DeviceSignalMapper()
{
}
void DeviceSignalMapper::setMapping(QObject* device, const QString &udi)
{
signalmap[device] = udi;
}
AcAdapterSignalMapper::AcAdapterSignalMapper(QObject *parent) : DeviceSignalMapper(parent)
{
}
AcAdapterSignalMapper::~AcAdapterSignalMapper()
{
}
void AcAdapterSignalMapper::plugStateChanged(bool newState)
{
emit deviceChanged(signalmap[sender()], "Plugged In", newState);
}
BatterySignalMapper::BatterySignalMapper(QObject *parent) : DeviceSignalMapper(parent)
{
}
BatterySignalMapper::~BatterySignalMapper()
{
}
void BatterySignalMapper::chargePercentChanged(int value)
{
emit deviceChanged(signalmap[sender()], "Charge Percent", value);
}
void BatterySignalMapper::chargeStateChanged(int newState)
{
QStringList chargestate;
chargestate << "Unknown Charge" << "Charging" << "Discharging" << "Fully Charged";
emit deviceChanged(signalmap[sender()], "Charge State", chargestate.at(newState));
}
void BatterySignalMapper::plugStateChanged(bool newState)
{
emit deviceChanged(signalmap[sender()], "Plugged In", newState);
}
void BatterySignalMapper::powerSupplyStateChanged(bool newState)
{
emit deviceChanged(signalmap[sender()], "Is Power Supply", newState);
}
void BatterySignalMapper::capacityChanged(int newState)
{
emit deviceChanged(signalmap[sender()], "Capacity", newState);
}
StorageAccessSignalMapper::StorageAccessSignalMapper(QObject *parent) : DeviceSignalMapper(parent)
{
}
StorageAccessSignalMapper::~StorageAccessSignalMapper()
{
}
void StorageAccessSignalMapper::accessibilityChanged(bool accessible)
{
emit deviceChanged(signalmap[sender()], "Accessible", accessible);
}
#include "moc_devicesignalmapper.cpp"

View file

@ -1,104 +0,0 @@
/*
* Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef DEVICE_SIGNAL_MAPPER_H
#define DEVICE_SIGNAL_MAPPER_H
#include <QObject>
#include <QSignalMapper>
#include <QMap>
#include <KDebug>
#include <solid/devicenotifier.h>
#include <solid/device.h>
#include <solid/processor.h>
#include <solid/block.h>
#include <solid/storageaccess.h>
#include <solid/storagedrive.h>
#include <solid/opticaldrive.h>
#include <solid/storagevolume.h>
#include <solid/opticaldisc.h>
#include <solid/camera.h>
#include <solid/portablemediaplayer.h>
#include <solid/networkinterface.h>
#include <solid/acadapter.h>
#include <solid/battery.h>
#include <solid/audiointerface.h>
#include <solid/video.h>
#include <solid/graphic.h>
#include <solid/input.h>
class DeviceSignalMapper : public QSignalMapper
{
Q_OBJECT
public:
DeviceSignalMapper(QObject *parent=0);
~DeviceSignalMapper();
void setMapping(QObject* device, const QString &udi);
Q_SIGNALS:
void deviceChanged(const QString& udi, const QString &property, QVariant value);
protected:
QMap<QObject*, QString> signalmap;
};
class AcAdapterSignalMapper : public DeviceSignalMapper
{
Q_OBJECT
public:
AcAdapterSignalMapper(QObject *parent=0);
~AcAdapterSignalMapper();
public Q_SLOTS:
void plugStateChanged(bool newState);
};
class BatterySignalMapper : public DeviceSignalMapper
{
Q_OBJECT
public:
BatterySignalMapper(QObject *parent=0);
~BatterySignalMapper();
public Q_SLOTS:
void chargePercentChanged(int value);
void chargeStateChanged(int newState);
void plugStateChanged(bool newState);
void powerSupplyStateChanged(bool newState);
void capacityChanged(int newState);
};
class StorageAccessSignalMapper : public DeviceSignalMapper
{
Q_OBJECT
public:
StorageAccessSignalMapper(QObject *parent=0);
~StorageAccessSignalMapper();
public Q_SLOTS:
void accessibilityChanged(bool accessible);
};
#endif

View file

@ -1,159 +0,0 @@
[Desktop Entry]
Name=Device Information
Name[ar]=معلومات الأجهزة
Name[ast]=Información del preséu
Name[be@latin]=Źviestki z pryłady
Name[bg]=Данни за устройства
Name[bn]=ি
Name[bn_IN]=ি
Name[bs]=podaci o uređajima
Name[ca]=Informació dels dispositius
Name[ca@valencia]=Informació dels dispositius
Name[cs]=Informace o zařízení
Name[csb]=Wëdowiédzô ò ùrządzeniach
Name[da]=Enhedsinformation
Name[de]=Geräteinformationen
Name[el]=Πληροφορίες συσκευής
Name[en_GB]=Device Information
Name[eo]=Aparataj Informoj
Name[es]=Información del dispositivo
Name[et]=Seadmete teave
Name[eu]=Gailuari buruzko informazioa
Name[fi]=Laitetiedot
Name[fr]=Informations sur les périphériques
Name[fy]=Apparaatynformaasje
Name[ga]=Eolas faoi Ghléas
Name[gl]=Información do dispositivo
Name[gu]= િ
Name[he]=מידע על התקנים
Name[hi]=
Name[hne]=
Name[hr]=Podaci o uređaju
Name[hu]=Eszközjellemzők
Name[ia]=Information de dispositivo
Name[id]=Informasi Divais
Name[is]=Upplýsingar tækis
Name[it]=Informazioni sui dispositivi
Name[ja]=
Name[kk]=Құрылғы мәліметі
Name[km]=
Name[kn]= ಿಿ
Name[ko]=
Name[ku]=Agahiya Cîhazê
Name[lt]=Informacija apie įrenginius
Name[lv]=Ierīču informācija
Name[mai]=ि
Name[mk]=Информации за уреди
Name[ml]= ി
Name[mr]= ि
Name[nb]=Enhetsinformasjon
Name[nds]=Reedschap-Informatschonen
Name[nl]=Apparaatinformatie
Name[nn]=Einingsinformasjon
Name[or]=
Name[pa]=
Name[pl]=Informacje o urządzeniach
Name[pt]=Informação dos Dispositivos
Name[pt_BR]=Informações do dispositivo
Name[ro]=Informații dispozitiv
Name[ru]=Сведения об устройствах
Name[si]=
Name[sk]=Informácie o zariadení
Name[sl]=Podatki o napravah
Name[sr]=подаци о уређајима
Name[sr@ijekavian]=подаци о уређајима
Name[sr@ijekavianlatin]=podaci o uređajima
Name[sr@latin]=podaci o uređajima
Name[sv]=Enhetsinformation
Name[ta]=Device Information
Name[tg]=Иттилооти дастгоҳ
Name[th]=
Name[tr]=Aygıt Bilgileri
Name[ug]=ئۈسكۈنە ئۇچۇرى
Name[uk]=Інформація про пристрої
Name[vi]=Thông tin thiết b
Name[wa]=Informåcions so l' éndjin
Name[x-test]=xxDevice Informationxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Device data via Solid
Comment[ar]=بيانات الأجهزة عن طريق سوليد
Comment[ast]=Datos de preséu vía Solid
Comment[bg]=Данни за устройствата (чрез Solid)
Comment[bs]=Podaci o uređajima preko Solida
Comment[ca]=Dades dels dispositius via Solid
Comment[ca@valencia]=Dades dels dispositius via Solid
Comment[cs]=Data zařízení pomocí Solid
Comment[csb]=Pòdôwczi ùrządzeniów z pòmòcą Solid
Comment[da]=Enhedsdata via Solid
Comment[de]=Gerätedaten mittels Solid
Comment[el]=Δεδομένα συσκευών μέσω Solid
Comment[en_GB]=Device data via Solid
Comment[es]=Datos de dispositivo vía Solid
Comment[et]=Seadmete andmed Solidi vahendusel
Comment[eu]=Gailuen datuak Solid bidez
Comment[fi]=Laitetietoja Solid-rajapinnalta
Comment[fr]=Données de périphériques utilisant Solid
Comment[fy]=Àpparaatgegevens fia Solid
Comment[ga]=Eolas faoi ghléas trí Solid
Comment[gl]=Datos do dispositivo mediante Solid
Comment[gu]=િ િ
Comment[he]=מידע אודות התקן באמצעות Solid
Comment[hr]=Podaci o uređajima preko Solida
Comment[hu]=Eszközjellemzők a Solid alrendszerből
Comment[ia]=Datos de dispositivos via Solid
Comment[id]=Data divais via Solid
Comment[is]=Vélbúnaðarupplýsingar með Solid
Comment[it]=Dati sui dispositivi con Solid
Comment[ja]=Solid
Comment[kk]=Solid құрылғы деректері
Comment[km]= Solid
Comment[kn]=ಿ
Comment[ko]=Solid
Comment[lt]=Solid įrenginių duomenys
Comment[lv]=Ierīču dati no Solid
Comment[mai]=ि ि
Comment[mk]=Податоци за уреди преку Солид
Comment[ml]=ി ി
Comment[mr]=ि ि
Comment[nb]=Enhetsdata via Solid
Comment[nds]=Reedschapdaten över Solid
Comment[nl]=Apparaatgegevens via Solid
Comment[nn]=SolidDevice-data
Comment[pa]=
Comment[pl]=Dane urządzenia przez Solid
Comment[pt]=Dados dos dispositivos através do Solid
Comment[pt_BR]=Dados do dispositivo através do Solid
Comment[ro]=Date despre dispozitive via Solid
Comment[ru]=Сведения об устройствах от Solid
Comment[si]=Solid
Comment[sk]=Dáta zariadenia pomocou Solid
Comment[sl]=Podatki o napravah s pomočjo Solid
Comment[sr]=Подаци о уређајима преко Солида
Comment[sr@ijekavian]=Подаци о уређајима преко Солида
Comment[sr@ijekavianlatin]=Podaci o uređajima preko Solida
Comment[sr@latin]=Podaci o uređajima preko Solida
Comment[sv]=Enhetsdata via Solid
Comment[tg]=Данные SolidDevice для плазмоидов
Comment[th]= Solid
Comment[tr]=Solid üzerinden aygıt verisi
Comment[ug]=Solid ئارقىلىق ئۈسكۈنە سانلىق-مەلۇماتىغا ئېرىشىدۇ
Comment[uk]=Дані щодо пристроїв з Solid
Comment[vi]=Thiết b d liu qua Solid
Comment[wa]=Dinêyes di l' éndjin avou Solid
Comment[x-test]=xxDevice data via Solidxx
Comment[zh_CN]= Solid
Comment[zh_TW]= Solid
X-KDE-ServiceTypes=Plasma/DataEngine
Type=Service
Icon=drive-harddisk
X-KDE-Library=plasma_engine_soliddevice
X-KDE-PluginInfo-Author=The Plasma Team
X-KDE-PluginInfo-Email=wilderkde@gmail.com
X-KDE-PluginInfo-Name=soliddevice
X-KDE-PluginInfo-Version=
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=

View file

@ -1,753 +0,0 @@
/*
* Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "soliddeviceengine.h"
#include "soliddeviceservice.h"
#include <QtCore/qmetaobject.h>
#include <QDateTime>
#include <KDebug>
#include <KDiskFreeSpaceInfo>
#include <KLocale>
#include <Plasma/DataContainer>
SolidDeviceEngine::SolidDeviceEngine(QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent, args),
m_notifier(0)
{
Q_UNUSED(args)
m_signalmanager = new DeviceSignalMapManager(this);
listenForNewDevices();
setMinimumPollingInterval(1000);
connect(this, SIGNAL(sourceRemoved(QString)),
this, SLOT(sourceWasRemoved(QString)));
}
SolidDeviceEngine::~SolidDeviceEngine()
{
}
Plasma::Service* SolidDeviceEngine::serviceForSource(const QString& source)
{
return new SolidDeviceService (this, source);
}
void SolidDeviceEngine::listenForNewDevices()
{
if (m_notifier) {
return;
}
//detect when new devices are added
m_notifier = Solid::DeviceNotifier::instance();
connect(m_notifier, SIGNAL(deviceAdded(QString)),
this, SLOT(deviceAdded(QString)));
connect(m_notifier, SIGNAL(deviceRemoved(QString)),
this, SLOT(deviceRemoved(QString)));
connect(m_notifier, SIGNAL(contentChanged(QString,bool)),
this, SLOT(deviceContentChanged(QString,bool)));
}
bool SolidDeviceEngine::sourceRequestEvent(const QString &name)
{
if (name.startsWith('/')) {
Solid::Device device = Solid::Device(name);
if (device.isValid()) {
if (m_devicemap.contains(name) ) {
return true;
} else {
m_devicemap[name] = device;
return populateDeviceData(name);
}
}
} else {
Solid::Predicate predicate = Solid::Predicate::fromString(name);
if (predicate.isValid() && !m_predicatemap.contains(name)) {
foreach (const Solid::Device &device, Solid::Device::listFromQuery(predicate)) {
m_predicatemap[name] << device.udi();
}
setData(name, m_predicatemap[name]);
return true;
}
}
kDebug() << "Source is not a predicate or a device.";
return false;
}
void SolidDeviceEngine::sourceWasRemoved(const QString &source)
{
m_devicemap.remove(source);
m_predicatemap.remove(source);
}
bool SolidDeviceEngine::populateDeviceData(const QString &name)
{
Solid::Device device = m_devicemap.value(name);
if (!device.isValid()) {
return false;
}
QStringList devicetypes;
setData(name, I18N_NOOP("Parent UDI"), device.parentUdi());
setData(name, I18N_NOOP("Vendor"), device.vendor());
setData(name, I18N_NOOP("Product"), device.product());
setData(name, I18N_NOOP("Description"), device.description());
setData(name, I18N_NOOP("Icon"), device.icon());
setData(name, I18N_NOOP("Emblems"), device.emblems());
setData(name, I18N_NOOP("State"), Idle);
setData(name, I18N_NOOP("Operation result"), Working);
setData(name, I18N_NOOP("Timestamp"), QDateTime::currentDateTime());
if (device.is<Solid::Processor>()) {
Solid::Processor *processor = device.as<Solid::Processor>();
if (!processor) {
return false;
}
devicetypes << I18N_NOOP("Processor");
setData(name, I18N_NOOP("Number"), processor->number());
setData(name, I18N_NOOP("Min Speed"), processor->minSpeed());
setData(name, I18N_NOOP("Max Speed"), processor->maxSpeed());
setData(name, I18N_NOOP("Can Change Frequency"), processor->canChangeFrequency());
}
if (device.is<Solid::Block>()) {
Solid::Block *block = device.as<Solid::Block>();
if (!block) {
return false;
}
devicetypes << I18N_NOOP("Block");
setData(name, I18N_NOOP("Major"), block->deviceMajor());
setData(name, I18N_NOOP("Minor"), block->deviceMajor());
setData(name, I18N_NOOP("Device"), block->device());
}
if (device.is<Solid::StorageAccess>()) {
Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
if (!storageaccess) {
return false;
}
devicetypes << I18N_NOOP("Storage Access");
setData(name, I18N_NOOP("Accessible"), storageaccess->isAccessible());
setData(name, I18N_NOOP("File Path"), storageaccess->filePath());
if (storageaccess->isAccessible()) {
QVariant freeDiskVar;
qulonglong freeDisk = freeDiskSpace(storageaccess->filePath());
if ( freeDisk != (qulonglong)-1 ) {
freeDiskVar.setValue( freeDisk );
}
if (!device.is<Solid::OpticalDisc>()) {
setData(name, I18N_NOOP("Free Space"), freeDiskVar );
setData(name, I18N_NOOP("Free Space Text"), KGlobal::locale()->formatByteSize(freeDisk));
}
}
m_signalmanager->mapDevice(storageaccess, device.udi());
}
if (device.is<Solid::StorageDrive>()) {
Solid::StorageDrive *storagedrive = device.as<Solid::StorageDrive>();
if (!storagedrive) {
return false;
}
devicetypes << I18N_NOOP("Storage Drive");
QStringList bus;
bus << I18N_NOOP("Ide") << I18N_NOOP("Usb") << I18N_NOOP("Ieee1394")
<< I18N_NOOP("Scsi") << I18N_NOOP("Sata") << I18N_NOOP("Platform");
QStringList drivetype;
drivetype << I18N_NOOP("Hard Disk") << I18N_NOOP("Cdrom Drive") << I18N_NOOP("Floppy")
<< I18N_NOOP("Tape") << I18N_NOOP("Compact Flash") << I18N_NOOP("Memory Stick")
<< I18N_NOOP("Smart Media") << I18N_NOOP("SdMmc");
setData(name, I18N_NOOP("Bus"), bus.at((int)storagedrive->bus()));
setData(name, I18N_NOOP("Drive Type"), drivetype.at((int)storagedrive->driveType()));
setData(name, I18N_NOOP("Removable"), storagedrive->isRemovable());
setData(name, I18N_NOOP("Hotpluggable"), storagedrive->isHotpluggable());
}
else {
bool isRemovable = false;
bool isHotpluggable = false;
Solid::StorageDrive *drive = device.as<Solid::StorageDrive>();
if (drive) {
//remove check for isHotpluggable() when plasmoids are changed to check for both properties
isRemovable = (drive->isRemovable() || drive->isHotpluggable());
isHotpluggable = drive->isHotpluggable();
}
setData(name, I18N_NOOP("Removable"), isRemovable);
setData(name, I18N_NOOP("Hotpluggable"), isHotpluggable);
}
if (device.is<Solid::OpticalDrive>()) {
Solid::OpticalDrive *opticaldrive = device.as<Solid::OpticalDrive>();
if (!opticaldrive) {
return false;
}
devicetypes << I18N_NOOP("Optical Drive");
QStringList supportedtypes;
Solid::OpticalDrive::MediumTypes mediatypes = opticaldrive->supportedMedia();
if (mediatypes & Solid::OpticalDrive::Cdr) {
supportedtypes << I18N_NOOP("CD-R");
}
if (mediatypes & Solid::OpticalDrive::Cdrw) {
supportedtypes << I18N_NOOP("CD-RW");
}
if (mediatypes & Solid::OpticalDrive::Dvd) {
supportedtypes << I18N_NOOP("DVD");
}
if (mediatypes & Solid::OpticalDrive::Dvdr) {
supportedtypes << I18N_NOOP("DVD-R");
}
if (mediatypes & Solid::OpticalDrive::Dvdrw) {
supportedtypes << I18N_NOOP("DVD-RW");
}
if (mediatypes & Solid::OpticalDrive::Dvdram) {
supportedtypes << I18N_NOOP("DVD-RAM");
}
if (mediatypes & Solid::OpticalDrive::Dvdplusr) {
supportedtypes << I18N_NOOP("DVD+R");
}
if (mediatypes & Solid::OpticalDrive::Dvdplusrw) {
supportedtypes << I18N_NOOP("DVD+RW");
}
if (mediatypes & Solid::OpticalDrive::Dvdplusdl) {
supportedtypes << I18N_NOOP("DVD+DL");
}
if (mediatypes & Solid::OpticalDrive::Dvdplusdlrw) {
supportedtypes << I18N_NOOP("DVD+DLRW");
}
if (mediatypes & Solid::OpticalDrive::Bd) {
supportedtypes << I18N_NOOP("BD");
}
if (mediatypes & Solid::OpticalDrive::Bdr) {
supportedtypes << I18N_NOOP("BD-R");
}
if (mediatypes & Solid::OpticalDrive::Bdre) {
supportedtypes << I18N_NOOP("BD-RE");
}
if (mediatypes & Solid::OpticalDrive::HdDvd) {
supportedtypes << I18N_NOOP("HDDVD");
}
if (mediatypes & Solid::OpticalDrive::HdDvdr) {
supportedtypes << I18N_NOOP("HDDVD-R");
}
if (mediatypes & Solid::OpticalDrive::HdDvdrw) {
supportedtypes << I18N_NOOP("HDDVD-RW");
}
setData(name, I18N_NOOP("Supported Media"), supportedtypes);
setData(name, I18N_NOOP("Read Speed"), opticaldrive->readSpeed());
setData(name, I18N_NOOP("Write Speed"), opticaldrive->writeSpeed());
//the following method return QList<int> so we need to convert it to QList<QVariant>
QList<int> writespeeds = opticaldrive->writeSpeeds();
QList<QVariant> variantlist = QList<QVariant>();
foreach(int num, writespeeds) {
variantlist << QVariant(num);
}
setData(name, I18N_NOOP("Write Speeds"), variantlist);
}
if (device.is<Solid::StorageVolume>()) {
Solid::StorageVolume *storagevolume = device.as<Solid::StorageVolume>();
if (!storagevolume) {
return false;
}
devicetypes << I18N_NOOP("Storage Volume");
QStringList usagetypes;
usagetypes << i18n("Other") << i18n("Unused") << i18n("File System")
<< i18n("Partition Table") << i18n("Raid") << i18n("Encrypted");
if (usagetypes.count() > storagevolume->usage()) {
setData(name, I18N_NOOP("Usage"), usagetypes.at((int)storagevolume->usage()));
} else {
setData(name, I18N_NOOP("Usage"), i18n("Unknown"));
}
setData(name, I18N_NOOP("Ignored"), storagevolume->isIgnored());
setData(name, I18N_NOOP("File System Type"), storagevolume->fsType());
setData(name, I18N_NOOP("Label"), storagevolume->label());
setData(name, I18N_NOOP("UUID"), storagevolume->uuid());
setData(name, I18N_NOOP("Size"), storagevolume->size());
updateInUse(name);
//Check if the volume is part of an encrypted container
//This needs to trigger an update for the encrypted container volume since
//libsolid cannot notify us when the accessibility of the container changes
Solid::Device encryptedContainer = storagevolume->encryptedContainer();
if (encryptedContainer.isValid()) {
QString containerUdi = encryptedContainer.udi();
setData(name, I18N_NOOP("Encrypted Container"), containerUdi);
m_encryptedContainerMap[name] = containerUdi;
//TODO: compress the calls?
forceUpdateAccessibility(containerUdi);
}
}
if (device.is<Solid::OpticalDisc>()) {
Solid::OpticalDisc *opticaldisc = device.as<Solid::OpticalDisc>();
if (!opticaldisc) {
return false;
}
devicetypes << I18N_NOOP("OpticalDisc");
//get the content types
QStringList contenttypelist;
Solid::OpticalDisc::ContentTypes contenttypes = opticaldisc->availableContent();
if (contenttypes & Solid::OpticalDisc::Audio) {
contenttypelist << I18N_NOOP("Audio");
}
if (contenttypes & Solid::OpticalDisc::Data) {
contenttypelist << I18N_NOOP("Data");
}
if (contenttypes & Solid::OpticalDisc::VideoCd) {
contenttypelist << I18N_NOOP("Video CD");
}
if (contenttypes & Solid::OpticalDisc::SuperVideoCd) {
contenttypelist << I18N_NOOP("Super Video CD");
}
if (contenttypes & Solid::OpticalDisc::VideoDvd) {
contenttypelist << I18N_NOOP("Video DVD");
}
if (contenttypes & Solid::OpticalDisc::VideoBluRay) {
contenttypelist << I18N_NOOP("Video Blu Ray");
}
setData(name, I18N_NOOP("Available Content"), contenttypelist);
QStringList disctypes;
disctypes << I18N_NOOP("Unknown Disc Type") << I18N_NOOP("CD Rom") << I18N_NOOP("CD Recordable")
<< I18N_NOOP("CD Rewritable") << I18N_NOOP("DVD Rom") << I18N_NOOP("DVD Ram")
<< I18N_NOOP("DVD Recordable") << I18N_NOOP("DVD Rewritable") << I18N_NOOP("DVD Plus Recordable")
<< I18N_NOOP("DVD Plus Rewritable") << I18N_NOOP("DVD Plus Recordable Duallayer")
<< I18N_NOOP("DVD Plus Rewritable Duallayer") << I18N_NOOP("Blu Ray Rom") << I18N_NOOP("Blu Ray Recordable")
<< I18N_NOOP("Blu Ray Rewritable") << I18N_NOOP("HD DVD Rom") << I18N_NOOP("HD DVD Recordable")
<< I18N_NOOP("HD DVD Rewritable");
setData(name, I18N_NOOP("Disc Type"), disctypes.at((int)opticaldisc->discType()));
setData(name, I18N_NOOP("Appendable"), opticaldisc->isAppendable());
setData(name, I18N_NOOP("Blank"), opticaldisc->isBlank());
setData(name, I18N_NOOP("Rewritable"), opticaldisc->isRewritable());
setData(name, I18N_NOOP("Capacity"), opticaldisc->capacity());
}
if (device.is<Solid::Camera>()) {
Solid::Camera *camera = device.as<Solid::Camera>();
if (!camera) {
return false;
}
devicetypes << I18N_NOOP("Camera");
setData(name, I18N_NOOP("Supported Protocols"), camera->supportedProtocols());
setData(name, I18N_NOOP("Supported Drivers"), camera->supportedDrivers());
// Cameras are necessarily Removable and Hotpluggable
setData(name, I18N_NOOP("Removable"), true);
setData(name, I18N_NOOP("Hotpluggable"), true);
}
if (device.is<Solid::PortableMediaPlayer>()) {
Solid::PortableMediaPlayer *mediaplayer = device.as<Solid::PortableMediaPlayer>();
if (!mediaplayer) {
return false;
}
devicetypes << I18N_NOOP("Portable Media Player");
setData(name, I18N_NOOP("Supported Protocols"), mediaplayer->supportedProtocols());
setData(name, I18N_NOOP("Supported Drivers"), mediaplayer->supportedDrivers());
// Portable Media Players are necessarily Removable and Hotpluggable
setData(name, I18N_NOOP("Removable"), true);
setData(name, I18N_NOOP("Hotpluggable"), true);
}
if (device.is<Solid::NetworkInterface>()) {
Solid::NetworkInterface *networkinterface = device.as<Solid::NetworkInterface>();
if (!networkinterface) {
return false;
}
devicetypes << I18N_NOOP("Network Interface");
setData(name, I18N_NOOP("Interface Name"), networkinterface->ifaceName());
setData(name, I18N_NOOP("Wireless"), networkinterface->isWireless());
setData(name, I18N_NOOP("Loopback"), networkinterface->isLoopback());
setData(name, I18N_NOOP("Hardware Address"), networkinterface->hwAddress());
setData(name, I18N_NOOP("MAC Address"), networkinterface->macAddress());
}
if (device.is<Solid::AcAdapter>()) {
Solid::AcAdapter *ac = device.as<Solid::AcAdapter>();
if (!ac) {
return false;
}
devicetypes << I18N_NOOP("AC Adapter");
setData(name, I18N_NOOP("Plugged In"), ac->isPlugged());
m_signalmanager->mapDevice(ac, device.udi());
}
if (device.is<Solid::Battery>()) {
Solid::Battery *battery = device.as<Solid::Battery>();
if (!battery) {
return false;
}
devicetypes << I18N_NOOP("Battery");
QStringList batterytype;
batterytype << I18N_NOOP("Unknown Battery") << I18N_NOOP("Primary Battery") << I18N_NOOP("UPS Battery")
<< I18N_NOOP("USB Battery");
QStringList chargestate;
chargestate << I18N_NOOP("Unknown Charge") << I18N_NOOP("Charging") << I18N_NOOP("Discharging")
<< I18N_NOOP("Fully Charged");
setData(name, I18N_NOOP("Plugged In"), battery->isPlugged());
setData(name, I18N_NOOP("Type"), batterytype.at((int)battery->type()));
setData(name, I18N_NOOP("Is Power Supply"), battery->isPowerSupply());
setData(name, I18N_NOOP("Capacity"), battery->capacity());
setData(name, I18N_NOOP("Charge Percent"), battery->chargePercent());
setData(name, I18N_NOOP("Rechargeable"), battery->isRechargeable());
setData(name, I18N_NOOP("Charge State"), chargestate.at((int)battery->chargeState()));
m_signalmanager->mapDevice(battery, device.udi());
}
if (device.is<Solid::AudioInterface>()) {
Solid::AudioInterface *audiointerface = device.as<Solid::AudioInterface>();
if (!audiointerface) {
return false;
}
devicetypes << I18N_NOOP("Audio Interface");
QStringList audiodriver;
audiodriver << I18N_NOOP("ALSA") << I18N_NOOP("Open Sound System") << I18N_NOOP("Unknown Audio Driver");
setData(name, I18N_NOOP("Driver"), audiodriver.at((int)audiointerface->driver()));
setData(name, I18N_NOOP("Driver Handle"), audiointerface->driverHandle());
setData(name, I18N_NOOP("Name"), audiointerface->name());
//get AudioInterfaceTypes
QStringList audiointerfacetypes;
Solid::AudioInterface::AudioInterfaceTypes devicetypes = audiointerface->deviceType();
if (devicetypes & Solid::AudioInterface::UnknownAudioInterfaceType) {
audiointerfacetypes << I18N_NOOP("Unknown Audio Interface Type");
}
if (devicetypes & Solid::AudioInterface::AudioControl) {
audiointerfacetypes << I18N_NOOP("Audio Control");
}
if (devicetypes & Solid::AudioInterface::AudioInput) {
audiointerfacetypes << I18N_NOOP("Audio Input");
}
if (devicetypes & Solid::AudioInterface::AudioOutput) {
audiointerfacetypes << I18N_NOOP("Audio Output");
}
setData(name, I18N_NOOP("Audio Device Type"), audiointerfacetypes);
//get SoundCardTypes
QStringList soundcardtype;
soundcardtype << I18N_NOOP("Internal Soundcard") << I18N_NOOP("USB Soundcard") << I18N_NOOP("Firewire Soundcard")
<< I18N_NOOP("Headset") << I18N_NOOP("Modem");
setData(name, I18N_NOOP("Soundcard Type"), soundcardtype.at((int)audiointerface->soundcardType()));
}
if (device.is<Solid::Video>()) {
Solid::Video *video = device.as<Solid::Video>();
if (!video) {
return false;
}
devicetypes << I18N_NOOP("Video");
setData(name, I18N_NOOP("Supported Protocols"), video->supportedProtocols());
setData(name, I18N_NOOP("Supported Drivers"), video->supportedDrivers());
QStringList handles;
foreach (const QString &driver, video->supportedDrivers()) {
handles << video->driverHandle(driver).toString();
}
setData(name, I18N_NOOP("Driver Handles"), handles);
}
if (device.is<Solid::Graphic>()) {
Solid::Graphic *graphic = device.as<Solid::Graphic>();
if (!graphic) {
return false;
}
devicetypes << I18N_NOOP("Graphic");
setData(name, I18N_NOOP("Driver"), graphic->driver());
}
if (device.is<Solid::Input>()) {
Solid::Input *input = device.as<Solid::Input>();
if (!input) {
return false;
}
devicetypes << I18N_NOOP("Input");
QStringList inputtype;
inputtype << I18N_NOOP("Unknown Input") << I18N_NOOP("Mouse") << I18N_NOOP("Keyboard")
<< I18N_NOOP("Joystick");
setData(name, I18N_NOOP("Input Type"), inputtype.at((int)input->inputType()));
setData(name, I18N_NOOP("Driver"), input->driver());
}
int index = Solid::DeviceInterface::staticMetaObject.indexOfEnumerator("Type");
QMetaEnum typeEnum = Solid::DeviceInterface::staticMetaObject.enumerator(index);
for (int i = typeEnum.keyCount() - 1 ; i > 0; i--) {
Solid::DeviceInterface::Type type = (Solid::DeviceInterface::Type)typeEnum.value(i);
const Solid::DeviceInterface *interface = device.asDeviceInterface(type);
if (interface) {
setData(name, I18N_NOOP("Type Description"), Solid::DeviceInterface::typeDescription(type));
break;
}
}
setData(name, I18N_NOOP("Device Types"), devicetypes);
return true;
}
void SolidDeviceEngine::deviceAdded(const QString& udi)
{
Solid::Device device(udi);
foreach (const QString &query, m_predicatemap.keys()) {
Solid::Predicate predicate = Solid::Predicate::fromString(query);
if (predicate.matches(device)) {
m_predicatemap[query] << udi;
setData(query, m_predicatemap[query]);
}
}
if (device.is<Solid::OpticalDisc>()) {
Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
if (drive) {
connect(drive, SIGNAL(ejectRequested(QString)),
this, SLOT(setUnmountingState(QString)));
connect(drive, SIGNAL(ejectDone(Solid::ErrorType,QString,QString)),
this, SLOT(setIdleState(Solid::ErrorType,QString,QString)));
}
} else if (device.is<Solid::StorageVolume>()) {
Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
if (access) {
connect(access, SIGNAL(setupRequested(QString)),
this, SLOT(setMountingState(QString)));
connect(access, SIGNAL(setupDone(Solid::ErrorType,QString,QString)),
this, SLOT(setIdleState(Solid::ErrorType,QString,QString)));
connect(access, SIGNAL(teardownRequested(QString)),
this, SLOT(setUnmountingState(QString)));
connect(access, SIGNAL(teardownDone(Solid::ErrorType,QString,QString)),
this, SLOT(setIdleState(Solid::ErrorType,QString,QString)));
}
}
}
void SolidDeviceEngine::setMountingState(const QString &udi)
{
setData(udi, I18N_NOOP("State"), Mounting);
setData(udi, I18N_NOOP("Operation result"), Working);
}
void SolidDeviceEngine::setUnmountingState(const QString &udi)
{
setData(udi, I18N_NOOP("State"), Unmounting);
setData(udi, I18N_NOOP("Operation result"), Working);
}
void SolidDeviceEngine::setIdleState(Solid::ErrorType error, const QString &errorData, const QString &udi)
{
Q_UNUSED(errorData)
if (error == Solid::NoError) {
setData(udi, I18N_NOOP("Operation result"), Successful);
} else {
setData(udi, I18N_NOOP("Operation result"), Unsuccessful);
}
setData(udi, I18N_NOOP("State"), Idle);
Solid::Device device = m_devicemap.value(udi);
if (!device.isValid()) {
return;
}
Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
if (!storageaccess) {
return;
}
setData(udi, I18N_NOOP("Accessible"), storageaccess->isAccessible());
setData(udi, I18N_NOOP("File Path"), storageaccess->filePath());
}
void SolidDeviceEngine::deviceContentChanged(const QString &udi, const bool hascontent)
{
if (hascontent) {
if (populateDeviceData(udi)) {
forceImmediateUpdateOfAllVisualizations();
}
}
}
qulonglong SolidDeviceEngine::freeDiskSpace(const QString &mountPoint)
{
KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
if (info.isValid()) {
return info.available();
}
return (qulonglong)-1;
}
bool SolidDeviceEngine::updateFreeSpace(const QString &udi)
{
Solid::Device device = m_devicemap.value(udi);
if (!device.is<Solid::StorageAccess>() || device.is<Solid::OpticalDisc>()) {
return false;
} else if (!device.as<Solid::StorageAccess>()->isAccessible()) {
removeData(udi, I18N_NOOP("Free Space"));
removeData(udi, I18N_NOOP("Free Space Text"));
}
Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
if (!storageaccess) {
return false;
}
QVariant freeSpaceVar;
qulonglong freeSpace = freeDiskSpace(storageaccess->filePath());
if (freeSpace != (qulonglong)-1) {
freeSpaceVar.setValue( freeSpace );
}
setData(udi, I18N_NOOP("Free Space"), freeSpaceVar );
setData(udi, I18N_NOOP("Free Space Text"), KGlobal::locale()->formatByteSize(freeSpace));
return true;
}
bool SolidDeviceEngine::updateEmblems(const QString &udi)
{
Solid::Device device = m_devicemap.value(udi);
setData(udi, I18N_NOOP("Emblems"), device.emblems() );
return true;
}
bool SolidDeviceEngine::forceUpdateAccessibility(const QString &udi)
{
Solid::Device device = m_devicemap.value(udi);
if (!device.isValid()) {
return false;
}
updateEmblems(udi);
Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
if (storageaccess) {
setData(udi, I18N_NOOP("Accessible"), storageaccess->isAccessible());
}
return true;
}
bool SolidDeviceEngine::updateInUse(const QString &udi)
{
Solid::Device device = m_devicemap.value(udi);
if (!device.isValid()) {
return false;
}
Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
if (!storageaccess) {
return false;
}
if (storageaccess->isAccessible()) {
setData(udi, I18N_NOOP("In Use"), true);
} else {
Solid::Device device = Solid::Device(udi);
Solid::StorageDrive *drive = device.as<Solid::StorageDrive>();
if (drive) {
setData(udi, I18N_NOOP("In Use"), drive->isInUse());
}
}
return true;
}
bool SolidDeviceEngine::updateSourceEvent(const QString& source)
{
bool update1 = updateFreeSpace(source);
bool update2 = updateEmblems(source);
bool update3 = updateInUse(source);
// TODO: update battery state?
return (update1 || update2 || update3);
}
void SolidDeviceEngine::deviceRemoved(const QString& udi)
{
//libsolid cannot notify us when an encrypted container is closed,
//hence we trigger an update when a device contained in an encrypted container device dies
QString containerUdi = m_encryptedContainerMap.value(udi, QString());
if (!containerUdi.isEmpty()) {
forceUpdateAccessibility(containerUdi);
m_encryptedContainerMap.remove(udi);
}
foreach (const QString &query, m_predicatemap.keys()) {
m_predicatemap[query].removeAll(udi);
setData(query, m_predicatemap[query]);
}
Solid::Device device(udi);
if (device.is<Solid::StorageVolume>()) {
Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
if (access) {
disconnect(access, 0, this, 0);
}
}
else if (device.is<Solid::OpticalDisc>()) {
Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
if (drive) {
disconnect(drive, 0, this, 0);
}
}
m_devicemap.remove(udi);
removeSource(udi);
}
void SolidDeviceEngine::deviceChanged(const QString& udi, const QString &property, const QVariant &value)
{
setData(udi, property, value);
updateSourceEvent(udi);
}
K_EXPORT_PLASMA_DATAENGINE(soliddevice, SolidDeviceEngine)
#include "moc_soliddeviceengine.cpp"

View file

@ -1,97 +0,0 @@
/*
* Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SOLIDDEVICEENGINE_H
#define SOLIDDEVICEENGINE_H
#include <QObject>
#include <QString>
#include <QList>
#include <QMap>
#include <QPair>
#include <solid/devicenotifier.h>
#include <solid/device.h>
#include <solid/deviceinterface.h>
#include <solid/predicate.h>
#include <Plasma/Service>
#include <Plasma/DataEngine>
#include "devicesignalmapmanager.h"
#include "devicesignalmapper.h"
enum State {
Idle = 0,
Mounting = 1,
Unmounting = 2
};
enum OperationResult {
Working = 0,
Successful = 1,
Unsuccessful =2
};
/**
* This class evaluates the basic expressions given in the interface.
*/
class SolidDeviceEngine : public Plasma::DataEngine
{
Q_OBJECT
friend class SolidDeviceService;
public:
SolidDeviceEngine( QObject* parent, const QVariantList& args);
~SolidDeviceEngine();
Plasma::Service *serviceForSource (const QString& source);
protected:
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString& source);
private:
bool populateDeviceData(const QString &name);
qulonglong freeDiskSpace(const QString &mountPoint);
bool updateFreeSpace(const QString &udi);
bool updateEmblems(const QString &udi);
bool updateInUse(const QString &udi);
bool forceUpdateAccessibility(const QString &udi);
void listenForNewDevices();
//predicate in string form, list of devices by udi
QMap<QString, QStringList> m_predicatemap;
//udi, corresponding device
QMap<QString, Solid::Device> m_devicemap;
//udi, corresponding encrypted container udi;
QMap<QString, QString> m_encryptedContainerMap;
DeviceSignalMapManager *m_signalmanager;
Solid::DeviceNotifier *m_notifier;
private Q_SLOTS:
void deviceAdded(const QString &udi);
void deviceRemoved(const QString &udi);
void deviceChanged(const QString& udi, const QString &property, const QVariant &value);
void sourceWasRemoved(const QString &source);
void setMountingState(const QString &udi);
void setUnmountingState(const QString &udi);
void setIdleState(Solid::ErrorType error, const QString &errorData, const QString &udi);
void deviceContentChanged(const QString &udi, const bool hascontent);
};
#endif

View file

@ -1,61 +0,0 @@
/*
* Copyright (C) 2011 Viranch Mehta <viranch.mehta@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "soliddevicejob.h"
#include "soliddeviceengine.h"
#include <solid/device.h>
#include <solid/opticaldisc.h>
#include <solid/storageaccess.h>
#include <solid/opticaldrive.h>
#include <KDebug>
void SolidDeviceJob::start()
{
Solid::Device device (m_dest);
QString operation = operationName();
if (operation == "mount") {
if (device.is<Solid::StorageAccess>()) {
Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
if (access && !access->isAccessible()) {
access->setup();
}
}
}
else if (operation == "unmount") {
if (device.is<Solid::OpticalDisc>()) {
Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
if (drive) {
drive->eject();
}
}
else if (device.is<Solid::StorageAccess>()) {
Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
if (access && access->isAccessible()) {
access->teardown();
}
}
}
emitResult();
}
#include "moc_soliddevicejob.cpp"

View file

@ -1,50 +0,0 @@
/*
* Copyright (C) 2011 Viranch Mehta <viranch.mehta@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SOLIDDEVICE_JOB_H
#define SOLIDDEVICE_JOB_H
#include "soliddeviceengine.h"
#include <Plasma/ServiceJob>
class SolidDeviceJob : public Plasma::ServiceJob
{
Q_OBJECT
public:
SolidDeviceJob (SolidDeviceEngine* engine,
const QString& destination,
const QString& operation,
const QMap<QString, QVariant>& parameters,
QObject* parent = 0)
: ServiceJob (destination, operation, parameters, parent),
m_engine (engine),
m_dest (destination)
{
}
void start();
private:
SolidDeviceEngine* m_engine;
QString m_dest;
};
#endif // SOLIDDEVICE_JOB_H

View file

@ -1,49 +0,0 @@
/*
* Copyright (C) 2011 Viranch Mehta <viranch.mehta@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "soliddeviceservice.h"
#include "soliddevicejob.h"
#include "soliddeviceengine.h"
SolidDeviceService::SolidDeviceService (SolidDeviceEngine* parent, const QString& source)
: Plasma::Service (parent),
m_engine(parent)
{
setName ("soliddevice");
setOperationNames(
QStringList()
<< "mount"
<< "unmount"
<< "updateFreespace"
);
setDestination (source);
}
Plasma::ServiceJob* SolidDeviceService::createJob (const QString& operation,
const QMap <QString, QVariant>& parameters)
{
if (operation == "updateFreespace") {
m_engine->updateFreeSpace(destination());
return 0;
}
return new SolidDeviceJob (m_engine, destination(), operation, parameters, this);
}
#include "moc_soliddeviceservice.cpp"

View file

@ -1,43 +0,0 @@
/*
* Copyright (C) 2011 Viranch Mehta <viranch.mehta@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SOLIDDEVICE_SERVICE_H
#define SOLIDDEVICE_SERVICE_H
#include <Plasma/Service>
class SolidDeviceEngine;
class SolidDeviceService : public Plasma::Service
{
Q_OBJECT
public:
SolidDeviceService (SolidDeviceEngine* parent, const QString& source);
protected:
Plasma::ServiceJob* createJob (const QString& operation,
const QMap<QString, QVariant>& parameters);
private:
SolidDeviceEngine* m_engine;
QString m_dest;
};
#endif // SOLIDDEVICE_SERVICE_H

View file

@ -1,14 +0,0 @@
set(systemmonitor_engine_SRCS
systemmonitor.cpp
)
kde4_add_plugin(plasma_engine_systemmonitor ${systemmonitor_engine_SRCS})
target_link_libraries(plasma_engine_systemmonitor KDE4::plasma KDE4::kdecore ${QT_QTNETWORK_LIBRARY} ksgrd)
install(TARGETS plasma_engine_systemmonitor DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
install(FILES plasma-dataengine-systemmonitor.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} )

View file

@ -1,2 +0,0 @@
#!/bin/bash
$XGETTEXT *.cpp -o $podir/plasma_engine_systemmonitor.pot

View file

@ -1,166 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=System Monitor
Name[af]=Stelsel Monitor
Name[ar]=مراقب النظام
Name[ast]=Monitor del sistema
Name[be]=Сістэмны назіральнік
Name[be@latin]=Systemny nazirańnik
Name[bg]=Наблюдение на системата
Name[bn]=ি ি
Name[bn_IN]=ি ি
Name[bs]=Monitor sistema
Name[ca]=Monitor del sistema
Name[ca@valencia]=Monitor del sistema
Name[cs]=Monitor systému
Name[csb]=Mònitór systemë
Name[da]=Systemovervågning
Name[de]=Systemmonitor
Name[el]=Επόπτης συστήματος
Name[en_GB]=System Monitor
Name[eo]=Sistemstato-programo
Name[es]=Monitor del sistema
Name[et]=Süsteemi jälgija
Name[eu]=Sistema-monitorea
Name[fa]=نمایشگر سیستم
Name[fi]=Järjestelmän valvonta
Name[fr]=Surveillance du système
Name[fy]=Systeemmonitor
Name[ga]=Monatóir an Chórais
Name[gl]=Vixilante do sistema
Name[gu]=િ
Name[he]=מוניטור המערכת
Name[hi]=
Name[hne]=
Name[hr]=Nadzor sustava
Name[hsb]=Systemowy monitor
Name[hu]=Rendszermonitor
Name[ia]=Monitor de systema
Name[id]=Monitor Sistem
Name[is]=Kerfiseftirlit
Name[it]=Monitor di sistema
Name[ja]=
Name[kk]=Жүйе мониторы
Name[km]=
Name[kn]=
Name[ko]=
Name[ku]=Temaşekerê Pergalê
Name[lt]=Sistemos stebėtojas
Name[lv]=Sistēmas monitors
Name[mai]=ि
Name[mk]=Системски монитор
Name[ml]=ി ി
Name[mr]= ि
Name[nb]=Systemovervåker
Name[nds]=Systeemkieker
Name[ne]= ि
Name[nl]=Systeemmonitor
Name[nn]=Systemovervaking
Name[oc]=Monitor sistèma
Name[pa]=ਿ
Name[pl]=Monitor systemu
Name[pt]=Monitor do Sistema
Name[pt_BR]=Monitor do sistema
Name[ro]=Monitor de sistem
Name[ru]=Системный монитор
Name[se]=Vuogádatgoziheaddji
Name[si]=
Name[sk]=Monitor systému
Name[sl]=Sistemski nadzornik
Name[sr]=надзорник система
Name[sr@ijekavian]=надзорник система
Name[sr@ijekavianlatin]=nadzornik sistema
Name[sr@latin]=nadzornik sistema
Name[sv]=Systemövervakare
Name[ta]=ிி
Name[te]=ి ి
Name[tg]=Назорати система
Name[th]=
Name[tr]=Sistem İzleyici
Name[ug]=سىستېما كۆزەتكۈچ
Name[uk]=Монітор системи
Name[vi]=B theo dõi h thng
Name[wa]=Corwaitoe do sistinme
Name[x-test]=xxSystem Monitorxx
Name[zh_CN]=
Name[zh_TW]=
Comment=System status information
Comment[ar]=معلومات حالة النظام
Comment[ast]=Información d'estáu del sistema
Comment[bg]=Данни за състоянието на системата
Comment[bn]=ি
Comment[bs]=Podaci o stanju sistema
Comment[ca]=Informació de l'estat del sistema
Comment[ca@valencia]=Informació de l'estat del sistema
Comment[cs]=Informace o stavu systému
Comment[csb]=Wëdowiédzô ò stónie systemë
Comment[da]=Information om systemstatus
Comment[de]=Systemstatus-Informationen
Comment[el]=Πληροφορίες κατάστασης συστήματος
Comment[en_GB]=System status information
Comment[eo]=Sistemstataj informoj
Comment[es]=Información de estado del sistema
Comment[et]=Süsteemi oleku teave
Comment[eu]=Sistemaren egoerari buruzko informazioa
Comment[fi]=Järjestelmätilatiedot
Comment[fr]=Informations sur l'état du système
Comment[fy]=Systeemtastân ynformaasje
Comment[ga]=Eolas faoi stádas an chórais
Comment[gl]=Información do estado do sistema
Comment[gu]=િ િિ િ
Comment[he]=מידע אודות מצב המערכת
Comment[hi]= िि
Comment[hr]=Podaci o stanju sustava
Comment[hu]=Rendszerjellemzők
Comment[ia]=Information de stato de systema
Comment[id]=Informasi status sistem
Comment[is]=Upplýsingar um kerfisforrit
Comment[it]=Informazioni sullo stato del sistema
Comment[ja]=
Comment[kk]=Жүйе күй-жайы туралы мәлімет
Comment[km]=
Comment[kn]= ಿಿ ಿಿ
Comment[ko]=
Comment[lt]=Sistemos būklės informacija
Comment[lv]=Sistēmas statusa informācija
Comment[mk]=Информации за статусот на системот
Comment[ml]=ിി ി
Comment[mr]= ि ि
Comment[nb]=Informasjon om systemstatus
Comment[nds]=Systeemstatus-Informatschonen
Comment[nl]=Informatie over systeemstatus
Comment[nn]=Informasjon om systemstatus
Comment[pa]=ਿ
Comment[pl]=Informacje o stanie systemu
Comment[pt]=Informações do estado do sistema
Comment[pt_BR]=Informação do status do sistema
Comment[ro]=Informații despre starea sistemului
Comment[ru]=Сведения о системе
Comment[si]=
Comment[sk]=Informácie o stave systému
Comment[sl]=Podatki o stanju sistema
Comment[sr]=Подаци о стању система
Comment[sr@ijekavian]=Подаци о стању система
Comment[sr@ijekavianlatin]=Podaci o stanju sistema
Comment[sr@latin]=Podaci o stanju sistema
Comment[sv]=Information om systemstatus
Comment[tg]=Барномаи маълумоти система
Comment[th]=
Comment[tr]=Sistem durumu bilgileri
Comment[ug]=سىستېما ھالەت ئۇچۇرى
Comment[uk]=Інформація про стан системи
Comment[wa]=Informåcion so l' estat do sistinme
Comment[x-test]=xxSystem status informationxx
Comment[zh_CN]=
Comment[zh_TW]=
ServiceTypes=Plasma/DataEngine
Icon=utilities-system-monitor
Type=Service
X-KDE-Library=plasma_engine_systemmonitor
X-KDE-PluginInfo-Author=
X-KDE-PluginInfo-Email=
X-KDE-PluginInfo-Name=systemmonitor
X-KDE-PluginInfo-Version=
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=

View file

@ -1,210 +0,0 @@
/*
* Copyright (C) 2007 John Tapsell <tapsell@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "systemmonitor.h"
#include <QTimer>
#include <QProcess>
#include <KDebug>
#include <KLocale>
#include <Plasma/DataContainer>
#include "ksysguard/ksgrd/SensorManager.h"
SystemMonitorEngine::SystemMonitorEngine(QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent)
{
Q_UNUSED(args)
KSGRD::SensorMgr = new KSGRD::SensorManager(this);
KSGRD::SensorMgr->engage("localhost", "", "ksysguardd");
m_waitingFor= 0;
connect(KSGRD::SensorMgr, SIGNAL(update()), this, SLOT(updateMonitorsList()));
updateMonitorsList();
}
SystemMonitorEngine::~SystemMonitorEngine()
{
}
void SystemMonitorEngine::updateMonitorsList()
{
KSGRD::SensorMgr->sendRequest("localhost", "monitors", (KSGRD::SensorClient*)this, -1);
}
QStringList SystemMonitorEngine::sources() const
{
return m_sensors;
}
bool SystemMonitorEngine::sourceRequestEvent(const QString &name)
{
// NB: do not follow this example in your own data engines!
// This is kept for backwards compatilibility.
// Visualizations should instead listen to sourceAdded()
if (m_sensors.isEmpty()) {
// we don't have our first data yet, so let's trust the requester, at least fo rnow
// when we get our list of sensors later, then we'll know for sure and remove
// this source if they were wrong
setData(name, DataEngine::Data());
return true;
}
return false;
}
bool SystemMonitorEngine::updateSourceEvent(const QString &sensorName)
{
const int index = m_sensors.indexOf(sensorName);
if (index != -1) {
KSGRD::SensorMgr->sendRequest("localhost", sensorName, (KSGRD::SensorClient*)this, index);
KSGRD::SensorMgr->sendRequest("localhost", QString("%1?").arg(sensorName), (KSGRD::SensorClient*)this, -(index + 2));
}
return false;
}
void SystemMonitorEngine::updateSensors()
{
DataEngine::SourceDict sources = containerDict();
DataEngine::SourceDict::iterator it = sources.begin();
if (m_waitingFor != 0) {
scheduleSourcesUpdated();
}
m_waitingFor = 0;
while (it != sources.end()) {
m_waitingFor++;
QString sensorName = it.key();
KSGRD::SensorMgr->sendRequest( "localhost", sensorName, (KSGRD::SensorClient*)this, -1);
++it;
}
}
void SystemMonitorEngine::answerReceived(int id, const QList<QByteArray> &answer)
{
if (id < -1) {
if (answer.isEmpty() || m_sensors.count() <= (-id - 2)) {
kDebug() << "sensor info answer was empty, (" << answer.isEmpty() << ") or sensors does not exist to us ("
<< (m_sensors.count() < (-id - 2)) << ") for index" << (-id - 2);
return;
}
DataEngine::SourceDict sources = containerDict();
DataEngine::SourceDict::const_iterator it = sources.constFind(m_sensors.value(-id - 2));
const QStringList newSensorInfo = QString::fromUtf8(answer[0]).split('\t');
if (newSensorInfo.count() < 4) {
kDebug() << "bad sensor info, only" << newSensorInfo.count()
<< "entries, and we were expecting 4. Answer was " << answer;
if(it != sources.constEnd())
kDebug() << "value =" << it.value()->data()["value"] << "type=" << it.value()->data()["type"];
return;
}
const QString sensorName = newSensorInfo[0];
const QString min = newSensorInfo[1];
const QString max = newSensorInfo[2];
const QString unit = newSensorInfo[3];
if (it != sources.constEnd()) {
it.value()->setData("name", sensorName);
it.value()->setData("min", min);
it.value()->setData("max", max);
it.value()->setData("units", unit);
scheduleSourcesUpdated();
}
return;
}
if (id == -1) {
QSet<QString> sensors;
m_sensors.clear();
int count = 0;
foreach (const QByteArray &sens, answer) {
const QStringList newSensorInfo = QString::fromUtf8(sens).split('\t');
if (newSensorInfo.count() < 2) {
continue;
}
if(newSensorInfo.at(1) == "logfile")
continue; // logfile data type not currently supported
const QString newSensor = newSensorInfo[0];
sensors.insert(newSensor);
m_sensors.append(newSensor);
{
// HACK: for backwards compability
// in case this source was created in sourceRequestEvent, stop it being
// automagically removed when disconnected from
Plasma::DataContainer *s = containerForSource( newSensor );
if ( s ) {
disconnect( s, SIGNAL(becameUnused(QString)), this, SLOT(removeSource(QString)) );
}
}
DataEngine::Data d;
d.insert("value", QVariant());
d.insert("type", newSensorInfo[1]);
setData(newSensor, d);
KSGRD::SensorMgr->sendRequest( "localhost", QString("%1?").arg(newSensor), (KSGRD::SensorClient*)this, -(count + 2));
++count;
}
QHash<QString, Plasma::DataContainer*> sourceDict = containerDict();
QHashIterator<QString, Plasma::DataContainer*> it(sourceDict);
while (it.hasNext()) {
it.next();
if (!sensors.contains(it.key())) {
removeSource(it.key());
}
}
return;
}
m_waitingFor--;
QString reply;
if (!answer.isEmpty()) {
reply = QString::fromUtf8(answer[0]);
}
DataEngine::SourceDict sources = containerDict();
DataEngine::SourceDict::const_iterator it = sources.constFind(m_sensors.value(id));
if (it != sources.constEnd()) {
it.value()->setData("value", reply);
}
if (m_waitingFor == 0) {
scheduleSourcesUpdated();
}
}
void SystemMonitorEngine::sensorLost( int )
{
m_waitingFor--;
}
#include "moc_systemmonitor.cpp"

View file

@ -1,62 +0,0 @@
/*
* Copyright (C) 2007 John Tapsell <tapsell@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SYSTEMMONITORENGINE_H
#define SYSTEMMONITORENGINE_H
#include <Plasma/DataEngine>
#include "ksysguard/ksgrd/SensorClient.h"
#include <QStringList>
#include <QTimer>
/**
* This class evaluates the basic expressions given in the interface.
*/
class SystemMonitorEngine : public Plasma::DataEngine, public KSGRD::SensorClient
{
Q_OBJECT
public:
/** Inherited from Plasma::DataEngine. Returns a list of all the sensors that ksysguardd knows about. */
virtual QStringList sources() const;
SystemMonitorEngine( QObject* parent, const QVariantList& args );
~SystemMonitorEngine();
protected:
bool sourceRequestEvent(const QString &name);
/** inherited from SensorClient */
virtual void answerReceived( int id, const QList<QByteArray>&answer );
virtual void sensorLost( int );
virtual bool updateSourceEvent(const QString &sensorName);
protected slots:
void updateSensors();
void updateMonitorsList();
private:
QStringList m_sensors;
int m_waitingFor;
};
K_EXPORT_PLASMA_DATAENGINE(systemmonitor, SystemMonitorEngine)
#endif