| 312 | } |
| 313 | |
| 314 | void MainFrame::updateRunning() |
| 315 | { |
| 316 | d->runningTable->clearContents(); |
| 317 | d->runningTable->setRowCount(0); |
| 318 | |
| 319 | d->process.reset(new QProcess(this)); |
| 320 | d->process->setProgram("ll-cli"); |
| 321 | QStringList args; |
| 322 | args.append("ps"); |
| 323 | args.append("--json"); |
| 324 | d->process->setArguments(args); |
| 325 | |
| 326 | connect(d->process.get(), &QProcess::readyRead, this, [=]() { |
| 327 | auto data = d->process->readAll(); |
| 328 | |
| 329 | QJsonParseError error; |
| 330 | QJsonDocument jsonDocument = QJsonDocument::fromJson(data, &error); |
| 331 | |
| 332 | if (error.error != QJsonParseError::NoError) { |
| 333 | qCritical() << "JSON parse error: " << error.errorString(); |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | QJsonArray arr = jsonDocument.array(); |
| 338 | int row = 0; |
| 339 | for (auto line : arr) { |
| 340 | d->runningTable->setRowCount(row + 1); |
| 341 | auto jsonObject = line.toObject(); |
| 342 | d->runningTable->setItem(row, 0, new QTableWidgetItem(jsonObject["package"].toString())); |
| 343 | d->runningTable->setItem(row, 1, new QTableWidgetItem(QString::number(jsonObject["pid"].toInt()))); |
| 344 | d->runningTable->setItem(row, 2, new QTableWidgetItem(jsonObject["path"].toString())); |
| 345 | d->runningTable->setItem(row, 3, new QTableWidgetItem(jsonObject["id"].toString())); |
| 346 | row++; |
| 347 | } |
| 348 | }); |
| 349 | |
| 350 | d->process->start(); |
| 351 | d->process->waitForFinished(); |
| 352 | } |
| 353 | |
| 354 | void MainFrame::runApp(const QString &appId) |
| 355 | { |
nothing calls this directly
no test coverage detected