mirror of
https://github.com/leozide/leocad.git
synced 2026-07-28 04:07:11 +00:00
Reorganize Save Image dialog.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "lc_htmldialog.h"
|
||||
#include "lc_renderdialog.h"
|
||||
#include "lc_instructionsdialog.h"
|
||||
#include "lc_qimagedialog.h"
|
||||
#include "lc_profile.h"
|
||||
#include "lc_view.h"
|
||||
#include "project.h"
|
||||
@@ -1360,6 +1361,29 @@ void lcMainWindow::ShowPrintDialog()
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcMainWindow::ShowImageDialog()
|
||||
{
|
||||
lcImageDialogOptions Options;
|
||||
Project* Project = lcGetActiveProject();
|
||||
lcModel* Model = Project->GetActiveModel();
|
||||
|
||||
Options.Width = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
|
||||
Options.Height = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT);
|
||||
Options.Start = Model->GetCurrentStep();
|
||||
Options.End = Model->GetLastStep();
|
||||
Options.FilePath = Project->GetImageFileName(false);
|
||||
|
||||
lcImageDialog Dialog(this, &Options);
|
||||
|
||||
if (Dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
lcSetProfileInt(LC_PROFILE_IMAGE_WIDTH, Options.Width);
|
||||
lcSetProfileInt(LC_PROFILE_IMAGE_HEIGHT, Options.Height);
|
||||
|
||||
lcGetActiveProject()->SaveImage(Options);
|
||||
}
|
||||
|
||||
void lcMainWindow::SetShadingMode(lcShadingMode ShadingMode)
|
||||
{
|
||||
lcGetPreferences().mShadingMode = ShadingMode;
|
||||
@@ -2639,7 +2663,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||
break;
|
||||
|
||||
case LC_FILE_SAVE_IMAGE:
|
||||
lcGetActiveProject()->SaveImage();
|
||||
ShowImageDialog();
|
||||
break;
|
||||
|
||||
case LC_FILE_IMPORT_LDD:
|
||||
|
||||
@@ -328,6 +328,7 @@ protected:
|
||||
void ShowRenderDialog(lcRenderDialogMode RenderDialogMode);
|
||||
void ShowInstructionsDialog();
|
||||
void ShowPrintDialog();
|
||||
void ShowImageDialog();
|
||||
void CreatePreviewWidget();
|
||||
|
||||
bool OpenProjectFile(const QString& FileName);
|
||||
|
||||
+7
-12
@@ -14,7 +14,6 @@
|
||||
#include "lc_profile.h"
|
||||
#include "lc_file.h"
|
||||
#include "lc_zipfile.h"
|
||||
#include "lc_qimagedialog.h"
|
||||
#include "lc_modellistdialog.h"
|
||||
#include "lc_bricklink.h"
|
||||
#include "lc_string.h"
|
||||
@@ -2601,22 +2600,18 @@ bool Project::ExportWavefront(const QString& FileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::SaveImage()
|
||||
void Project::SaveImage(const lcImageDialogOptions& Options)
|
||||
{
|
||||
lcImageDialog Dialog(gMainWindow);
|
||||
|
||||
if (Dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QString Extension = QFileInfo(Dialog.mFileName).suffix();
|
||||
QString FilePath = Options.FilePath;
|
||||
QString Extension = QFileInfo(FilePath).suffix();
|
||||
|
||||
if (!Extension.isEmpty())
|
||||
lcSetProfileString(LC_PROFILE_IMAGE_EXTENSION, Dialog.mFileName.right(Extension.length() + 1));
|
||||
lcSetProfileString(LC_PROFILE_IMAGE_EXTENSION, FilePath.right(Extension.length() + 1));
|
||||
|
||||
if (Dialog.mStart != Dialog.mEnd)
|
||||
Dialog.mFileName = Dialog.mFileName.insert(Dialog.mFileName.length() - Extension.length() - 1, QLatin1String("%1"));
|
||||
if (Options.Start != Options.End)
|
||||
FilePath = FilePath.insert(FilePath.length() - Extension.length() - 1, QLatin1String("%1"));
|
||||
|
||||
mActiveModel->SaveStepImages(Dialog.mFileName, Dialog.mStart != Dialog.mEnd, false, Dialog.mWidth, Dialog.mHeight, Dialog.mStart, Dialog.mEnd);
|
||||
mActiveModel->SaveStepImages(FilePath, Options.Start != Options.End, false, Options.Width, Options.Height, Options.Start, Options.End);
|
||||
}
|
||||
|
||||
void Project::UpdatePieceInfo(PieceInfo* Info) const
|
||||
|
||||
+10
-1
@@ -27,6 +27,15 @@ public:
|
||||
bool PartsListEnd;
|
||||
};
|
||||
|
||||
struct lcImageDialogOptions
|
||||
{
|
||||
QString FilePath;
|
||||
int Width;
|
||||
int Height;
|
||||
int Start;
|
||||
int End;
|
||||
};
|
||||
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
@@ -83,7 +92,7 @@ public:
|
||||
bool ImportLDD(const QString& FileName);
|
||||
bool ImportInventory(const QByteArray& Inventory, const QString& Name, const QString& Description);
|
||||
|
||||
void SaveImage();
|
||||
void SaveImage(const lcImageDialogOptions& Options);
|
||||
bool ExportCurrentStep(const QString& FileName);
|
||||
bool ExportModel(const QString& FileName, lcModel* Model) const;
|
||||
bool Export3DStudio(const QString& FileName);
|
||||
|
||||
Reference in New Issue
Block a user