mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
Merge pull request #6635 from Cacodemon345/manager-fixes-speed
Improve slow loading speeds for manager
This commit is contained in:
@@ -392,6 +392,7 @@ extern const char * machine_getname_ex(int m);
|
||||
extern const char * machine_get_internal_name(void);
|
||||
extern const char * machine_get_nvr_name(void);
|
||||
extern int machine_get_machine_from_internal_name(const char *s);
|
||||
extern int machine_get_machine_from_internal_name_ex(const char *s); /* returns -1 if internal name does not exist. */
|
||||
extern void machine_init(void);
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t *machine_get_kbc_device(int m);
|
||||
|
||||
@@ -20709,6 +20709,21 @@ machine_get_machine_from_internal_name(const char *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
machine_get_machine_from_internal_name_ex(const char *s)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
while (machines[c].init != NULL) {
|
||||
if (!strcmp(machines[c].internal_name, s))
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
machine_has_mouse(void)
|
||||
{
|
||||
|
||||
@@ -263,8 +263,6 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig)
|
||||
// * First you clear it with VMManagerDetailSection::clear()
|
||||
// * Then you add each line with VMManagerDetailSection::addSection()
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
// System
|
||||
systemSection->clear();
|
||||
systemSection->addSection("Machine", passed_sysconfig->getDisplayValue(VMManager::Display::Name::Machine));
|
||||
@@ -322,8 +320,6 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig)
|
||||
inputSection->setSections();
|
||||
portsSection->setSections();
|
||||
otherSection->setSections();
|
||||
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -39,10 +39,6 @@ VMManagerDetailSection::
|
||||
ui->setupUi(this);
|
||||
|
||||
frameGridLayout = new QGridLayout();
|
||||
frameGridLayout->setContentsMargins(getMargins(MarginSection::DisplayGrid));
|
||||
ui->detailFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
ui->detailFrame->setLayout(frameGridLayout);
|
||||
|
||||
// Create the collapse button, set the name and add it to the layout
|
||||
collapseButton = new CollapseButton();
|
||||
setSectionName(sectionName);
|
||||
@@ -132,8 +128,6 @@ VMManagerDetailSection::
|
||||
innerFrameLayout->addWidget(buttonWidget);
|
||||
innerFrameLayout->addWidget(frame);
|
||||
setLayout(outerFrameLayout);
|
||||
|
||||
usedRows = 0;
|
||||
}
|
||||
|
||||
VMManagerDetailSection::~VMManagerDetailSection()
|
||||
@@ -162,7 +156,6 @@ VMManagerDetailSection::setupMainLayout()
|
||||
delete mainLayout;
|
||||
mainLayout = new QVBoxLayout;
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetailSection::setSections()
|
||||
{
|
||||
@@ -179,64 +172,52 @@ VMManagerDetailSection::setSections()
|
||||
continue;
|
||||
}
|
||||
|
||||
auto item = frameGridLayout->itemAtPosition(row, 1);
|
||||
QLabel *label;
|
||||
if (item) {
|
||||
label = (QLabel *) item->widget();
|
||||
label->setVisible(true);
|
||||
} else {
|
||||
label = new QLabel();
|
||||
label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
label->setTextInteractionFlags(label->textInteractionFlags() | Qt::TextSelectableByMouse);
|
||||
frameGridLayout->addWidget(label, row, 1, Qt::AlignLeft);
|
||||
}
|
||||
label->setText(line);
|
||||
const auto labelValue = new QLabel();
|
||||
labelValue->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
labelValue->setTextInteractionFlags(labelValue->textInteractionFlags() | Qt::TextSelectableByMouse);
|
||||
labelValue->setText(line);
|
||||
frameGridLayout->addWidget(labelValue, row, 1, Qt::AlignLeft);
|
||||
|
||||
item = frameGridLayout->itemAtPosition(row, 0);
|
||||
if (!labelKey) {
|
||||
if (item) {
|
||||
labelKey = (QLabel *) item->widget();
|
||||
labelKey->setVisible(true);
|
||||
} else {
|
||||
labelKey = new QLabel();
|
||||
labelKey->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
frameGridLayout->addWidget(labelKey, row, 0, Qt::AlignLeft);
|
||||
}
|
||||
labelKey = new QLabel();
|
||||
labelKey->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
labelKey->setTextInteractionFlags(labelValue->textInteractionFlags());
|
||||
labelKey->setText(QCoreApplication::translate("", QString(section.name + ":").toUtf8().data()));
|
||||
} else if (item) {
|
||||
item->widget()->setVisible(false);
|
||||
}
|
||||
|
||||
if (!frameGridLayout->itemAtPosition(row, 2)) {
|
||||
const auto hSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
frameGridLayout->addItem(hSpacer, row, 2);
|
||||
frameGridLayout->addWidget(labelKey, row, 0, Qt::AlignLeft);
|
||||
}
|
||||
|
||||
const auto hSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
frameGridLayout->addItem(hSpacer, row, 2);
|
||||
empty = false;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
int prevUsedRows = usedRows;
|
||||
usedRows = row;
|
||||
for (; row < prevUsedRows; row++) {
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
auto item = frameGridLayout->itemAtPosition(row, i);
|
||||
if (item)
|
||||
item->widget()->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
collapseButton->setContent(ui->detailFrame);
|
||||
if (!empty)
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void
|
||||
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();
|
||||
frameGridLayout->setContentsMargins(getMargins(MarginSection::DisplayGrid));
|
||||
ui->detailFrame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
ui->detailFrame->setLayout(frameGridLayout);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
@@ -91,7 +91,6 @@ private:
|
||||
static QMargins getMargins(MarginSection section);
|
||||
|
||||
QString sectionName;
|
||||
int usedRows;
|
||||
|
||||
struct DetailSection {
|
||||
QString name;
|
||||
|
||||
@@ -521,14 +521,11 @@ VMManagerSystem::setupVars()
|
||||
auto machine_name = QString();
|
||||
int i = 0;
|
||||
int ram_granularity = 0;
|
||||
int ci = machine_get_machine_from_internal_name_ex(machine_config["machine"].toUtf8());
|
||||
// Machine
|
||||
for (int ci = 0; ci < machine_count(); ++ci) {
|
||||
if (machine_available(ci)) {
|
||||
if (machines[ci].internal_name == machine_config["machine"]) {
|
||||
machine_name = machines[ci].name;
|
||||
ram_granularity = machines[ci].ram.step;
|
||||
}
|
||||
}
|
||||
if (ci != -1 && machine_available(ci)) {
|
||||
machine_name = machines[ci].name;
|
||||
ram_granularity = machines[ci].ram.step;
|
||||
}
|
||||
display_table[VMManager::Display::Name::Machine] = machine_name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user