Changeset View
Changeset View
Standalone View
Standalone View
plugins/global/ksgrd/ksgrdiface.cpp
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Line(s) | 286 | if (id == -1) { | |||
---|---|---|---|---|---|
287 | onSensorListRetrieved(answer); | 287 | onSensorListRetrieved(answer); | ||
288 | return; | 288 | return; | ||
289 | } | 289 | } | ||
290 | onSensorUpdated(id, answer); | 290 | onSensorUpdated(id, answer); | ||
291 | } | 291 | } | ||
292 | 292 | | |||
293 | void KSGRDIface::addAggregateSensors() | 293 | void KSGRDIface::addAggregateSensors() | ||
294 | { | 294 | { | ||
295 | auto networkAll = new SensorObject("all", i18n("All"), m_subsystems["network"]); | 295 | auto networkAll = new SensorObject("all", i18nc("@title All Network Interfaces", "All"), m_subsystems["network"]); | ||
296 | 296 | | |||
297 | auto sensor = new AggregateSensor(networkAll, "receivedDataRate", i18n("Received Data Rate")); | 297 | auto sensor = new AggregateSensor(networkAll, "receivedDataRate", i18nc("@title", "Received Data Rate")); | ||
298 | sensor->setShortName(i18n("Down")); | 298 | sensor->setShortName(i18nc("@title Received Data Rate", "Down")); | ||
299 | sensor->setMatchSensors(QRegularExpression("[^/]*/receiver"), QStringLiteral("data")); | 299 | sensor->setMatchSensors(QRegularExpression("[^/]*/receiver"), QStringLiteral("data")); | ||
300 | sensor->setDescription(i18n("The rate at which data is received on all interfaces.")); | 300 | sensor->setDescription(i18nc("@info", "The rate at which data is received on all interfaces.")); | ||
301 | sensor->setUnit(KSysGuard::utils::UnitKiloByteRate); | 301 | sensor->setUnit(KSysGuard::utils::UnitKiloByteRate); | ||
302 | 302 | | |||
303 | sensor = new AggregateSensor(networkAll, "totalReceivedData", i18n("Total Received Data")); | 303 | sensor = new AggregateSensor(networkAll, "totalReceivedData", i18nc("@title", "Total Received Data")); | ||
304 | sensor->setShortName(i18n("Total Down")); | 304 | sensor->setShortName(i18nc("@title Total Receieved Data", "Total Down")); | ||
305 | sensor->setMatchSensors(QRegularExpression("[^/]*/receiver"), QStringLiteral("dataTotal")); | 305 | sensor->setMatchSensors(QRegularExpression("[^/]*/receiver"), QStringLiteral("dataTotal")); | ||
306 | sensor->setDescription(i18n("The total amount of data received on all interfaces.")); | 306 | sensor->setDescription(i18nc("@info", "The total amount of data received on all interfaces.")); | ||
307 | sensor->setUnit(KSysGuard::utils::UnitKiloByte); | 307 | sensor->setUnit(KSysGuard::utils::UnitKiloByte); | ||
308 | 308 | | |||
309 | sensor = new AggregateSensor(networkAll, "sentDataRate", i18n("Sent Data Rate")); | 309 | sensor = new AggregateSensor(networkAll, "sentDataRate", i18nc("@title", "Sent Data Rate")); | ||
310 | sensor->setShortName(i18n("Up")); | 310 | sensor->setShortName(i18nc("@title Sent Data Rate", "Up")); | ||
311 | sensor->setMatchSensors(QRegularExpression("[^/]*/transmitter"), QStringLiteral("data")); | 311 | sensor->setMatchSensors(QRegularExpression("[^/]*/transmitter"), QStringLiteral("data")); | ||
312 | sensor->setDescription(i18n("The rate at which data is sent on all interfaces.")); | 312 | sensor->setDescription(i18nc("@info", "The rate at which data is sent on all interfaces.")); | ||
313 | sensor->setUnit(KSysGuard::utils::UnitKiloByteRate); | 313 | sensor->setUnit(KSysGuard::utils::UnitKiloByteRate); | ||
314 | 314 | | |||
315 | sensor = new AggregateSensor(networkAll, "totalSentData", i18n("Total Sent Data")); | 315 | sensor = new AggregateSensor(networkAll, "totalSentData", i18nc("@title", "Total Sent Data")); | ||
316 | sensor->setShortName(i18n("Total Up")); | 316 | sensor->setShortName(i18nc("@title Total Sent Data", "Total Up")); | ||
317 | sensor->setMatchSensors(QRegularExpression("[^/]*/transmitter"), QStringLiteral("dataTotal")); | 317 | sensor->setMatchSensors(QRegularExpression("[^/]*/transmitter"), QStringLiteral("dataTotal")); | ||
318 | sensor->setDescription(i18n("The total amount of data sent on all interfaces.")); | 318 | sensor->setDescription(i18nc("@info", "The total amount of data sent on all interfaces.")); | ||
319 | sensor->setUnit(KSysGuard::utils::UnitKiloByte); | 319 | sensor->setUnit(KSysGuard::utils::UnitKiloByte); | ||
320 | 320 | | |||
321 | auto diskAll = new SensorObject("all", i18n("all"), m_subsystems["disk"]); | 321 | auto diskAll = new SensorObject("all", i18nc("@title All Disks", "All"), m_subsystems["disk"]); | ||
322 | sensor = new AggregateSensor(diskAll, "read", i18n("Disk Read Accesses")); | 322 | sensor = new AggregateSensor(diskAll, "read", i18nc("@title", "Disk Read Accesses")); | ||
323 | sensor->setShortName(i18n("Read")); | 323 | sensor->setShortName(i18nc("@title Disk Read Accesses", "Read")); | ||
324 | // TODO: This regex is not exhaustive as it doesn't consider things that aren't treated as sdX devices. | 324 | // TODO: This regex is not exhaustive as it doesn't consider things that aren't treated as sdX devices. | ||
325 | // However, we do not simply want to match disk/* as that would include duplicate devices. | 325 | // However, we do not simply want to match disk/* as that would include duplicate devices. | ||
326 | sensor->setMatchSensors(QRegularExpression("^sd[a-z]+[0-9]+_[^/]*/Rate$"), QStringLiteral("rblk")); | 326 | sensor->setMatchSensors(QRegularExpression("^sd[a-z]+[0-9]+_[^/]*/Rate$"), QStringLiteral("rblk")); | ||
327 | sensor->setDescription(i18n("Read accesses across all disk devices")); | 327 | sensor->setDescription(i18nc("@info", "Read accesses across all disk devices")); | ||
328 | 328 | | |||
329 | sensor = new AggregateSensor(diskAll, "write", i18n("Disk Write Accesses")); | 329 | sensor = new AggregateSensor(diskAll, "write", i18nc("@title", "Disk Write Accesses")); | ||
330 | sensor->setShortName(i18n("Write")); | 330 | sensor->setShortName(i18nc("@title Disk Write Accesses", "Write")); | ||
331 | // TODO: See above. | 331 | // TODO: See above. | ||
332 | sensor->setMatchSensors(QRegularExpression("^sd[a-z]+[0-9]+_[^/]*/Rate$"), QStringLiteral("wblk")); | 332 | sensor->setMatchSensors(QRegularExpression("^sd[a-z]+[0-9]+_[^/]*/Rate$"), QStringLiteral("wblk")); | ||
333 | sensor->setDescription(i18n("Write accesses across all disk devices")); | 333 | sensor->setDescription(i18nc("@info", "Write accesses across all disk devices")); | ||
334 | 334 | | |||
335 | auto memPhysical = m_subsystems["mem"]->object("physical"); | 335 | auto memPhysical = m_subsystems["mem"]->object("physical"); | ||
336 | Q_ASSERT(memPhysical); | 336 | Q_ASSERT(memPhysical); | ||
337 | if (!memPhysical) { | 337 | if (!memPhysical) { | ||
338 | return; | 338 | return; | ||
339 | } | 339 | } | ||
340 | 340 | | |||
341 | PercentageSensor *appLevel = new PercentageSensor(memPhysical, "applicationlevel", i18n("Application Memory Percentage")); | 341 | PercentageSensor *appLevel = new PercentageSensor(memPhysical, "applicationlevel", i18nc("@title", "Application Memory Percentage")); | ||
342 | appLevel->setShortName(i18n("Application")); | 342 | appLevel->setShortName(i18nc("@title Application Memory Percentage", "Application")); | ||
343 | appLevel->setBaseSensor(memPhysical->sensor("application")); | 343 | appLevel->setBaseSensor(memPhysical->sensor("application")); | ||
344 | appLevel->setDescription(i18n("Percentage of memory taken by applications.")); | 344 | appLevel->setDescription(i18nc("@info", "Percentage of memory taken by applications.")); | ||
345 | 345 | | |||
346 | PercentageSensor *bufLevel = new PercentageSensor(memPhysical, "buflevel", i18n("Buffer Memory Percentage")); | 346 | PercentageSensor *bufLevel = new PercentageSensor(memPhysical, "buflevel", i18nc("@title", "Buffer Memory Percentage")); | ||
347 | bufLevel->setShortName(i18n("Buffer")); | 347 | bufLevel->setShortName(i18nc("@title Buffer Memory Percentage", "Buffer")); | ||
348 | bufLevel->setBaseSensor(memPhysical->sensor("buf")); | 348 | bufLevel->setBaseSensor(memPhysical->sensor("buf")); | ||
349 | bufLevel->setDescription(i18n("Percentage of memory taken by the buffer.")); | 349 | bufLevel->setDescription(i18nc("@info", "Percentage of memory taken by the buffer.")); | ||
350 | 350 | | |||
351 | PercentageSensor *cacheLevel = new PercentageSensor(memPhysical, "cachelevel", i18n("Cache Memory Percentage")); | 351 | PercentageSensor *cacheLevel = new PercentageSensor(memPhysical, "cachelevel", i18nc("@title", "Cache Memory Percentage")); | ||
352 | cacheLevel->setShortName(i18n("Cache")); | 352 | cacheLevel->setShortName(i18nc("@title Cache Memory Percentage", "Cache")); | ||
353 | cacheLevel->setBaseSensor(memPhysical->sensor("cached")); | 353 | cacheLevel->setBaseSensor(memPhysical->sensor("cached")); | ||
354 | cacheLevel->setDescription(i18n("Percentage of memory taken by the cache.")); | 354 | cacheLevel->setDescription(i18nc("@info", "Percentage of memory taken by the cache.")); | ||
355 | 355 | | |||
356 | PercentageSensor *freeLevel = new PercentageSensor(memPhysical, "freelevel", i18n("Free Memory Percentage")); | 356 | PercentageSensor *freeLevel = new PercentageSensor(memPhysical, "freelevel", i18nc("@title", "Free Memory Percentage")); | ||
357 | freeLevel->setShortName(i18n("Cache")); | 357 | freeLevel->setShortName(i18nc("@title Free Memory Percentage", "Free")); | ||
358 | freeLevel->setBaseSensor(memPhysical->sensor("free")); | 358 | freeLevel->setBaseSensor(memPhysical->sensor("free")); | ||
359 | freeLevel->setDescription(i18n("Percentage of free memory.")); | 359 | freeLevel->setDescription(i18nc("@info", "Percentage of free memory.")); | ||
360 | 360 | | |||
361 | PercentageSensor *usedLevel = new PercentageSensor(memPhysical, "usedlevel", i18n("Used Memory Percentage")); | 361 | PercentageSensor *usedLevel = new PercentageSensor(memPhysical, "usedlevel", i18nc("@title", "Used Memory Percentage")); | ||
362 | usedLevel->setShortName(i18n("Used")); | 362 | usedLevel->setShortName(i18nc("@title Used Memory Percentage", "Used")); | ||
363 | usedLevel->setBaseSensor(memPhysical->sensor("used")); | 363 | usedLevel->setBaseSensor(memPhysical->sensor("used")); | ||
364 | usedLevel->setDescription(i18n("Percentage of used memory.")); | 364 | usedLevel->setDescription(i18nc("@info", "Percentage of used memory.")); | ||
365 | 365 | | |||
366 | PercentageSensor *availableLevel = new PercentageSensor(memPhysical, "availablelevel", i18n("Available Memory Percentage")); | 366 | PercentageSensor *availableLevel = new PercentageSensor(memPhysical, "availablelevel", i18nc("@title", "Available Memory Percentage")); | ||
367 | availableLevel->setShortName(i18n("Available")); | 367 | availableLevel->setShortName(i18nc("@title Available Memory Percentage", "Available")); | ||
368 | availableLevel->setBaseSensor(memPhysical->sensor("available")); | 368 | availableLevel->setBaseSensor(memPhysical->sensor("available")); | ||
369 | availableLevel->setDescription(i18n("Percentage of used memory.")); | 369 | availableLevel->setDescription(i18nc("@info", "Percentage of available memory.")); | ||
370 | 370 | | |||
371 | PercentageSensor *allocatedLevel = new PercentageSensor(memPhysical, "allocatedlevel", i18n("Allocated Memory Percentage")); | 371 | PercentageSensor *allocatedLevel = new PercentageSensor(memPhysical, "allocatedlevel", i18nc("@title", "Allocated Memory Percentage")); | ||
372 | allocatedLevel->setShortName(i18n("Used")); | 372 | allocatedLevel->setShortName(i18nc("@title Allocated Memory Percentage", "Used")); | ||
373 | allocatedLevel->setBaseSensor(memPhysical->sensor("allocated")); | 373 | allocatedLevel->setBaseSensor(memPhysical->sensor("allocated")); | ||
374 | allocatedLevel->setDescription(i18n("Percentage of used memory.")); | 374 | allocatedLevel->setDescription(i18nc("@info", "Percentage of allocated memory.")); | ||
375 | } | 375 | } | ||
376 | 376 | | |||
377 | QString KSGRDIface::shortNameFor(const QString &key) | 377 | QString KSGRDIface::shortNameFor(const QString &key) | ||
378 | { | 378 | { | ||
379 | // TODO: This is pretty ugly, but it is really hard to add this information to ksysguardd. | 379 | // TODO: This is pretty ugly, but it is really hard to add this information to ksysguardd. | ||
380 | // So for now, we just map sensor ids to short names and return that. | 380 | // So for now, we just map sensor ids to short names and return that. | ||
381 | 381 | | |||
382 | static QHash<QString, QString> shortNames = { | 382 | static QHash<QString, QString> shortNames = { | ||
383 | { QStringLiteral("cpu/system/TotalLoad"), i18n("Usage") }, | 383 | { QStringLiteral("cpu/system/TotalLoad"), i18nc("@title Total CPU Usage", "Usage") }, | ||
384 | { QStringLiteral("mem/physical/used"), i18n("Total Used") }, | 384 | { QStringLiteral("mem/physical/used"), i18nc("@title Total Memory Usage", "Total Used") }, | ||
385 | { QStringLiteral("mem/physical/cached"), i18n("Cached") }, | 385 | { QStringLiteral("mem/physical/cached"), i18nc("@title Cached Memory Usage", "Cached") }, | ||
386 | { QStringLiteral("mem/physical/free"), i18n("Free") }, | 386 | { QStringLiteral("mem/physical/free"), i18nc("@title Free Memory Amount", "Free") }, | ||
387 | { QStringLiteral("mem/physical/available"), i18n("Avalable") }, | 387 | { QStringLiteral("mem/physical/available"), i18nc("@title Available Memory Amount", "Avalable") }, | ||
388 | { QStringLiteral("mem/physical/application"), i18n("Application") }, | 388 | { QStringLiteral("mem/physical/application"), i18nc("@title Application Memory Usage", "Application") }, | ||
389 | { QStringLiteral("mem/physical/buf"), i18n("Buffer") }, | 389 | { QStringLiteral("mem/physical/buf"), i18nc("@title Buffer Memory Usage", "Buffer") }, | ||
390 | { QStringLiteral("cpu/system/processors"), i18n("Processors") }, | 390 | { QStringLiteral("cpu/system/processors"), i18nc("@title Number of Processors", "Processors") }, | ||
391 | { QStringLiteral("cpu/system/cores"), i18n("Cores") }, | 391 | { QStringLiteral("cpu/system/cores"), i18nc("@title Number of Cores", "Cores") }, | ||
392 | }; | 392 | }; | ||
393 | 393 | | |||
394 | return shortNames.value(key, QString {}); | 394 | return shortNames.value(key, QString {}); | ||
395 | } | 395 | } | ||
396 | 396 | | |||
397 | K_PLUGIN_FACTORY(KSGRDPluginFactory, registerPlugin<KSGRDIface>();) | 397 | K_PLUGIN_FACTORY(KSGRDPluginFactory, registerPlugin<KSGRDIface>();) | ||
398 | 398 | | |||
399 | #include "ksgrdiface.moc" | 399 | #include "ksgrdiface.moc" |