Renamed user facing strings "project" -> "model" and "model" -> "submodel" to be consistent.

This commit is contained in:
Leonardo Zide 2017-12-10 15:01:12 -08:00
parent a339a62a97
commit 5f582f7fd1
7 changed files with 162 additions and 94 deletions

View file

@ -7,35 +7,35 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
{
QT_TRANSLATE_NOOP("Action", "File.New"),
QT_TRANSLATE_NOOP("Menu", "&New"),
QT_TRANSLATE_NOOP("Status", "Create a new project"),
QT_TRANSLATE_NOOP("Status", "Create a new model"),
QT_TRANSLATE_NOOP("Shortcut", "Ctrl+N")
},
// LC_FILE_OPEN
{
QT_TRANSLATE_NOOP("Action", "File.Open"),
QT_TRANSLATE_NOOP("Menu", "&Open..."),
QT_TRANSLATE_NOOP("Status", "Open an existing project"),
QT_TRANSLATE_NOOP("Status", "Open an existing model"),
QT_TRANSLATE_NOOP("Shortcut", "Ctrl+O")
},
// LC_FILE_MERGE
{
QT_TRANSLATE_NOOP("Action", "File.Merge"),
QT_TRANSLATE_NOOP("Menu", "&Merge..."),
QT_TRANSLATE_NOOP("Status", "Merge the contents of another project with the current one"),
QT_TRANSLATE_NOOP("Status", "Merge the contents of another file with the current one"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_SAVE
{
QT_TRANSLATE_NOOP("Action", "File.Save"),
QT_TRANSLATE_NOOP("Menu", "&Save"),
QT_TRANSLATE_NOOP("Status", "Save the active project"),
QT_TRANSLATE_NOOP("Status", "Save the current model"),
QT_TRANSLATE_NOOP("Shortcut", "Ctrl+S")
},
// LC_FILE_SAVEAS
{
QT_TRANSLATE_NOOP("Action", "File.SaveAs"),
QT_TRANSLATE_NOOP("Menu", "Save &As..."),
QT_TRANSLATE_NOOP("Status", "Save the active project with a new name"),
QT_TRANSLATE_NOOP("Status", "Save the current model with a new name"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_SAVE_IMAGE
@ -63,21 +63,21 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
{
QT_TRANSLATE_NOOP("Action", "File.Export.3DS"),
QT_TRANSLATE_NOOP("Menu", "3D &Studio..."),
QT_TRANSLATE_NOOP("Status", "Export the project in 3D Studio 3DS format"),
QT_TRANSLATE_NOOP("Status", "Export the current model in 3D Studio 3DS format"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_EXPORT_COLLADA
{
QT_TRANSLATE_NOOP("Action", "File.Export.COLLADA"),
QT_TRANSLATE_NOOP("Menu", "&COLLADA..."),
QT_TRANSLATE_NOOP("Status", "Export the project in COLLADA DAE format"),
QT_TRANSLATE_NOOP("Status", "Export the current model in COLLADA DAE format"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_EXPORT_HTML
{
QT_TRANSLATE_NOOP("Action", "File.Export.HTML"),
QT_TRANSLATE_NOOP("Menu", "&HTML..."),
QT_TRANSLATE_NOOP("Status", "Create an HTML page for this project"),
QT_TRANSLATE_NOOP("Status", "Create an HTML page for the current model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_EXPORT_BRICKLINK
@ -98,35 +98,35 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
{
QT_TRANSLATE_NOOP("Action", "File.Export.POVRay"),
QT_TRANSLATE_NOOP("Menu", "&POV-Ray..."),
QT_TRANSLATE_NOOP("Status", "Export the project in POV-Ray format"),
QT_TRANSLATE_NOOP("Status", "Export the current model in POV-Ray format"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_EXPORT_WAVEFRONT
{
QT_TRANSLATE_NOOP("Action", "File.Export.Wavefront"),
QT_TRANSLATE_NOOP("Menu", "&Wavefront..."),
QT_TRANSLATE_NOOP("Status", "Export the project in Wavefront OBJ format"),
QT_TRANSLATE_NOOP("Status", "Export the current model in Wavefront OBJ format"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_RENDER
{
QT_TRANSLATE_NOOP("Action", "File.Render"),
QT_TRANSLATE_NOOP("Menu", "&Render..."),
QT_TRANSLATE_NOOP("Status", "Render the project using POV-Ray"),
QT_TRANSLATE_NOOP("Status", "Render the current model using POV-Ray"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_PRINT
{
QT_TRANSLATE_NOOP("Action", "File.Print"),
QT_TRANSLATE_NOOP("Menu", "&Print..."),
QT_TRANSLATE_NOOP("Status", "Print the active project"),
QT_TRANSLATE_NOOP("Status", "Print the current model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_PRINT_PREVIEW
{
QT_TRANSLATE_NOOP("Action", "File.PrintPreview"),
QT_TRANSLATE_NOOP("Menu", "Print Pre&view..."),
QT_TRANSLATE_NOOP("Status", "Display how the project would look if printed"),
QT_TRANSLATE_NOOP("Status", "Display how the model would look if printed"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_PRINT_BOM
@ -140,35 +140,35 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
{
QT_TRANSLATE_NOOP("Action", "File.Recent1"),
QT_TRANSLATE_NOOP("Menu", "&Recent1"),
QT_TRANSLATE_NOOP("Status", "Open this document"),
QT_TRANSLATE_NOOP("Status", "Open this model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_RECENT2
{
QT_TRANSLATE_NOOP("Action", "File.Recent2"),
QT_TRANSLATE_NOOP("Menu", "&Recent2"),
QT_TRANSLATE_NOOP("Status", "Open this document"),
QT_TRANSLATE_NOOP("Status", "Open this model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_RECENT3
{
QT_TRANSLATE_NOOP("Action", "File.Recent3"),
QT_TRANSLATE_NOOP("Menu", "&Recent3"),
QT_TRANSLATE_NOOP("Status", "Open this document"),
QT_TRANSLATE_NOOP("Status", "Open this model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_RECENT4
{
QT_TRANSLATE_NOOP("Action", "File.Recent4"),
QT_TRANSLATE_NOOP("Menu", "&Recent4"),
QT_TRANSLATE_NOOP("Status", "Open this document"),
QT_TRANSLATE_NOOP("Status", "Open this model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_FILE_EXIT
{
QT_TRANSLATE_NOOP("Action", "File.Exit"),
QT_TRANSLATE_NOOP("Menu", "E&xit"),
QT_TRANSLATE_NOOP("Status", "Quit the application; prompts to save project"),
QT_TRANSLATE_NOOP("Status", "Quit the application; prompts to save model"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_EDIT_UNDO
@ -231,7 +231,7 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
{
QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"),
QT_TRANSLATE_NOOP("Menu", "Select &All"),
QT_TRANSLATE_NOOP("Status", "Select all pieces in the project"),
QT_TRANSLATE_NOOP("Status", "Select all pieces in the model"),
QT_TRANSLATE_NOOP("Shortcut", "Ctrl+A")
},
// LC_EDIT_SELECT_NONE
@ -1231,197 +1231,197 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
// LC_MODEL_NEW
{
QT_TRANSLATE_NOOP("Action", "Model.New"),
QT_TRANSLATE_NOOP("Menu", "New Model..."),
QT_TRANSLATE_NOOP("Status", "Add a new model to the project"),
QT_TRANSLATE_NOOP("Menu", "New Submodel..."),
QT_TRANSLATE_NOOP("Status", "Create a new submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_PROPERTIES
{
QT_TRANSLATE_NOOP("Action", "Model.Properties"),
QT_TRANSLATE_NOOP("Menu", "Prope&rties..."),
QT_TRANSLATE_NOOP("Status", "Display the properties of the current model"),
QT_TRANSLATE_NOOP("Status", "Display the properties of the current submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_EDIT_FOCUS
{
QT_TRANSLATE_NOOP("Action", "Model.SwitchToFocus"),
QT_TRANSLATE_NOOP("Menu", "Switch to Model"),
QT_TRANSLATE_NOOP("Status", "Switch to the model corresponding to the piece with focus"),
QT_TRANSLATE_NOOP("Menu", "Switch to Submodel"),
QT_TRANSLATE_NOOP("Status", "Switch to the submodel corresponding to the piece with focus"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_LIST
{
QT_TRANSLATE_NOOP("Action", "Model.List"),
QT_TRANSLATE_NOOP("Menu", "Models..."),
QT_TRANSLATE_NOOP("Status", "Show a list of all models in this project"),
QT_TRANSLATE_NOOP("Menu", "Submodels..."),
QT_TRANSLATE_NOOP("Status", "Show a list of all submodels"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_01
{
QT_TRANSLATE_NOOP("Action", "Model.Model01"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_02
{
QT_TRANSLATE_NOOP("Action", "Model.Model02"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_03
{
QT_TRANSLATE_NOOP("Action", "Model.Model03"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_04
{
QT_TRANSLATE_NOOP("Action", "Model.Model04"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_05
{
QT_TRANSLATE_NOOP("Action", "Model.Model05"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_06
{
QT_TRANSLATE_NOOP("Action", "Model.Model06"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_07
{
QT_TRANSLATE_NOOP("Action", "Model.Model07"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_08
{
QT_TRANSLATE_NOOP("Action", "Model.Model08"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_09
{
QT_TRANSLATE_NOOP("Action", "Model.Model09"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_10
{
QT_TRANSLATE_NOOP("Action", "Model.Model10"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_11
{
QT_TRANSLATE_NOOP("Action", "Model.Model11"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_12
{
QT_TRANSLATE_NOOP("Action", "Model.Model12"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_13
{
QT_TRANSLATE_NOOP("Action", "Model.Model13"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_14
{
QT_TRANSLATE_NOOP("Action", "Model.Model14"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_15
{
QT_TRANSLATE_NOOP("Action", "Model.Model15"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_16
{
QT_TRANSLATE_NOOP("Action", "Model.Model16"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_17
{
QT_TRANSLATE_NOOP("Action", "Model.Model17"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_18
{
QT_TRANSLATE_NOOP("Action", "Model.Model18"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_19
{
QT_TRANSLATE_NOOP("Action", "Model.Model19"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_20
{
QT_TRANSLATE_NOOP("Action", "Model.Model20"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_21
{
QT_TRANSLATE_NOOP("Action", "Model.Model21"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_22
{
QT_TRANSLATE_NOOP("Action", "Model.Model22"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_23
{
QT_TRANSLATE_NOOP("Action", "Model.Model23"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_MODEL_24
{
QT_TRANSLATE_NOOP("Action", "Model.Model24"),
QT_TRANSLATE_NOOP("Menu", ""),
QT_TRANSLATE_NOOP("Status", "Switch to this model"),
QT_TRANSLATE_NOOP("Status", "Switch to this submodel"),
QT_TRANSLATE_NOOP("Shortcut", "")
},
// LC_HELP_HOMEPAGE

View file

@ -151,9 +151,9 @@ void lcMainWindow::CreateActions()
mActions[CommandIdx] = Action;
}
mActions[LC_FILE_NEW]->setToolTip(tr("New Project"));
mActions[LC_FILE_OPEN]->setToolTip(tr("Open Project"));
mActions[LC_FILE_SAVE]->setToolTip(tr("Save Project"));
mActions[LC_FILE_NEW]->setToolTip(tr("New Model"));
mActions[LC_FILE_OPEN]->setToolTip(tr("Open Model"));
mActions[LC_FILE_SAVE]->setToolTip(tr("Save Model"));
QIcon FileNewIcon;
FileNewIcon.addFile(":/resources/file_new.png");
@ -522,7 +522,7 @@ void lcMainWindow::CreateMenus()
PieceMenu->addAction(mActions[LC_PIECE_HIDE_UNSELECTED]);
PieceMenu->addAction(mActions[LC_PIECE_UNHIDE_ALL]);
QMenu* ModelMenu = menuBar()->addMenu(tr("&Model"));
QMenu* ModelMenu = menuBar()->addMenu(tr("Sub&model"));
ModelMenu->addAction(mActions[LC_MODEL_PROPERTIES]);
ModelMenu->addAction(mActions[LC_MODEL_NEW]);
ModelMenu->addSeparator();
@ -1837,7 +1837,7 @@ bool lcMainWindow::OpenProject(const QString& FileName)
if (LoadFileName.isEmpty())
LoadFileName = lcGetProfileString(LC_PROFILE_PROJECTS_PATH);
LoadFileName = QFileDialog::getOpenFileName(this, tr("Open Project"), LoadFileName, tr("Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*)"));
LoadFileName = QFileDialog::getOpenFileName(this, tr("Open Model"), LoadFileName, tr("Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*)"));
if (LoadFileName.isEmpty())
return false;
@ -1869,7 +1869,7 @@ void lcMainWindow::MergeProject()
if (LoadFileName.isEmpty())
LoadFileName = lcGetProfileString(LC_PROFILE_PROJECTS_PATH);
LoadFileName = QFileDialog::getOpenFileName(this, tr("Merge Project"), LoadFileName, tr("Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*)"));
LoadFileName = QFileDialog::getOpenFileName(this, tr("Merge Model"), LoadFileName, tr("Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*)"));
if (LoadFileName.isEmpty())
return;
@ -1885,9 +1885,9 @@ void lcMainWindow::MergeProject()
lcGetActiveProject()->Merge(NewProject);
if (NumModels == 1)
QMessageBox::information(this, tr("LeoCAD"), tr("Merged 1 model."));
QMessageBox::information(this, tr("LeoCAD"), tr("Merged 1 submodel."));
else
QMessageBox::information(this, tr("LeoCAD"), tr("Merged %1 models.").arg(NumModels));
QMessageBox::information(this, tr("LeoCAD"), tr("Merged %1 submodels.").arg(NumModels));
UpdateModels();
}
@ -1954,7 +1954,7 @@ bool lcMainWindow::SaveProject(const QString& FileName)
QString Filter = (Project->GetModels().GetSize() > 1) ? tr("Supported Files (*.mpd);;All Files (*.*)") : tr("Supported Files (*.ldr *.dat *.mpd);;All Files (*.*)");
SaveFileName = QFileDialog::getSaveFileName(this, tr("Save Project"), SaveFileName, Filter);
SaveFileName = QFileDialog::getSaveFileName(this, tr("Save Model"), SaveFileName, Filter);
if (SaveFileName.isEmpty())
return false;
@ -1983,7 +1983,7 @@ bool lcMainWindow::SaveProjectIfModified()
if (!Project->IsModified())
return true;
switch (QMessageBox::question(this, tr("Save Project"), tr("Save changes to '%1'?").arg(Project->GetTitle()), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel))
switch (QMessageBox::question(this, tr("Save Model"), tr("Save changes to '%1'?").arg(Project->GetTitle()), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel))
{
default:
case QMessageBox::Cancel:

View file

@ -23,7 +23,7 @@
Project::Project()
{
mModified = false;
mActiveModel = new lcModel(tr("Model #1.ldr"));
mActiveModel = new lcModel(tr("New Model.ldr"));
mActiveModel->CreatePieceInfo(this);
mActiveModel->SetSaved();
mModels.Add(mActiveModel);
@ -51,7 +51,7 @@ QString Project::GetTitle() const
if (!mFileName.isEmpty())
return QFileInfo(mFileName).fileName();
return mModels.GetSize() == 1 ? tr("New Project.ldr") : tr("New Project.mpd");
return mModels.GetSize() == 1 ? tr("New Model.ldr") : tr("New Model.mpd");
}
void Project::SetActiveModel(int ModelIndex)
@ -92,7 +92,7 @@ QString Project::GetNewModelName(QWidget* ParentWidget, const QString& DialogTit
if (Name.isEmpty())
{
const QString Prefix = tr("Model #");
const QString Prefix = tr("Submodel #");
int Max = 0;
for (int ModelIdx = 0; ModelIdx < ExistingModels.size(); ModelIdx++)
@ -116,14 +116,14 @@ QString Project::GetNewModelName(QWidget* ParentWidget, const QString& DialogTit
{
bool Ok = false;
Name = QInputDialog::getText(ParentWidget, DialogTitle, tr("Model Name:"), QLineEdit::Normal, Name, &Ok);
Name = QInputDialog::getText(ParentWidget, DialogTitle, tr("Submodel Name:"), QLineEdit::Normal, Name, &Ok);
if (!Ok)
return QString();
if (Name.isEmpty())
{
QMessageBox::information(ParentWidget, tr("Empty Name"), tr("The model name cannot be empty."));
QMessageBox::information(ParentWidget, tr("Empty Name"), tr("The submodel name cannot be empty."));
continue;
}
@ -139,14 +139,11 @@ QString Project::GetNewModelName(QWidget* ParentWidget, const QString& DialogTit
}
if (!ExtensionValid)
{
QMessageBox::information(ParentWidget, tr("Invalid Extension"), tr("The model name must end with '.ldr', '.dat' or '.mpd'."));
continue;
}
Name += ".ldr";
if (ExistingModels.contains(Name, Qt::CaseInsensitive) && Name != CurrentName)
{
QMessageBox::information(ParentWidget, tr("Duplicate Model"), tr("A model named '%1' already exists, please enter an unique name.").arg(Name));
QMessageBox::information(ParentWidget, tr("Duplicate Submodel"), tr("A submodel named '%1' already exists, please enter an unique name.").arg(Name));
continue;
}
@ -163,7 +160,7 @@ lcModel* Project::CreateNewModel(bool ShowModel)
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
ModelNames.append(mModels[ModelIdx]->GetProperties().mName);
QString Name = GetNewModelName(gMainWindow, tr("New Model"), QString(), ModelNames);
QString Name = GetNewModelName(gMainWindow, tr("New Submodel"), QString(), ModelNames);
if (Name.isEmpty())
return nullptr;
@ -517,6 +514,23 @@ void Project::GetModelParts(lcArray<lcModelPartsEntry>& ModelParts)
SetActiveModel(mModels.FindIndex(mActiveModel));
}
bool Project::ExportModel(const QString& FileName, lcModel* Model)
{
QFile File(FileName);
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return false;
}
QTextStream Stream(&File);
Model->SaveLDraw(Stream, false);
return true;
}
QString Project::GetExportFileName(const QString& FileName, const QString& DefaultExtension, const QString& DialogTitle, const QString& DialogFilter) const
{
if (!FileName.isEmpty())

View file

@ -40,6 +40,11 @@ public:
return mActiveModel;
}
int GetActiveModelIndex() const
{
return mModels.FindIndex(mActiveModel);
}
lcModel* GetMainModel() const
{
return !mModels.IsEmpty() ? mModels[0] : nullptr;
@ -68,6 +73,7 @@ public:
bool ImportInventory(const QByteArray& Inventory, const QString& Name, const QString& Description);
void SaveImage();
bool ExportModel(const QString& FileName, lcModel* Model);
void Export3DStudio(const QString& FileName);
void ExportBrickLink();
void ExportCOLLADA(const QString& FileName);

View file

@ -2,6 +2,7 @@
#include "lc_qmodellistdialog.h"
#include "ui_lc_qmodellistdialog.h"
#include "project.h"
#include "lc_profile.h"
lcQModelListDialog::lcQModelListDialog(QWidget* Parent, QList<QPair<QString, lcModel*>>& Models)
: QDialog(Parent), mModels(Models), ui(new Ui::lcQModelListDialog)
@ -14,7 +15,8 @@ lcQModelListDialog::lcQModelListDialog(QWidget* Parent, QList<QPair<QString, lcM
Item->setData(Qt::UserRole, qVariantFromValue<uintptr_t>((uintptr_t)it->second));
ui->ModelList->addItem(Item);
}
ui->ModelList->setCurrentRow(0);
ui->ModelList->setCurrentRow(lcGetActiveProject()->GetActiveModelIndex());
UpdateButtons();
}
lcQModelListDialog::~lcQModelListDialog()
@ -22,6 +24,16 @@ lcQModelListDialog::~lcQModelListDialog()
delete ui;
}
void lcQModelListDialog::UpdateButtons()
{
int CurrentModel = ui->ModelList->currentRow();
int NumModels = ui->ModelList->count();
ui->DeleteModel->setEnabled(NumModels > 1);
ui->MoveUp->setEnabled(NumModels > 1 && CurrentModel > 0);
ui->MoveDown->setEnabled(NumModels > 1 && CurrentModel < NumModels - 1);
}
void lcQModelListDialog::accept()
{
mModels.clear();
@ -41,24 +53,12 @@ void lcQModelListDialog::accept()
void lcQModelListDialog::on_NewModel_clicked()
{
const QString Prefix = tr("Model #");
int Max = 0;
QStringList ModelNames;
for (int ItemIdx = 0; ItemIdx < ui->ModelList->count(); ItemIdx++)
{
const QString& Name = ui->ModelList->item(ItemIdx)->text();
ModelNames.append(ui->ModelList->item(ItemIdx)->text());
if (Name.startsWith(Prefix))
{
QString NumberString = Name.mid(Prefix.length());
QTextStream Stream(&NumberString);
int Number;
Stream >> Number;
Max = qMax(Max, Number);
}
}
QString Name = Prefix + QString::number(Max + 1) + ".ldr";
QString Name = lcGetActiveProject()->GetNewModelName(this, tr("New Submodel"), QString(), ModelNames);
if (Name.isEmpty())
return;
@ -66,13 +66,14 @@ void lcQModelListDialog::on_NewModel_clicked()
QListWidgetItem* Item = new QListWidgetItem(Name);
Item->setData(Qt::UserRole, qVariantFromValue<uintptr_t>(0));
ui->ModelList->addItem(Item);
UpdateButtons();
}
void lcQModelListDialog::on_DeleteModel_clicked()
{
if (ui->ModelList->count() == 1)
{
QMessageBox::information(this, tr("Error"), tr("The project must have at least 1 model."));
QMessageBox::information(this, tr("Error"), tr("The model cannot be empty."));
return;
}
@ -81,11 +82,12 @@ void lcQModelListDialog::on_DeleteModel_clicked()
if (SelectedItems.isEmpty())
return;
QString Prompt = tr("Are you sure you want to delete the model '%1'?").arg(SelectedItems[0]->text());
if (QMessageBox::question(this, tr("Delete Model"), Prompt, QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
QString Prompt = tr("Are you sure you want to delete the submodel '%1'?").arg(SelectedItems[0]->text());
if (QMessageBox::question(this, tr("Delete Submodel"), Prompt, QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
return;
delete SelectedItems[0];
UpdateButtons();
}
void lcQModelListDialog::on_RenameModel_clicked()
@ -100,12 +102,39 @@ void lcQModelListDialog::on_RenameModel_clicked()
for (int ItemIdx = 0; ItemIdx < ui->ModelList->count(); ItemIdx++)
ModelNames.append(ui->ModelList->item(ItemIdx)->text());
QString Name = lcGetActiveProject()->GetNewModelName(this, tr("Rename Model"), SelectedItems[0]->text(), ModelNames);
QString Name = lcGetActiveProject()->GetNewModelName(this, tr("Rename Submodel"), SelectedItems[0]->text(), ModelNames);
if (!Name.isEmpty())
SelectedItems[0]->setText(Name);
}
void lcQModelListDialog::on_ExportModel_clicked()
{
QListWidgetItem* CurrentItem = ui->ModelList->currentItem();
if (!CurrentItem)
return;
lcModel* Model = (lcModel*)CurrentItem->data(Qt::UserRole).value<uintptr_t>();
if (!Model)
{
QMessageBox::information(this, tr("LeoCAD"), tr("Nothing to export."));
return;
}
QString SaveFileName = QFileInfo(QDir(lcGetProfileString(LC_PROFILE_PROJECTS_PATH)), CurrentItem->text()).absoluteFilePath();
SaveFileName = QFileDialog::getSaveFileName(this, tr("Save Model"), SaveFileName, tr("Supported Files (*.ldr *.dat);;All Files (*.*)"));
if (SaveFileName.isEmpty())
return;
lcGetActiveProject()->ExportModel(SaveFileName, Model);
lcSetProfileString(LC_PROFILE_PROJECTS_PATH, QFileInfo(SaveFileName).absolutePath());
}
void lcQModelListDialog::on_MoveUp_clicked()
{
QList<QListWidgetItem*> SelectedItems = ui->ModelList->selectedItems();
@ -122,6 +151,7 @@ void lcQModelListDialog::on_MoveUp_clicked()
ui->ModelList->takeItem(Row);
ui->ModelList->insertItem(Row - 1, Item);
ui->ModelList->setCurrentItem(Item);
UpdateButtons();
}
void lcQModelListDialog::on_MoveDown_clicked()
@ -137,6 +167,7 @@ void lcQModelListDialog::on_MoveDown_clicked()
ui->ModelList->takeItem(Row);
ui->ModelList->insertItem(Row + 1, Item);
ui->ModelList->setCurrentItem(Item);
UpdateButtons();
}
void lcQModelListDialog::on_ModelList_itemDoubleClicked(QListWidgetItem* Item)
@ -145,3 +176,10 @@ void lcQModelListDialog::on_ModelList_itemDoubleClicked(QListWidgetItem* Item)
accept();
}
void lcQModelListDialog::on_ModelList_currentRowChanged(int CurrentRow)
{
Q_UNUSED(CurrentRow);
UpdateButtons();
}

View file

@ -22,11 +22,14 @@ public slots:
void on_NewModel_clicked();
void on_DeleteModel_clicked();
void on_RenameModel_clicked();
void on_ExportModel_clicked();
void on_MoveUp_clicked();
void on_MoveDown_clicked();
void on_ModelList_itemDoubleClicked(QListWidgetItem* Item);
void on_ModelList_currentRowChanged(int CurrentRow);
private:
void UpdateButtons();
Ui::lcQModelListDialog* ui;
};

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Models</string>
<string>Submodels</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -24,7 +24,7 @@
<item>
<widget class="QPushButton" name="NewModel">
<property name="text">
<string>&amp;New</string>
<string>&amp;New...</string>
</property>
</widget>
</item>
@ -42,6 +42,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ExportModel">
<property name="text">
<string>Export...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="MoveUp">
<property name="text">
@ -100,9 +107,9 @@
<tabstop>NewModel</tabstop>
<tabstop>DeleteModel</tabstop>
<tabstop>RenameModel</tabstop>
<tabstop>ExportModel</tabstop>
<tabstop>MoveUp</tabstop>
<tabstop>MoveDown</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>