MCPcopy Create free account
hub / github.com/Cubitect/cubiomes-viewer / onUpdateConfig

Method onUpdateConfig

src/mainwindow.cpp:1166–1246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1164}
1165
1166void MainWindow::onUpdateConfig()
1167{
1168 Config old = config;
1169 config.load();
1170
1171 if (old.lang != config.lang)
1172 {
1173 info(this, tr("The application will need to be restarted before all changes can take effect."));
1174 }
1175
1176 QFont fnorm_old = ui->labelMC->font();
1177 QFont fmono_old = ui->labelMono->font();
1178 QFont fnorm = config.fontNorm;
1179 QFont fmono = config.fontMono;
1180 if (fnorm.family() == "Monospace") // avoid identification conflict
1181 fnorm = QApplication::font();
1182 fnorm.setStyleHint(QFont::AnyStyle);
1183 fmono.setStyleHint(QFont::Monospace);
1184 fmono.setFixedPitch(true);
1185
1186 bool font_changed = fnorm_old != fnorm || fmono_old != fmono;
1187
1188 QFontMetrics fm_ref(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
1189 QFontMetrics fm_new(fnorm);
1190
1191 g_fontscale = fm_new.height() / (qreal) fm_ref.height();
1192 g_iconscale = config.iconScale;
1193
1194 getMapView()->setConfig(config);
1195
1196 if ((old.uistyle != config.uistyle) || (old.iconScale != config.iconScale) || font_changed)
1197 {
1198 onStyleChanged(config.uistyle);
1199 int s = (int) round(g_iconscale * 20);
1200 ui->toolBar->setIconSize(QSize(s, s));
1201 }
1202 if (!old.biomeColorPath.isEmpty() || !config.biomeColorPath.isEmpty())
1203 {
1204 onBiomeColorChange();
1205 }
1206
1207 if (font_changed)
1208 {
1209 QFont fnormb = fnorm;
1210 QFont fmonob = fmono;
1211 fnormb.setBold(true);
1212 fmonob.setBold(true);
1213
1214 QApplication::setFont(fnorm);
1215
1216 QWidgetList wlist = QApplication::allWidgets();
1217 for (QWidget *w : qAsConst(wlist))
1218 {
1219 const QFont& f = w->font();
1220 if (f.styleHint() == QFont::Monospace || f.family() == "Monospace")
1221 w->setFont(f.bold() ? fmonob : fmono);
1222 else
1223 w->setFont(f.bold() ? fnormb : fnorm);

Callers

nothing calls this directly

Calls 4

infoFunction · 0.85
loadMethod · 0.45
setConfigMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected