MCPcopy Create free account
hub / github.com/amakaseev/sprite-sheet-packer / openSpritePackerProject

Method openSpritePackerProject

SpriteSheetPacker/MainWindow.cpp:319–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319void MainWindow::openSpritePackerProject(const QString& fileName) {
320 QSettings settings;
321 settings.setValue("spritePackerFileName", fileName);
322
323 std::string suffix = QFileInfo(fileName).suffix().toStdString();
324 SpritePackerProjectFile* projectFile = SpritePackerProjectFile::factory().get(suffix)();
325 if (projectFile) {
326 if (!projectFile->read(fileName)) {
327 QMessageBox::critical(this, "ERROR", "File format error.");
328 return;
329 }
330 } else {
331 QMessageBox::critical(this, "ERROR", "Unknown project file format!");
332
333 return;
334 }
335
336 _blockUISignals = true;
337 ui->algorithmComboBox->setCurrentText(projectFile->algorithm());
338 ui->trimModeComboBox->setCurrentText(projectFile->trimMode());
339 ui->trimSpinBox->setValue(projectFile->trimThreshold());
340 ui->epsilonHorizontalSlider->setValue(projectFile->epsilon() * 10);
341 ui->heuristicMaskCheckBox->setChecked(projectFile->heuristicMask());
342 ui->textureBorderSpinBox->setValue(projectFile->textureBorder());
343 ui->spriteBorderSpinBox->setValue(projectFile->spriteBorder());
344 ui->dataFormatComboBox->setCurrentText(projectFile->dataFormat());
345 ui->destPathLineEdit->setText(projectFile->destPath());
346 ui->spriteSheetLineEdit->setText(projectFile->spriteSheetName());
347 ui->imageFormatComboBox->setCurrentText(imageFormatToString(projectFile->imageFormat()));
348 ui->pixelFormatComboBox->setCurrentText(pixelFormatToString(projectFile->pixelFormat()));
349 ui->premultipliedCheckBox->setChecked(projectFile->premultiplied());
350 ui->pngOptModeComboBox->setCurrentText(projectFile->pngOptMode());
351 ui->pngOptLevelSlider->setValue(projectFile->pngOptLevel());
352 ui->webpQualitySlider->setValue(projectFile->webpQuality());
353 ui->jpgQualitySlider->setValue(projectFile->jpgQuality());
354
355 ui->trimSpriteNamesCheckBox->setChecked(projectFile->trimSpriteNames());
356 ui->prependSmartFolderNameCheckBox->setChecked(projectFile->prependSmartFolderName());
357
358 _encryptionKey = projectFile->encryptionKey();
359 ui->contentProtectionToolButton->setChecked(!_encryptionKey.isEmpty());
360
361 while(ui->scalingVariantsGroupBox->layout()->count() > 0){
362 QLayoutItem *item = ui->scalingVariantsGroupBox->layout()->takeAt(0);
363 delete item->widget();
364 delete item;
365 }
366 for (auto scalingVariant: projectFile->scalingVariants()) {
367 ScalingVariantWidget* scalingVariantWidget = new ScalingVariantWidget(this,
368 scalingVariant.name,
369 scalingVariant.scale,
370 scalingVariant.maxTextureSize,
371 scalingVariant.pow2,
372 scalingVariant.forceSquared);
373 connect(scalingVariantWidget, SIGNAL(remove()), this, SLOT(onRemoveScalingVariant()));
374 connect(scalingVariantWidget, SIGNAL(valueChanged(bool)), this, SLOT(onScalingVariantWidgetValueChanged(bool)));
375 ui->scalingVariantsGroupBox->layout()->addWidget(scalingVariantWidget);
376

Callers 2

openRecentMethod · 0.80

Calls 15

imageFormatToStringFunction · 0.85
pixelFormatToStringFunction · 0.85
getMethod · 0.80
readMethod · 0.80
trimModeMethod · 0.80
trimThresholdMethod · 0.80
epsilonMethod · 0.80
heuristicMaskMethod · 0.80
textureBorderMethod · 0.80
spriteBorderMethod · 0.80
imageFormatMethod · 0.80
pixelFormatMethod · 0.80

Tested by

no test coverage detected