From 5f582f7fd1c155cd97d846394761982119837545 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 10 Dec 2017 15:01:12 -0800 Subject: [PATCH] Renamed user facing strings "project" -> "model" and "model" -> "submodel" to be consistent. --- common/lc_commands.cpp | 100 ++++++++++++++++++------------------- common/lc_mainwindow.cpp | 20 ++++---- common/project.cpp | 36 +++++++++---- common/project.h | 6 +++ qt/lc_qmodellistdialog.cpp | 78 +++++++++++++++++++++-------- qt/lc_qmodellistdialog.h | 3 ++ qt/lc_qmodellistdialog.ui | 13 +++-- 7 files changed, 162 insertions(+), 94 deletions(-) diff --git a/common/lc_commands.cpp b/common/lc_commands.cpp index df6281e6..2b7e7efa 100644 --- a/common/lc_commands.cpp +++ b/common/lc_commands.cpp @@ -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 diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 26be3ba7..2dbfbe8c 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -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: diff --git a/common/project.cpp b/common/project.cpp index 8ba7da51..27cfd314 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -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& 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()) diff --git a/common/project.h b/common/project.h index 9db5db26..f2003692 100644 --- a/common/project.h +++ b/common/project.h @@ -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); diff --git a/qt/lc_qmodellistdialog.cpp b/qt/lc_qmodellistdialog.cpp index 613467c9..bc43c49f 100644 --- a/qt/lc_qmodellistdialog.cpp +++ b/qt/lc_qmodellistdialog.cpp @@ -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>& Models) : QDialog(Parent), mModels(Models), ui(new Ui::lcQModelListDialog) @@ -14,7 +15,8 @@ lcQModelListDialog::lcQModelListDialog(QWidget* Parent, QListsetData(Qt::UserRole, qVariantFromValue((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(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(); + + 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 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(); +} \ No newline at end of file diff --git a/qt/lc_qmodellistdialog.h b/qt/lc_qmodellistdialog.h index e3ba36d5..7226f24f 100644 --- a/qt/lc_qmodellistdialog.h +++ b/qt/lc_qmodellistdialog.h @@ -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; }; diff --git a/qt/lc_qmodellistdialog.ui b/qt/lc_qmodellistdialog.ui index 60c06ce4..478098fe 100644 --- a/qt/lc_qmodellistdialog.ui +++ b/qt/lc_qmodellistdialog.ui @@ -11,7 +11,7 @@ - Models + Submodels @@ -24,7 +24,7 @@ - &New + &New... @@ -42,6 +42,13 @@ + + + + Export... + + + @@ -100,9 +107,9 @@ NewModel DeleteModel RenameModel + ExportModel MoveUp MoveDown - buttonBox