Manager: Refactor the machine process stats system
and the statusbar text generation
This commit is contained in:
@@ -369,7 +369,7 @@ illegal_chars:
|
||||
|
||||
// Set initial status bar after the event loop starts
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
emit updateStatusRight(totalCountString());
|
||||
emit updateStatusRight(machineCountString());
|
||||
});
|
||||
|
||||
#if EMU_BUILD_NUM != 0
|
||||
@@ -698,10 +698,14 @@ VMManagerMain::getSearchCompletionList() const
|
||||
}
|
||||
|
||||
QString
|
||||
VMManagerMain::totalCountString() const
|
||||
VMManagerMain::machineCountString(QString states) const
|
||||
{
|
||||
const auto count = vm_model->rowCount(QModelIndex());
|
||||
return QString("%1 %2").arg(QString::number(count), tr("total"));
|
||||
if (!states.isEmpty())
|
||||
states.append(", ");
|
||||
states.append(tr("%1 total").arg(count));
|
||||
|
||||
return tr("VMs: %1").arg(states);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -713,14 +717,26 @@ VMManagerMain::modelDataChange()
|
||||
QStringList stats;
|
||||
for (auto it = modelStats.constBegin(); it != modelStats.constEnd(); ++it) {
|
||||
const auto &key = it.key();
|
||||
stats.append(QString("%1 %2").arg(QString::number(modelStats[key]), key));
|
||||
QString text = "";
|
||||
switch (key) {
|
||||
case VMManagerSystem::ProcessStatus::Running:
|
||||
text = tr("%n running", "", modelStats[key]);
|
||||
break;
|
||||
case VMManagerSystem::ProcessStatus::Paused:
|
||||
text = tr("%n paused", "", modelStats[key]);
|
||||
break;
|
||||
case VMManagerSystem::ProcessStatus::PausedWaiting:
|
||||
case VMManagerSystem::ProcessStatus::RunningWaiting:
|
||||
text = tr("%n waiting", "", modelStats[key]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!text.isEmpty())
|
||||
stats.append(text);
|
||||
}
|
||||
auto states = stats.join(", ");
|
||||
if (!modelStats.isEmpty()) {
|
||||
states.append(", ");
|
||||
}
|
||||
|
||||
emit updateStatusRight(states + totalCountString());
|
||||
emit updateStatusRight(machineCountString(states));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user