MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / updateCalculations

Method updateCalculations

launcher/ui/pages/instance/StoragePage.cpp:127–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void StoragePage::updateCalculations()
128{
129 auto size_resource_packs =
130 getDirectorySize((m_inst->gameRoot() + "/texturepacks")) + getDirectorySize((m_inst->gameRoot() + "/resourcepacks"));
131 auto size_mods = getDirectorySize(m_inst->modsRoot());
132 auto size_saves = getDirectorySize((m_inst->gameRoot() + "/saves"));
133 auto size_screenshots = getDirectorySize((m_inst->gameRoot() + "/screenshots"));
134 auto size_logs = getDirectorySize((m_inst->gameRoot() + "/logs"));
135
136 auto storage_info = QStorageInfo(QDir(m_inst->gameRoot()));
137 auto size_remaining = storage_info.bytesAvailable();
138 auto size_used = storage_info.bytesTotal() - size_remaining;
139
140 auto locale = this->locale();
141 ui->label_resource_packs->setText(locale.formattedDataSize(size_resource_packs));
142 ui->label_mods->setText(locale.formattedDataSize(size_mods));
143 ui->label_saves->setText(locale.formattedDataSize(size_saves));
144 ui->label_screenshots->setText(locale.formattedDataSize(size_screenshots));
145 ui->label_logs->setText(locale.formattedDataSize(size_logs));
146 ui->label_combined->setText(locale.formattedDataSize(size_resource_packs + size_mods + size_saves + size_screenshots + size_logs));
147
148 ui->label_used->setText(locale.formattedDataSize(size_used));
149 ui->label_remaining->setText(locale.formattedDataSize(size_remaining));
150
151 m_series->clear();
152 m_series->append("Resource packs", size_resource_packs);
153 m_series->append("Mods", size_mods);
154 m_series->append("Saves", size_saves);
155 m_series->append("Screenshots", size_screenshots);
156 m_series->append("Logs", size_logs);
157
158 m_chart_view->setChart(m_chart);
159 for (auto slice : m_series->slices())
160 slice->setLabel(slice->label() + " " + QString("%1%").arg(100 * slice->percentage(), 0, 'f', 1));
161}
162
163bool StoragePage::eventFilter(QObject *object, QEvent *event)
164{

Callers

nothing calls this directly

Calls 8

getDirectorySizeFunction · 0.85
QStringClass · 0.85
appendMethod · 0.80
QDirClass · 0.50
gameRootMethod · 0.45
modsRootMethod · 0.45
setTextMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected