mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Save images to the documents folder if a folder is not specified. Fixes #224.
This commit is contained in:
parent
bf59b42e0a
commit
aaa33d55e5
5 changed files with 21 additions and 8 deletions
|
@ -439,7 +439,7 @@ bool lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPaths, bool&
|
|||
if (SaveImage)
|
||||
{
|
||||
if (ImageName.isEmpty())
|
||||
ImageName = mProject->GetImageFileName();
|
||||
ImageName = mProject->GetImageFileName(true);
|
||||
|
||||
if (ImageEnd < ImageStart)
|
||||
ImageEnd = ImageStart;
|
||||
|
|
|
@ -121,9 +121,9 @@ QString Project::GetTitle() const
|
|||
return mModels.GetSize() == 1 ? tr("New Model.ldr") : tr("New Model.mpd");
|
||||
}
|
||||
|
||||
QString Project::GetImageFileName() const
|
||||
QString Project::GetImageFileName(bool AllowCurrentFolder) const
|
||||
{
|
||||
QString FileName = QDir::toNativeSeparators(GetFileName());
|
||||
QString FileName = GetFileName();
|
||||
|
||||
if (!FileName.isEmpty())
|
||||
{
|
||||
|
@ -132,9 +132,22 @@ QString Project::GetImageFileName() const
|
|||
FileName = FileName.left(FileName.length() - Extension.length() - 1);
|
||||
}
|
||||
else
|
||||
FileName = QLatin1String("image");
|
||||
{
|
||||
if (!AllowCurrentFolder)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
QStringList cachePathList = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
|
||||
FileName = cachePathList.first();
|
||||
#else
|
||||
FileName = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
|
||||
#endif
|
||||
|
||||
return FileName + lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
|
||||
}
|
||||
|
||||
FileName += QLatin1String("image");
|
||||
}
|
||||
|
||||
return QDir::toNativeSeparators(FileName) + lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION);
|
||||
}
|
||||
|
||||
void Project::SetActiveModel(int ModelIndex)
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
return mFileName;
|
||||
}
|
||||
|
||||
QString GetImageFileName() const;
|
||||
QString GetImageFileName(bool AllowCurrentFolder) const;
|
||||
|
||||
void SetActiveModel(int ModelIndex);
|
||||
void SetActiveModel(const QString& ModelName);
|
||||
|
|
|
@ -22,7 +22,7 @@ lcQImageDialog::lcQImageDialog(QWidget* Parent)
|
|||
mHeight = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT);
|
||||
mStart = Model->GetCurrentStep();
|
||||
mEnd = Model->GetLastStep();
|
||||
mFileName = Project->GetImageFileName();
|
||||
mFileName = Project->GetImageFileName(false);
|
||||
|
||||
ui->fileName->setText(mFileName);
|
||||
ui->width->setText(QString::number(mWidth));
|
||||
|
|
|
@ -26,7 +26,7 @@ lcRenderDialog::lcRenderDialog(QWidget* Parent)
|
|||
ui->WidthEdit->setValidator(new QIntValidator(16, INT_MAX));
|
||||
ui->HeightEdit->setText(QString::number(lcGetProfileInt(LC_PROFILE_POVRAY_HEIGHT)));
|
||||
ui->HeightEdit->setValidator(new QIntValidator(16, INT_MAX));
|
||||
ui->OutputEdit->setText(lcGetActiveProject()->GetImageFileName());
|
||||
ui->OutputEdit->setText(lcGetActiveProject()->GetImageFileName(false));
|
||||
|
||||
QImage Image(LC_POVRAY_PREVIEW_WIDTH, LC_POVRAY_PREVIEW_HEIGHT, QImage::Format_RGB32);
|
||||
Image.fill(QColor(255, 255, 255));
|
||||
|
|
Loading…
Add table
Reference in a new issue