From be3c96006f2c00a40c7a714003758ad9cb9efdb4 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 10 Dec 2017 18:12:31 -0800 Subject: [PATCH] Removed old DoDialog function. --- common/lc_application.cpp | 4 +- common/lc_basewindow.h | 7 --- common/lc_mainwindow.cpp | 95 ++++++++++++++++++++++++++------------- common/lc_mainwindow.h | 3 +- common/lc_model.cpp | 4 +- common/project.cpp | 55 +---------------------- common/project.h | 4 +- 7 files changed, 74 insertions(+), 98 deletions(-) diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 63919a8a..9c5e9fc8 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -5,6 +5,7 @@ #include "lc_profile.h" #include "project.h" #include "lc_mainwindow.h" +#include "lc_qpreferencesdialog.h" #include "lc_partselectionwidget.h" #include "lc_shortcuts.h" #include "view.h" @@ -498,7 +499,8 @@ void lcApplication::ShowPreferencesDialog() Options.MouseShortcutsModified = false; Options.MouseShortcutsDefault = false; - if (!gMainWindow->DoDialog(LC_DIALOG_PREFERENCES, &Options)) + lcQPreferencesDialog Dialog(gMainWindow, &Options); + if (Dialog.exec() != QDialog::Accepted) return; bool LibraryChanged = Options.LibraryPath != lcGetProfileString(LC_PROFILE_PARTS_LIBRARY); diff --git a/common/lc_basewindow.h b/common/lc_basewindow.h index 7a403e33..ac979b07 100644 --- a/common/lc_basewindow.h +++ b/common/lc_basewindow.h @@ -8,13 +8,6 @@ #include "lc_shortcuts.h" #include "image.h" -enum LC_DIALOG_TYPE -{ - LC_DIALOG_EXPORT_HTML, - LC_DIALOG_PROPERTIES, - LC_DIALOG_PREFERENCES -}; - struct lcHTMLDialogOptions { QString PathName; diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 2dbfbe8c..cf0f00cb 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -12,6 +12,7 @@ #include "lc_qupdatedialog.h" #include "lc_qaboutdialog.h" #include "lc_setsdatabasedialog.h" +#include "lc_qhtmldialog.h" #include "lc_renderdialog.h" #include "lc_profile.h" #include "view.h" @@ -1008,6 +1009,67 @@ void lcMainWindow::ShowAboutDialog() Dialog.exec(); } +void lcMainWindow::ShowHTMLDialog() +{ + lcHTMLDialogOptions Options; + + QString FileName = lcGetActiveProject()->GetFileName(); + + if (!FileName.isEmpty()) + Options.PathName = QFileInfo(FileName).canonicalPath(); + + int ImageOptions = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_OPTIONS); + int HTMLOptions = lcGetProfileInt(LC_PROFILE_HTML_OPTIONS); + + Options.TransparentImages = (ImageOptions & LC_IMAGE_TRANSPARENT) != 0; + Options.SubModels = (HTMLOptions & (LC_HTML_SUBMODELS)) != 0; + Options.CurrentOnly = (HTMLOptions & LC_HTML_CURRENT_ONLY) != 0; + Options.SinglePage = (HTMLOptions & LC_HTML_SINGLEPAGE) != 0; + Options.IndexPage = (HTMLOptions & LC_HTML_INDEX) != 0; + Options.StepImagesWidth = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_WIDTH); + Options.StepImagesHeight = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_HEIGHT); + Options.HighlightNewParts = (HTMLOptions & LC_HTML_HIGHLIGHT) != 0; + Options.PartsListStep = (HTMLOptions & LC_HTML_LISTSTEP) != 0; + Options.PartsListEnd = (HTMLOptions & LC_HTML_LISTEND) != 0; + Options.PartsListImages = (HTMLOptions & LC_HTML_IMAGES) != 0; + Options.PartImagesColor = lcGetColorIndex(lcGetProfileInt(LC_PROFILE_HTML_PARTS_COLOR)); + Options.PartImagesWidth = lcGetProfileInt(LC_PROFILE_HTML_PARTS_WIDTH); + Options.PartImagesHeight = lcGetProfileInt(LC_PROFILE_HTML_PARTS_HEIGHT); + + lcQHTMLDialog Dialog(this, &Options); + if (Dialog.exec() != QDialog::Accepted) + return; + + HTMLOptions = 0; + + if (Options.SubModels) + HTMLOptions |= LC_HTML_SUBMODELS; + if (Options.CurrentOnly) + HTMLOptions |= LC_HTML_CURRENT_ONLY; + if (Options.SinglePage) + HTMLOptions |= LC_HTML_SINGLEPAGE; + if (Options.IndexPage) + HTMLOptions |= LC_HTML_INDEX; + if (Options.HighlightNewParts) + HTMLOptions |= LC_HTML_HIGHLIGHT; + if (Options.PartsListStep) + HTMLOptions |= LC_HTML_LISTSTEP; + if (Options.PartsListEnd) + HTMLOptions |= LC_HTML_LISTEND; + if (Options.PartsListImages) + HTMLOptions |= LC_HTML_IMAGES; + + lcSetProfileInt(LC_PROFILE_HTML_IMAGE_OPTIONS, Options.TransparentImages ? LC_IMAGE_TRANSPARENT : 0); + lcSetProfileInt(LC_PROFILE_HTML_OPTIONS, HTMLOptions); + lcSetProfileInt(LC_PROFILE_HTML_IMAGE_WIDTH, Options.StepImagesWidth); + lcSetProfileInt(LC_PROFILE_HTML_IMAGE_HEIGHT, Options.StepImagesHeight); + lcSetProfileInt(LC_PROFILE_HTML_PARTS_COLOR, lcGetColorCode(Options.PartImagesColor)); + lcSetProfileInt(LC_PROFILE_HTML_PARTS_WIDTH, Options.PartImagesWidth); + lcSetProfileInt(LC_PROFILE_HTML_PARTS_HEIGHT, Options.PartImagesHeight); + + lcGetActiveProject()->ExportHTML(Options); +} + void lcMainWindow::ShowRenderDialog() { lcRenderDialog Dialog(this); @@ -1048,37 +1110,6 @@ void lcMainWindow::SetSelectionMode(lcSelectionMode SelectionMode) UpdateSelectionMode(); } -// todo: call dialogs directly -#include "lc_qhtmldialog.h" -#include "lc_qpropertiesdialog.h" -#include "lc_qpreferencesdialog.h" - -bool lcMainWindow::DoDialog(LC_DIALOG_TYPE Type, void* Data) -{ - switch (Type) - { - case LC_DIALOG_EXPORT_HTML: - { - lcQHTMLDialog Dialog(this, Data); - return Dialog.exec() == QDialog::Accepted; - } break; - - case LC_DIALOG_PROPERTIES: - { - lcQPropertiesDialog Dialog(this, Data); - return Dialog.exec() == QDialog::Accepted; - } break; - - case LC_DIALOG_PREFERENCES: - { - lcQPreferencesDialog Dialog(this, Data); - return Dialog.exec() == QDialog::Accepted; - } break; - } - - return false; -} - void lcMainWindow::RemoveAllModelTabs() { while (mModelTabWidget->count() > 1) @@ -2081,7 +2112,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) break; case LC_FILE_EXPORT_HTML: - lcGetActiveProject()->ExportHTML(); + ShowHTMLDialog(); break; case LC_FILE_EXPORT_BRICKLINK: diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index 53ad11cb..9ac99209 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -229,8 +229,6 @@ public: return mShadingMenu; } - bool DoDialog(LC_DIALOG_TYPE Type, void* Data); - void RemoveAllModelTabs(); void SetCurrentModelTab(lcModel* Model); void ResetCameras(); @@ -324,6 +322,7 @@ protected: void ShowSearchDialog(); void ShowUpdatesDialog(); void ShowAboutDialog(); + void ShowHTMLDialog(); void ShowRenderDialog(); void ShowPrintDialog(); diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 1a9499ac..2b02fe4b 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -20,6 +20,7 @@ #include "lc_qgroupdialog.h" #include "lc_qeditgroupsdialog.h" #include "lc_selectbycolordialog.h" +#include "lc_qpropertiesdialog.h" #include "lc_qutils.h" #include "lc_lxf.h" @@ -4050,7 +4051,8 @@ void lcModel::ShowPropertiesDialog() GetPartsList(gDefaultColor, true, Options.PartsList); - if (!gMainWindow->DoDialog(LC_DIALOG_PROPERTIES, &Options)) + lcQPropertiesDialog Dialog(gMainWindow, &Options); + if (Dialog.exec() != QDialog::Accepted) return; if (Options.SetDefault) diff --git a/common/project.cpp b/common/project.cpp index 27cfd314..9b99e438 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -1626,61 +1626,8 @@ void Project::CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep St Stream << QLatin1String("\r\n
"); } -void Project::ExportHTML() +void Project::ExportHTML(const lcHTMLDialogOptions& Options) { - lcHTMLDialogOptions Options; - - if (!mFileName.isEmpty()) - Options.PathName = QFileInfo(mFileName).canonicalPath(); - - int ImageOptions = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_OPTIONS); - int HTMLOptions = lcGetProfileInt(LC_PROFILE_HTML_OPTIONS); - - Options.TransparentImages = (ImageOptions & LC_IMAGE_TRANSPARENT) != 0; - Options.SubModels = (HTMLOptions & (LC_HTML_SUBMODELS)) != 0; - Options.CurrentOnly = (HTMLOptions & LC_HTML_CURRENT_ONLY) != 0; - Options.SinglePage = (HTMLOptions & LC_HTML_SINGLEPAGE) != 0; - Options.IndexPage = (HTMLOptions & LC_HTML_INDEX) != 0; - Options.StepImagesWidth = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_WIDTH); - Options.StepImagesHeight = lcGetProfileInt(LC_PROFILE_HTML_IMAGE_HEIGHT); - Options.HighlightNewParts = (HTMLOptions & LC_HTML_HIGHLIGHT) != 0; - Options.PartsListStep = (HTMLOptions & LC_HTML_LISTSTEP) != 0; - Options.PartsListEnd = (HTMLOptions & LC_HTML_LISTEND) != 0; - Options.PartsListImages = (HTMLOptions & LC_HTML_IMAGES) != 0; - Options.PartImagesColor = lcGetColorIndex(lcGetProfileInt(LC_PROFILE_HTML_PARTS_COLOR)); - Options.PartImagesWidth = lcGetProfileInt(LC_PROFILE_HTML_PARTS_WIDTH); - Options.PartImagesHeight = lcGetProfileInt(LC_PROFILE_HTML_PARTS_HEIGHT); - - if (!gMainWindow->DoDialog(LC_DIALOG_EXPORT_HTML, &Options)) - return; - - HTMLOptions = 0; - - if (Options.SubModels) - HTMLOptions |= LC_HTML_SUBMODELS; - if (Options.CurrentOnly) - HTMLOptions |= LC_HTML_CURRENT_ONLY; - if (Options.SinglePage) - HTMLOptions |= LC_HTML_SINGLEPAGE; - if (Options.IndexPage) - HTMLOptions |= LC_HTML_INDEX; - if (Options.HighlightNewParts) - HTMLOptions |= LC_HTML_HIGHLIGHT; - if (Options.PartsListStep) - HTMLOptions |= LC_HTML_LISTSTEP; - if (Options.PartsListEnd) - HTMLOptions |= LC_HTML_LISTEND; - if (Options.PartsListImages) - HTMLOptions |= LC_HTML_IMAGES; - - lcSetProfileInt(LC_PROFILE_HTML_IMAGE_OPTIONS, Options.TransparentImages ? LC_IMAGE_TRANSPARENT : 0); - lcSetProfileInt(LC_PROFILE_HTML_OPTIONS, HTMLOptions); - lcSetProfileInt(LC_PROFILE_HTML_IMAGE_WIDTH, Options.StepImagesWidth); - lcSetProfileInt(LC_PROFILE_HTML_IMAGE_HEIGHT, Options.StepImagesHeight); - lcSetProfileInt(LC_PROFILE_HTML_PARTS_COLOR, lcGetColorCode(Options.PartImagesColor)); - lcSetProfileInt(LC_PROFILE_HTML_PARTS_WIDTH, Options.PartImagesWidth); - lcSetProfileInt(LC_PROFILE_HTML_PARTS_HEIGHT, Options.PartImagesHeight); - QDir Dir(Options.PathName); Dir.mkpath(QLatin1String(".")); diff --git a/common/project.h b/common/project.h index f2003692..ddc2eef1 100644 --- a/common/project.h +++ b/common/project.h @@ -4,6 +4,8 @@ #include "lc_array.h" #include "lc_application.h" +struct lcHTMLDialogOptions; + #define LC_SCENE_BG 0x010 // Draw bg image #define LC_SCENE_BG_TILE 0x040 // Tile bg image #define LC_SCENE_GRADIENT 0x100 // Draw gradient @@ -78,7 +80,7 @@ public: void ExportBrickLink(); void ExportCOLLADA(const QString& FileName); void ExportCSV(); - void ExportHTML(); + void ExportHTML(const lcHTMLDialogOptions& Options); bool ExportPOVRay(const QString& FileName); void ExportWavefront(const QString& FileName);