Manager: Render details section only once it's fully populated with data

This commit is contained in:
RichardG867
2025-08-20 17:17:06 -03:00
parent eb56961f10
commit c836f6e103
3 changed files with 48 additions and 39 deletions

View File

@@ -281,6 +281,15 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) {
otherSection->addSection(tr("ISA RTC"), passed_sysconfig->getDisplayValue(Display::Name::IsaRtc));
otherSection->addSection(tr("ISA RAM"), passed_sysconfig->getDisplayValue(Display::Name::IsaMem));
otherSection->addSection(tr("ISA ROM"), passed_sysconfig->getDisplayValue(Display::Name::IsaRom));
systemSection->setSections();
videoSection->setSections();
storageSection->setSections();
audioSection->setSections();
networkSection->setSections();
inputSection->setSections();
portsSection->setSections();
otherSection->setSections();
}
void

View File

@@ -143,7 +143,6 @@ VMManagerDetailSection::addSection(const QString &name, const QString &value, Di
{
const auto new_section = DetailSection { name, value};
sections.push_back(new_section);
setSections();
}
void
@@ -154,30 +153,8 @@ VMManagerDetailSection::setupMainLayout()
mainLayout = new QVBoxLayout;
}
void
VMManagerDetailSection::clearContentsSetupGrid()
{
// Clear everything out
if(frameGridLayout) {
while(frameGridLayout->count()) {
QLayoutItem * cur_item = frameGridLayout->takeAt(0);
if(cur_item->widget())
delete cur_item->widget();
delete cur_item;
}
}
delete frameGridLayout;
frameGridLayout = new QGridLayout();
qint32 *left = nullptr, *top = nullptr, *right = nullptr, *bottom = nullptr;
frameGridLayout->getContentsMargins(left, top, right, bottom);
frameGridLayout->setContentsMargins(getMargins(MarginSection::DisplayGrid));
ui->detailFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
ui->detailFrame->setLayout(frameGridLayout);
}
void
VMManagerDetailSection::setSections()
{
clearContentsSetupGrid();
int row = 0;
@@ -191,6 +168,19 @@ VMManagerDetailSection::setSections()
sectionsToAdd.push_back(section.value);
}
bool keyAdded = false;
// Reduce the text size for the label
// First, get the existing font
auto reference_label = new QLabel();
auto smaller_font = reference_label->font();
// Get a smaller size
// Not sure if I like the smaller size, back to regular for now
// auto smaller_size = 0.85 * smaller_font.pointSize();
const auto smaller_size = 1 * smaller_font.pointSize();
// Set the font to the smaller size
smaller_font.setPointSizeF(smaller_size);
delete reference_label;
for(const auto&line : sectionsToAdd) {
if(line.isEmpty()) {
// Don't bother adding entries if the values are blank
@@ -203,15 +193,6 @@ VMManagerDetailSection::setSections()
labelValue->setTextInteractionFlags(labelValue->textInteractionFlags() | Qt::TextSelectableByMouse);
labelKey->setTextInteractionFlags(labelValue->textInteractionFlags() | Qt::TextSelectableByMouse);
// Reduce the text size for the label
// First, get the existing font
auto smaller_font = labelValue->font();
// Get a smaller size
// Not sure if I like the smaller size, back to regular for now
// auto smaller_size = 0.85 * smaller_font.pointSize();
const auto smaller_size = 1 * smaller_font.pointSize();
// Set the font to the smaller size
smaller_font.setPointSizeF(smaller_size);
// Assign that new, smaller font to the label
labelKey->setFont(smaller_font);
labelValue->setFont(smaller_font);
@@ -237,6 +218,24 @@ VMManagerDetailSection::clear()
{
sections.clear();
setVisible(false);
// Clear everything out
if(frameGridLayout) {
while(frameGridLayout->count()) {
QLayoutItem * cur_item = frameGridLayout->takeAt(0);
if(cur_item->widget())
delete cur_item->widget();
delete cur_item;
}
}
delete frameGridLayout;
frameGridLayout = new QGridLayout();
qint32 *left = nullptr, *top = nullptr, *right = nullptr, *bottom = nullptr;
frameGridLayout->getContentsMargins(left, top, right, bottom);
frameGridLayout->setContentsMargins(getMargins(MarginSection::DisplayGrid));
ui->detailFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
ui->detailFrame->setLayout(frameGridLayout);
}
// QT for Linux and Windows doesn't have the same default margins as QT on MacOS.
@@ -284,7 +283,7 @@ void CollapseButton::setButtonText(const QString &text) {
void CollapseButton::setContent(QWidget *content) {
assert(content != nullptr);
content_ = content;
const auto animation_ = new QPropertyAnimation(content_, "maximumHeight"); // QObject with auto delete
/*const auto animation_ = new QPropertyAnimation(content_, "maximumHeight"); // QObject with auto delete
animation_->setStartValue(0);
animation_->setEasingCurve(QEasingCurve::InOutQuad);
animation_->setDuration(300);
@@ -294,16 +293,16 @@ void CollapseButton::setContent(QWidget *content) {
animator_.addAnimation(animation_);
if (!isChecked()) {
content->setMaximumHeight(0);
}
}*/
}
void CollapseButton::hideContent() {
animator_.setDirection(QAbstractAnimation::Backward);
animator_.start();
/*animator_.setDirection(QAbstractAnimation::Backward);
animator_.start();*/
}
void CollapseButton::showContent() {
animator_.setDirection(QAbstractAnimation::Forward);
animator_.start();
/*animator_.setDirection(QAbstractAnimation::Forward);
animator_.start();*/
}

View File

@@ -61,8 +61,10 @@ public:
~VMManagerDetailSection() override;
void addSection(const QString &name, const QString &value, VMManager::Display::Name displayField = VMManager::Display::Name::Unknown);
void setSections();
void clear();
QLabel *tableLabel;
CollapseButton *collapseButton;
// QGridLayout *buttonGridLayout;
QGridLayout *frameGridLayout;
@@ -82,7 +84,6 @@ private:
void setSectionName(const QString &name);
void setupMainLayout();
void clearContentsSetupGrid();
void setSections();
static QMargins getMargins(MarginSection section);