mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-13 16:18:30 +00:00
Clear layout before adding more widgets
This commit is contained in:
parent
ab28142ec5
commit
06e82c8421
@ -9,6 +9,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QFile>
|
||||
#include <QLayoutItem>
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user