add possibility to use layer name when save snapshot, fix #1358

This commit is contained in:
Alessandro Muntoni 2023-11-22 11:31:54 +01:00
parent 32d84cd97f
commit 5bb42ba642
5 changed files with 67 additions and 8 deletions

View File

@ -44,6 +44,7 @@ void SaveSnapshotDialog::setValues(const SnapshotSetting& ss)
ui->counterSpinBox->setValue(settings.counter);
ui->backgroundComboBox->setCurrentIndex(settings.background);
ui->alllayersCheckBox->setChecked(settings.snapAllLayers);
ui->useLayerNameCheckBox->setChecked(settings.useLayerName);
ui->tiledSaveCheckBox->setChecked(settings.tiledSave);
ui->addToRastersCheckBox->setChecked(settings.addToRasters);
}
@ -56,6 +57,7 @@ SnapshotSetting SaveSnapshotDialog::getValues()
settings.resolution=ui->resolutionSpinBox->value();
settings.background = ui->backgroundComboBox->currentIndex();
settings.snapAllLayers=ui->alllayersCheckBox->isChecked();
settings.useLayerName=ui->useLayerNameCheckBox->isChecked();
settings.tiledSave=ui->tiledSaveCheckBox->isChecked();
settings.addToRasters=ui->addToRastersCheckBox->isChecked();
return settings;
@ -80,3 +82,23 @@ void SaveSnapshotDialog::on_browseDir_clicked()
ui->outDirLineEdit->setText(selection.at(0));
}
}
void SaveSnapshotDialog::on_alllayersCheckBox_stateChanged(int arg1)
{
if (arg1 == Qt::Checked)
ui->useLayerNameCheckBox->setEnabled(true);
else {
ui->useLayerNameCheckBox->setEnabled(false);
ui->useLayerNameCheckBox->setChecked(false);
}
}
void SaveSnapshotDialog::on_useLayerNameCheckBox_stateChanged(int arg1)
{
if (arg1 == Qt::Checked)
ui->baseNameLineEdit->setEnabled(false);
else
ui->baseNameLineEdit->setEnabled(true);
}

View File

@ -45,6 +45,10 @@ public:
private slots:
void on_browseDir_clicked();
void on_alllayersCheckBox_stateChanged(int arg1);
void on_useLayerNameCheckBox_stateChanged(int arg1);
private:
Ui::SaveSnapShotDialog* ui;
SnapshotSetting settings;

View File

@ -120,10 +120,38 @@
</spacer>
</item>
<item>
<widget class="QCheckBox" name="alllayersCheckBox">
<property name="text">
<string>Snap All Layers</string>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="alllayersCheckBox">
<property name="text">
<string>Snap All Layers</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useLayerNameCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use Layer Name</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>

View File

@ -219,11 +219,14 @@ void GLArea::pasteTile()
if (tileRow >= totalRows) {
if (ss.snapAllLayers) {
outfile = QString("%1/%2%3_L%4.png")
QString lname = ss.basename;
if (ss.useLayerName) {
lname = md()->getMesh(snapshotCounter)->label();
}
outfile = QString("%1/%2%3.png")
.arg(ss.outdir)
.arg(ss.basename)
.arg(ss.counter, 2, 10, QChar('0'))
.arg(snapshotCounter, 2, 10, QChar('0'));
.arg(lname)
.arg(ss.counter, 2, 10, QChar('0'));
}
else {
outfile = QString("%1/%2%3.png")

View File

@ -33,6 +33,7 @@ public:
int resolution;
int background;
bool snapAllLayers;
bool useLayerName;
bool tiledSave; // if true all the tiles are saved as separated files and not joined.
bool addToRasters;
@ -44,9 +45,10 @@ public:
resolution=1;
background=0;
snapAllLayers=false;
useLayerName=false;
tiledSave=false;
addToRasters=false;
};
};
#endif
#endif