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; }
QDBusObjectPath JobViewServer::requestView(const QString &appName, const QString &appIconName, int capabilities) { QString objectPath = QString("/JobViewServer/JobView_%1").arg(++lastID); JobView* jobview = new JobView(objectPath, appName, appIconName, capabilities); Plasma::Meter* meter = new Plasma::Meter(); meter->setMeterType(Plasma::Meter::BarMeterHorizontal); meter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); activeMeters.insert(jobview->objectPath(), meter); activeJobViews.insert(jobview->objectPath(), jobview); meterLayout->addItem(meter); jobViewLayout->addItem(jobview); connect(jobview, SIGNAL(progressChanged(uint)), this, SLOT(updateMeter(uint))); connect(jobview, SIGNAL(terminated()), this, SLOT(jobViewTerminated())); updateStatusIndicators(); return QDBusObjectPath(objectPath); }