diff --git a/src/qt/qt_vmmanager_detailsection.cpp b/src/qt/qt_vmmanager_detailsection.cpp index 907b5ab94..043342f1e 100644 --- a/src/qt/qt_vmmanager_detailsection.cpp +++ b/src/qt/qt_vmmanager_detailsection.cpp @@ -157,58 +157,36 @@ VMManagerDetailSection::setSections() { int row = 0; + for (const auto& section : sections) { + QStringList sectionsToAdd = section.value.split(sectionSeparator); + QLabel *labelKey = nullptr; - for ( const auto& section : sections) { - // if the string contains the separator (defined elsewhere) then split and - // add each entry on a new line. Otherwise, just add the one. - QStringList sectionsToAdd; - if(section.value.contains(sectionSeparator)) { - sectionsToAdd = section.value.split(sectionSeparator); - } else { - 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()) { + for (const auto& line : sectionsToAdd) { + if (line.isEmpty()) { // Don't bother adding entries if the values are blank continue; } - const auto labelKey = new QLabel(); - labelKey->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + const auto labelValue = new QLabel(); - labelKey->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); + labelValue->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); labelValue->setTextInteractionFlags(labelValue->textInteractionFlags() | Qt::TextSelectableByMouse); - labelKey->setTextInteractionFlags(labelValue->textInteractionFlags() | Qt::TextSelectableByMouse); - - // Assign that new, smaller font to the label - labelKey->setFont(smaller_font); - labelValue->setFont(smaller_font); - - labelKey->setText(QCoreApplication::translate("", QString(section.name + ":").toUtf8().data())); labelValue->setText(line); - if(!keyAdded) { - frameGridLayout->addWidget(labelKey, row, 0, Qt::AlignLeft); - keyAdded = true; - } frameGridLayout->addWidget(labelValue, row, 1, Qt::AlignLeft); + + if (!labelKey) { + labelKey = new QLabel(); + labelKey->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + labelKey->setTextInteractionFlags(labelValue->textInteractionFlags()); + labelKey->setText(QCoreApplication::translate("", QString(section.name + ":").toUtf8().data())); + frameGridLayout->addWidget(labelKey, row, 0, Qt::AlignLeft); + } + const auto hSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); frameGridLayout->addItem(hSpacer, row, 2); row++; } } + collapseButton->setContent(ui->detailFrame); if (sections.size()) setVisible(true); @@ -231,8 +209,6 @@ VMManagerDetailSection::clear() 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); @@ -283,7 +259,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); @@ -293,16 +269,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(); }