diff --git a/src/widgets/dashboard.cpp b/src/widgets/dashboard.cpp index fdc04684..4364054d 100644 --- a/src/widgets/dashboard.cpp +++ b/src/widgets/dashboard.cpp @@ -9,6 +9,7 @@ #include #include #include +#include Dashboard::Dashboard(MainWindow *main, QWidget *parent) : @@ -40,7 +41,6 @@ void Dashboard::refresh() void Dashboard::updateContents() { - // Parse and add JSON file info QString info = this->main->core->getFileInfo(); @@ -150,11 +150,28 @@ void Dashboard::updateContents() QString libs = this->main->core->cmd("il"); QStringList lines = libs.split("\n", QString::SkipEmptyParts); - if (! lines.isEmpty()) + if (!lines.isEmpty()) { lines.removeFirst(); lines.removeLast(); } + + // dunno: why not label->setText(lines.join("\n")? + while (ui->verticalLayout_2->count() > 0) + { + QLayoutItem *item = ui->verticalLayout_2->takeAt(0); + if (item != nullptr) + { + QWidget *w = item->widget(); + if (w != nullptr) + { + w->deleteLater(); + } + + delete item; + } + } + foreach (QString lib, lines) { QLabel *label = new QLabel(this); @@ -162,6 +179,10 @@ void Dashboard::updateContents() label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); ui->verticalLayout_2->addWidget(label); } + + + + QSpacerItem *spacer = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding); ui->verticalLayout_2->addSpacerItem(spacer); @@ -198,4 +219,3 @@ void Dashboard::updateContents() code2.replace("WOEM", data); ui->polarWebView->setHtml(code2); } -