diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 2f62b18c1..e5700e8cd 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -39,6 +39,7 @@ #include "../qmuparser/qmuparsererror.h" #include "../mainwindow.h" #include "../vmisc/qt_dispatch/qt_dispatch.h" +#include "../vmisc/vsettings.h" #include #include @@ -747,25 +748,6 @@ void VApplication::AboutToQuit() Settings()->sync(); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief OpenSettings get acsses to application settings. - * - * Because we can create object in constructor we open file separately. - */ -void VApplication::OpenSettings() -{ - settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), - QCoreApplication::applicationName(), this); -} - -//--------------------------------------------------------------------------------------------------------------------- -VSettings *VApplication::ValentinaSettings() -{ - SCASSERT(settings != nullptr) - return qobject_cast(settings); -} - //--------------------------------------------------------------------------------------------------------------------- bool VApplication::IsGUIMode() { diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index a6e20721c..70c4bbfe7 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -32,7 +32,6 @@ #include "../vmisc/vabstractvalapplication.h" #include "../vwidgets/vmaingraphicsview.h" #include "../vpatterndb/vtranslatevars.h" -#include "vsettings.h" #include "vcmdexport.h" #include "vlockguard.h" @@ -75,9 +74,6 @@ public: virtual bool IsAppInGUIMode() const override; virtual bool IsPedantic() const override; - virtual void OpenSettings() override; - VSettings *ValentinaSettings(); - protected: virtual void InitTrVars() override; virtual bool event(QEvent *e) override; diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index 9a35dbc0d..f3e88df3a 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -30,6 +30,7 @@ #include "ui_preferencesconfigurationpage.h" #include "../../core/vapplication.h" #include "../vpatterndb/pmsystems.h" +#include "../vmisc/vsettings.h" #include #include diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 58a436366..be9dde58c 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -32,6 +32,7 @@ #include "../ifc/xml/vabstractpattern.h" #include "../dialogdatetimeformats.h" #include "../dialogknownmaterials.h" +#include "../vmisc/vsettings.h" #include #include diff --git a/src/app/valentina/dialogs/dialogaboutapp.cpp b/src/app/valentina/dialogs/dialogaboutapp.cpp index 167df5e93..e57b10a67 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.cpp +++ b/src/app/valentina/dialogs/dialogaboutapp.cpp @@ -35,6 +35,7 @@ #include #include "../core/vapplication.h" #include "../fervor/fvupdater.h" +#include "../vmisc/vsettings.h" //--------------------------------------------------------------------------------------------------------------------- DialogAboutApp::DialogAboutApp(QWidget *parent) : diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.cpp b/src/app/valentina/dialogs/dialoglayoutprogress.cpp index 4cb88747f..f8b2dd4db 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.cpp +++ b/src/app/valentina/dialogs/dialoglayoutprogress.cpp @@ -29,6 +29,7 @@ #include "dialoglayoutprogress.h" #include "ui_dialoglayoutprogress.h" #include "../core/vapplication.h" +#include "../vmisc/vsettings.h" #include #include diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 8bfd1e708..6694a61bc 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -41,7 +41,7 @@ #include "../core/vapplication.h" #include "../vtools/dialogs/support/dialogeditlabel.h" #include "dialogknownmaterials.h" -#include "dialogpatternmaterials.h" +#include "../vmisc/vsettings.h" //--------------------------------------------------------------------------------------------------------------------- DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) @@ -54,16 +54,10 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat gradationChanged(false), defaultChanged(false), securityChanged(false), - labelDataChanged(false), - askSaveLabelData(false), - templateDataChanged(false), - patternMaterialsChanged(false), deleteAction(nullptr), changeImageAction(nullptr), saveImageAction(nullptr), - showImageAction(nullptr), - templateLines(), - patternMaterials() + showImageAction(nullptr) { ui->setupUi(this); @@ -71,15 +65,11 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat setWindowFlags(Qt::Window); #endif - ui->lineEditCustomerEmail->setClearButtonEnabled(true); - SCASSERT(doc != nullptr) VSettings *settings = qApp->ValentinaSettings(); settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - patternMaterials = doc->GetPatternMaterials(); - if (qApp->GetPatternPath().isEmpty()) { ui->lineEditPathToFile->setText(tr("")); @@ -154,49 +144,6 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat gradationChanged = false; defaultChanged = false; securityChanged = false; - - ui->lineEditPatternName->setText(doc->GetPatternName()); - ui->lineEditPatternNumber->setText(doc->GetPatternNumber()); - ui->lineEditCompanyName->setText(doc->GetCompanyName()); - - ui->lineEditCustomerName->setText(qApp->GetCustomerName()); - ui->lineEditCustomerEmail->setText(qApp->CustomerEmail()); - ui->dateEditCustomerBirthDate->setDate(qApp->GetCustomerBirthDate()); - - if (qApp->GetMeasurementsType() == MeasurementsType::Individual) - { - ui->lineEditCustomerName->setReadOnly(true); - ui->lineEditCustomerName->setToolTip(tr("The customer name from individual measurements")); - - ui->lineEditCustomerEmail->setReadOnly(true); - ui->lineEditCustomerEmail->setToolTip(tr("The customer email from individual measurements")); - - ui->dateEditCustomerBirthDate->setReadOnly(true); - ui->dateEditCustomerBirthDate->setToolTip(tr("The customer birth date from individual measurements")); - } - - connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); - connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); - connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); - connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); - connect(ui->lineEditCustomerEmail, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); - connect(ui->dateEditCustomerBirthDate, &QDateEdit::editingFinished, this, - &DialogPatternProperties::LabelDataChanged); - connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel); - connect(ui->pushButtonPatternMaterials, &QPushButton::clicked, this, - &DialogPatternProperties::ManagePatternMaterials); - - InitComboBoxFormats(ui->comboBoxDateFormat, - VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(), - doc->GetLabelDateFormat()); - InitComboBoxFormats(ui->comboBoxTimeFormat, - VCommonSettings::PredefinedTimeFormats() + settings->GetUserDefinedTimeFormats(), - doc->GetLabelTimeFormat()); - - connect(ui->comboBoxDateFormat, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogPatternProperties::LabelDataChanged); - connect(ui->comboBoxTimeFormat, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogPatternProperties::LabelDataChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -216,12 +163,6 @@ void DialogPatternProperties::Apply() case 1: SaveReadOnlyState(); break; - case 2: - SaveLabelData(); - SaveTemplateData(); - SaveMaterialData(); - emit doc->UpdatePatternLabel(); - break; default: break; } @@ -232,11 +173,6 @@ void DialogPatternProperties::Ok() { SaveDescription(); SaveReadOnlyState(); - SaveLabelData(); - SaveTemplateData(); - SaveMaterialData(); - - emit doc->UpdatePatternLabel(); close(); } @@ -247,31 +183,6 @@ void DialogPatternProperties::DescEdited() descriptionChanged = true; } -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::LabelDataChanged() -{ - labelDataChanged = true; - askSaveLabelData = true; -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::InitComboBoxFormats(QComboBox *box, const QStringList &items, - const QString ¤tFormat) -{ - SCASSERT(box != nullptr) - - box->addItems(items); - int index = box->findText(currentFormat); - if (index != -1) - { - box->setCurrentIndex(index); - } - else - { - box->setCurrentIndex(0); - } -} - //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveDescription() { @@ -285,48 +196,6 @@ void DialogPatternProperties::SaveDescription() } } -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::SaveLabelData() -{ - if (labelDataChanged) - { - doc->SetPatternName(ui->lineEditPatternName->text()); - doc->SetPatternNumber(ui->lineEditPatternNumber->text()); - doc->SetCompanyName(ui->lineEditCompanyName->text()); - if (qApp->GetMeasurementsType() != MeasurementsType::Individual) - { - doc->SetCustomerName(ui->lineEditCustomerName->text()); - doc->SetCustomerBirthDate(ui->dateEditCustomerBirthDate->date()); - doc->SetCustomerEmail(ui->lineEditCustomerEmail->text()); - } - doc->SetLabelDateFormat(ui->comboBoxDateFormat->currentText()); - doc->SetLabelTimeFormat(ui->comboBoxTimeFormat->currentText()); - - labelDataChanged = false; - askSaveLabelData = false; - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::SaveTemplateData() -{ - if (templateDataChanged) - { - doc->SetPatternLabelTemplate(templateLines); - templateDataChanged = false; - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::SaveMaterialData() -{ - if (patternMaterialsChanged) - { - doc->SetPatternMaterials(patternMaterials); - patternMaterialsChanged = false; - } -} - //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveReadOnlyState() { @@ -469,52 +338,3 @@ void DialogPatternProperties::SaveImage() } } } - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::EditLabel() -{ - if (labelDataChanged && askSaveLabelData) - { - QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Save label data."), - tr("Label data were changed. Do you want to save them before editing label template?"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); - - if (answer == QMessageBox::Yes) - { - SaveLabelData(); - } - else - { - askSaveLabelData = false; - } - } - - DialogEditLabel editor(doc, pattern); - - templateDataChanged ? editor.SetTemplate(templateLines) : editor.SetTemplate(doc->GetPatternLabelTemplate()); - - if (QDialog::Accepted == editor.exec()) - { - templateLines = editor.GetTemplate(); - templateDataChanged = true; - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::ManagePatternMaterials() -{ - VSettings *settings = qApp->ValentinaSettings(); - - DialogPatternMaterials editor(patternMaterials, settings->IsRememberPatternMaterials()); - - if (QDialog::Accepted == editor.exec()) - { - patternMaterials = editor.GetPatternMaterials(); - patternMaterialsChanged = true; - - if (settings->IsRememberPatternMaterials()) - { - settings->SetKnownMaterials(editor.GetKnownMaterials()); - } - } -} diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 851a05e8c..188d3008d 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -51,14 +51,11 @@ public: explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr); virtual ~DialogPatternProperties() override; private slots: - void LabelDataChanged(); void Apply(); void Ok(); void DescEdited(); void ChangeImage(); void SaveImage(); - void EditLabel(); - void ManagePatternMaterials(); private: Q_DISABLE_COPY(DialogPatternProperties) Ui::DialogPatternProperties *ui; @@ -69,23 +66,12 @@ private: bool gradationChanged; bool defaultChanged; bool securityChanged; - bool labelDataChanged; - bool askSaveLabelData; - bool templateDataChanged; - bool patternMaterialsChanged; QAction *deleteAction; QAction *changeImageAction; QAction *saveImageAction; QAction *showImageAction; - QVector templateLines; - QMap patternMaterials; - - void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString ¤tFormat); void SaveDescription(); - void SaveLabelData(); - void SaveTemplateData(); - void SaveMaterialData(); void SaveReadOnlyState(); void InitImage(); diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index 54b2ccf74..d28f9a1aa 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -6,8 +6,8 @@ 0 0 - 726 - 507 + 571 + 491 @@ -21,7 +21,7 @@ - 2 + 0 @@ -247,207 +247,6 @@ - - - Label data - - - - - - - - Label template: - - - - - - - Edit pattern label - - - Edit template - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 0 - 1 - - - - Label data - - - - QFormLayout::ExpandingFieldsGrow - - - - - Pattern name: - - - - - - - 30 - - - - - - - Pattern number: - - - - - - - 30 - - - - - - - Company/Designer name: - - - - - - - 30 - - - - - - - Customer name: - - - - - - - 30 - - - - - - - Date format: - - - - - - - - - - Time format: - - - - - - - - - - Customer birth date: - - - - - - - yyyy-MM-dd - - - - - - - Customer email: - - - - - - - - - - - - - Materials - - - - QFormLayout::ExpandingFieldsGrow - - - - - Pattern materials: - - - - - - - Manage list of pattern materials - - - Manage - - - - - - - - - - Qt::Vertical - - - - 20 - 9000 - - - - - - @@ -468,11 +267,6 @@ QPlainTextEdit
vplaintextedit.h
- - VLineEdit - QLineEdit -
vlineedit.h
-
diff --git a/src/app/valentina/dialogs/dialogpreferences.cpp b/src/app/valentina/dialogs/dialogpreferences.cpp index c7fb237d4..93543160a 100644 --- a/src/app/valentina/dialogs/dialogpreferences.cpp +++ b/src/app/valentina/dialogs/dialogpreferences.cpp @@ -32,6 +32,7 @@ #include "configpages/preferencesconfigurationpage.h" #include "configpages/preferencespatternpage.h" #include "configpages/preferencespathpage.h" +#include "../vmisc/vsettings.h" #include #include diff --git a/src/app/valentina/dialogs/dialogs.pri b/src/app/valentina/dialogs/dialogs.pri index 61c91e73c..192266995 100644 --- a/src/app/valentina/dialogs/dialogs.pri +++ b/src/app/valentina/dialogs/dialogs.pri @@ -19,7 +19,6 @@ HEADERS += \ $$PWD/configpages/preferencespathpage.h \ $$PWD/dialogdatetimeformats.h \ $$PWD/dialogknownmaterials.h \ - $$PWD/dialogpatternmaterials.h \ $$PWD/dialogfinalmeasurements.h SOURCES += \ @@ -39,7 +38,6 @@ SOURCES += \ $$PWD/configpages/preferencespathpage.cpp \ $$PWD/dialogdatetimeformats.cpp \ $$PWD/dialogknownmaterials.cpp \ - $$PWD/dialogpatternmaterials.cpp \ $$PWD/dialogfinalmeasurements.cpp FORMS += \ @@ -59,5 +57,4 @@ FORMS += \ $$PWD/configpages/preferencespathpage.ui \ $$PWD/dialogdatetimeformats.ui \ $$PWD/dialogknownmaterials.ui \ - $$PWD/dialogpatternmaterials.ui \ $$PWD/dialogfinalmeasurements.ui diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index e7fc4878a..d93ee939e 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -695,6 +695,8 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons case Tool::Group: dialogTool->SetGroupCategories(doc->GetGroupCategories()); break; + case Tool::Piece: + dialogTool->SetPatternDoc(doc); default: break; } diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 80f377365..0bca2967a 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -54,6 +54,7 @@ #include "../ifc/xml/vvstconverter.h" #include "../ifc/xml/vvitconverter.h" #include "../ifc/xml/vwatermarkconverter.h" +#include "../vmisc/vsettings.h" #include #include diff --git a/src/app/valentina/watermarkwindow.cpp b/src/app/valentina/watermarkwindow.cpp index d29c487c3..3dbd3d058 100644 --- a/src/app/valentina/watermarkwindow.cpp +++ b/src/app/valentina/watermarkwindow.cpp @@ -41,6 +41,7 @@ #include "../vpropertyexplorer/checkablemessagebox.h" #include "../ifc/exception/vexception.h" #include "../ifc/xml/vwatermarkconverter.h" +#include "../vmisc/vsettings.h" //--------------------------------------------------------------------------------------------------------------------- WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) : diff --git a/src/libs/vmisc/vabstractvalapplication.cpp b/src/libs/vmisc/vabstractvalapplication.cpp index 0e36f0891..dc901f2b9 100644 --- a/src/libs/vmisc/vabstractvalapplication.cpp +++ b/src/libs/vmisc/vabstractvalapplication.cpp @@ -26,7 +26,8 @@ ** *************************************************************************/ #include "vabstractvalapplication.h" -#include "../vmisc/customevents.h" +#include "customevents.h" +#include "vsettings.h" #include @@ -53,3 +54,22 @@ void VAbstractValApplication::PostWarningMessage(const QString &message, QtMsgTy QApplication::postEvent(mainWindow, new WarningMessageEvent(VAbstractValApplication::ClearMessage(message), severity)); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief OpenSettings get acsses to application settings. + * + * Because we can create object in constructor we open file separately. + */ +void VAbstractValApplication::OpenSettings() +{ + settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), + QCoreApplication::applicationName(), this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VSettings *VAbstractValApplication::ValentinaSettings() +{ + SCASSERT(settings != nullptr) + return qobject_cast(settings); +} diff --git a/src/libs/vmisc/vabstractvalapplication.h b/src/libs/vmisc/vabstractvalapplication.h index e0aed0122..eb603a50b 100644 --- a/src/libs/vmisc/vabstractvalapplication.h +++ b/src/libs/vmisc/vabstractvalapplication.h @@ -36,6 +36,7 @@ class VAbstractValApplication;// use in define class VAbstractPattern; class VMainGraphicsView; class QGraphicsScene; +class VSettings; #if defined(qApp) #undef qApp @@ -112,6 +113,9 @@ public: qreal GetDimensionWaist() const; void SetDimensionWaist(qreal dimensionWaist); + virtual void OpenSettings() override; + VSettings *ValentinaSettings(); + protected: QString m_customerName{}; QDate m_customerBirthDate{}; diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 7ae3f7d86..1355a77c0 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -49,7 +49,8 @@ HEADERS += \ $$PWD/support/dialogeditlabel.h \ $$PWD/tools/piece/dialogplacelabel.h \ $$PWD/tools/piece/dialogduplicatedetail.h \ - $$PWD/dialogtoolbox.h + $$PWD/dialogtoolbox.h \ + $$PWD/tools/piece/dialogpatternmaterials.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -98,7 +99,8 @@ SOURCES += \ $$PWD/support/dialogeditlabel.cpp \ $$PWD/tools/piece/dialogplacelabel.cpp \ $$PWD/tools/piece/dialogduplicatedetail.cpp \ - $$PWD/dialogtoolbox.cpp + $$PWD/dialogtoolbox.cpp \ + $$PWD/tools/piece/dialogpatternmaterials.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -151,4 +153,5 @@ FORMS += \ $$PWD/support/dialogeditlabel.ui \ $$PWD/tools/piece/dialogplacelabel.ui \ $$PWD/tools/piece/tabs/tabplacelabels.ui \ - $$PWD/tools/piece/dialogduplicatedetail.ui + $$PWD/tools/piece/dialogduplicatedetail.ui \ + $$PWD/tools/piece/dialogpatternmaterials.ui diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 264180196..54da3386c 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -45,7 +45,7 @@ #include //--------------------------------------------------------------------------------------------------------------------- -DialogEditLabel::DialogEditLabel(VAbstractPattern *doc, const VContainer *data, QWidget *parent) +DialogEditLabel::DialogEditLabel(const VAbstractPattern *doc, const VContainer *data, QWidget *parent) : QDialog(parent), ui(new Ui::DialogEditLabel), m_placeholdersMenu(new QMenu(this)), diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index d663ebe29..8c55fb76a 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -49,7 +49,7 @@ class DialogEditLabel : public QDialog Q_OBJECT public: - explicit DialogEditLabel(VAbstractPattern *doc, const VContainer *data, QWidget *parent = nullptr); + explicit DialogEditLabel(const VAbstractPattern *doc, const VContainer *data, QWidget *parent = nullptr); virtual ~DialogEditLabel(); QVector GetTemplate() const; @@ -75,7 +75,7 @@ private: Q_DISABLE_COPY(DialogEditLabel) Ui::DialogEditLabel *ui; QMenu *m_placeholdersMenu; - VAbstractPattern *m_doc; + const VAbstractPattern *m_doc; const VContainer *m_data; QMap> m_placeholders; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index d773502b6..6b72a97b5 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -809,6 +809,12 @@ void DialogTool::SetPiecesList(const QVector &list) Q_UNUSED(list); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::SetPatternDoc(VAbstractPattern *doc) +{ + Q_UNUSED(doc); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogTool::SetAssociatedTool(VAbstractTool *tool) { diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 4ce2f771d..6912eb13c 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -86,6 +86,7 @@ public: virtual void ShowDialog(bool click); virtual void Build(const Tool &type); virtual void SetPiecesList(const QVector &list); + virtual void SetPatternDoc(VAbstractPattern *doc); quint32 GetToolId() const; void SetToolId(const quint32 &value); diff --git a/src/app/valentina/dialogs/dialogpatternmaterials.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.cpp similarity index 98% rename from src/app/valentina/dialogs/dialogpatternmaterials.cpp rename to src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.cpp index 25fc59ba2..decb39377 100644 --- a/src/app/valentina/dialogs/dialogpatternmaterials.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.cpp @@ -30,8 +30,9 @@ #include "ui_dialogpatternmaterials.h" #include "../vmisc/def.h" -#include "../core/vapplication.h" +#include "../vmisc/vabstractvalapplication.h" #include "../vwidgets/vcomboboxdelegate.h" +#include "../vmisc/vsettings.h" namespace { diff --git a/src/app/valentina/dialogs/dialogpatternmaterials.h b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h similarity index 100% rename from src/app/valentina/dialogs/dialogpatternmaterials.h rename to src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h diff --git a/src/app/valentina/dialogs/dialogpatternmaterials.ui b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.ui similarity index 100% rename from src/app/valentina/dialogs/dialogpatternmaterials.ui rename to src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.ui diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 48e8dc058..7b1497bc7 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -50,8 +50,12 @@ #include "../vgeometry/vplacelabelitem.h" #include "../../dialogtoolbox.h" #include "../vmisc/vmodifierkey.h" +#include "dialogpatternmaterials.h" +#include "../vmisc/vabstractvalapplication.h" +#include "../vmisc/vsettings.h" #include +#include #include #include @@ -76,15 +80,36 @@ QString GetFormulaFromUser(QPlainTextEdit *textEdit) SCASSERT(textEdit != nullptr) return qApp->TrVars()->TryFormulaFromUser(textEdit->toPlainText(), qApp->Settings()->GetOsSeparator()); } + +//--------------------------------------------------------------------------------------------------------------------- +void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString ¤tFormat) +{ + SCASSERT(box != nullptr) + + box->blockSignals(true); + box->addItems(items); + int index = box->findText(currentFormat); + if (index != -1) + { + box->setCurrentIndex(index); + } + else + { + box->setCurrentIndex(0); + } + box->blockSignals(false); +} } //--------------------------------------------------------------------------------------------------------------------- -DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const VAbstractPattern *doc, quint32 toolId, +DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, VAbstractPattern *doc, quint32 toolId, QWidget *parent) : DialogSeamAllowance(data, toolId, parent) { SCASSERT(doc != nullptr) - uiTabLabels->groupBoxPatternLabel->setEnabled(not doc->GetPatternLabelTemplate().isEmpty()); + m_doc = doc; + + uiTabLabels->groupBoxPatternLabel->setEnabled(not m_doc->GetPatternLabelTemplate().isEmpty()); } //--------------------------------------------------------------------------------------------------------------------- @@ -478,7 +503,13 @@ void DialogSeamAllowance::ShowDialog(bool click) //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SaveData() -{} +{ + SavePatternLabelData(); + SavePatternTemplateData(); + SavePatternMaterialData(); + + emit m_doc->UpdatePatternLabel(); +} //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::CheckState() @@ -578,6 +609,19 @@ void DialogSeamAllowance::showEvent(QShowEvent *event) } // do your init stuff here + if (m_doc != nullptr) + { + VSettings *settings = qApp->ValentinaSettings(); + m_patternMaterials = m_doc->GetPatternMaterials(); + + InitComboBoxFormats(uiTabLabels->comboBoxDateFormat, + VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(), + m_doc->GetLabelDateFormat()); + InitComboBoxFormats(uiTabLabels->comboBoxTimeFormat, + VCommonSettings::PredefinedTimeFormats() + settings->GetUserDefinedTimeFormats(), + m_doc->GetLabelTimeFormat()); + } + const QSize sz = qApp->Settings()->GetToolSeamAllowanceDialogSize(); if (not sz.isEmpty()) { @@ -600,6 +644,13 @@ void DialogSeamAllowance::resizeEvent(QResizeEvent *event) DialogTool::resizeEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::SetPatternDoc(VAbstractPattern *doc) +{ + SCASSERT(doc != nullptr) + m_doc = doc; +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::NameDetailChanged() { @@ -2426,7 +2477,7 @@ void DialogSeamAllowance::PatternPinPointChanged() } //--------------------------------------------------------------------------------------------------------------------- -void DialogSeamAllowance::EditLabel() +void DialogSeamAllowance::EditPieceLabel() { DialogEditLabel editor(qApp->getCurrentDocument(), data); editor.SetTemplate(m_templateLines); @@ -3053,7 +3104,7 @@ void DialogSeamAllowance::InitPatternPieceDataTab() uiTabLabels->lineEditTilt->setClearButtonEnabled(true); uiTabLabels->lineEditFoldPosition->setClearButtonEnabled(true); - connect(uiTabLabels->pushButtonEditPieceLabel, &QPushButton::clicked, this, &DialogSeamAllowance::EditLabel); + connect(uiTabLabels->pushButtonEditPieceLabel, &QPushButton::clicked, this, &DialogSeamAllowance::EditPieceLabel); } //--------------------------------------------------------------------------------------------------------------------- @@ -3126,6 +3177,52 @@ void DialogSeamAllowance::InitLabelsTab() connect(uiTabLabels->pushButtonShowPLAngle, &QPushButton::clicked, this, &DialogSeamAllowance::DeployPLAngle); EnabledPatternLabel(); + + // Pattern label data + uiTabLabels->lineEditCustomerEmail->setClearButtonEnabled(true); + + uiTabLabels->lineEditPatternName->setText(m_doc->GetPatternName()); + uiTabLabels->lineEditPatternNumber->setText(m_doc->GetPatternNumber()); + uiTabLabels->lineEditCompanyName->setText(m_doc->GetCompanyName()); + + uiTabLabels->lineEditCustomerName->setText(qApp->GetCustomerName()); + uiTabLabels->lineEditCustomerEmail->setText(qApp->CustomerEmail()); + uiTabLabels->dateEditCustomerBirthDate->setDate(qApp->GetCustomerBirthDate()); + + if (qApp->GetMeasurementsType() == MeasurementsType::Individual) + { + uiTabLabels->lineEditCustomerName->setDisabled(true); + uiTabLabels->lineEditCustomerName->setToolTip(tr("The customer name from individual measurements")); + + uiTabLabels->lineEditCustomerEmail->setDisabled(true); + uiTabLabels->lineEditCustomerEmail->setToolTip(tr("The customer email from individual measurements")); + + uiTabLabels->dateEditCustomerBirthDate->setDisabled(true); + uiTabLabels->dateEditCustomerBirthDate->setToolTip(tr("The customer birth date from individual measurements")); + } + + connect(uiTabLabels->lineEditPatternName, &QLineEdit::editingFinished, this, + &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->lineEditPatternNumber, &QLineEdit::editingFinished, this, + &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->lineEditCompanyName, &QLineEdit::editingFinished, this, + &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->lineEditCustomerName, &QLineEdit::editingFinished, this, + &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->lineEditCustomerEmail, &QLineEdit::editingFinished, this, + &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->dateEditCustomerBirthDate, &QDateEdit::editingFinished, this, + &DialogSeamAllowance::PatternLabelDataChanged); + + connect(uiTabLabels->pushButtonEditPatternLabel, &QPushButton::clicked, this, + &DialogSeamAllowance::EditPatternLabel); + connect(uiTabLabels->pushButtonPatternMaterials, &QPushButton::clicked, this, + &DialogSeamAllowance::ManagePatternMaterials); + + connect(uiTabLabels->comboBoxDateFormat, QOverload::of(&QComboBox::currentIndexChanged), + this, &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->comboBoxTimeFormat, QOverload::of(&QComboBox::currentIndexChanged), + this, &DialogSeamAllowance::PatternLabelDataChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -3616,6 +3713,48 @@ void DialogSeamAllowance::EnablePatternLabelFormulaControls(bool enable) uiTabLabels->comboBoxPLCenterPin->setEnabled(enable); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::SavePatternLabelData() +{ + if (m_patternLabelDataChanged) + { + m_doc->SetPatternName(uiTabLabels->lineEditPatternName->text()); + m_doc->SetPatternNumber(uiTabLabels->lineEditPatternNumber->text()); + m_doc->SetCompanyName(uiTabLabels->lineEditCompanyName->text()); + if (qApp->GetMeasurementsType() != MeasurementsType::Individual) + { + m_doc->SetCustomerName(uiTabLabels->lineEditCustomerName->text()); + m_doc->SetCustomerBirthDate(uiTabLabels->dateEditCustomerBirthDate->date()); + m_doc->SetCustomerEmail(uiTabLabels->lineEditCustomerEmail->text()); + } + m_doc->SetLabelDateFormat(uiTabLabels->comboBoxDateFormat->currentText()); + m_doc->SetLabelTimeFormat(uiTabLabels->comboBoxTimeFormat->currentText()); + + m_patternLabelDataChanged = false; + m_askSavePatternLabelData = false; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::SavePatternTemplateData() +{ + if (m_patternTemplateDataChanged) + { + m_doc->SetPatternLabelTemplate(m_patternTemplateLines); + m_patternTemplateDataChanged = false; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::SavePatternMaterialData() +{ + if (m_patternMaterialsChanged) + { + m_doc->SetPatternMaterials(m_patternMaterials); + m_patternMaterialsChanged = false; + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetMoveControls() { @@ -3645,3 +3784,60 @@ void DialogSeamAllowance::SetMoveControls() } } } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::PatternLabelDataChanged() +{ + m_patternLabelDataChanged = true; + m_askSavePatternLabelData = true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::EditPatternLabel() +{ + if (m_patternLabelDataChanged && m_askSavePatternLabelData) + { + QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Save label data."), + tr("Label data were changed. Do you want to save them before editing label template?"), + QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); + + if (answer == QMessageBox::Yes) + { + SavePatternLabelData(); + } + else + { + m_askSavePatternLabelData = false; + } + } + + DialogEditLabel editor(m_doc, data); + + m_patternTemplateDataChanged ? editor.SetTemplate(m_patternTemplateLines) + : editor.SetTemplate(m_doc->GetPatternLabelTemplate()); + + if (QDialog::Accepted == editor.exec()) + { + m_patternTemplateLines = editor.GetTemplate(); + m_patternTemplateDataChanged = true; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::ManagePatternMaterials() +{ + VSettings *settings = qApp->ValentinaSettings(); + + DialogPatternMaterials editor(m_patternMaterials, settings->IsRememberPatternMaterials()); + + if (QDialog::Accepted == editor.exec()) + { + m_patternMaterials = editor.GetPatternMaterials(); + m_patternMaterialsChanged = true; + + if (settings->IsRememberPatternMaterials()) + { + settings->SetKnownMaterials(editor.GetKnownMaterials()); + } + } +} diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 6a7250ef6..0a3f05e0e 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -56,7 +56,7 @@ class DialogSeamAllowance : public DialogTool Q_OBJECT public: - DialogSeamAllowance(const VContainer *data, const VAbstractPattern *doc, quint32 toolId, + DialogSeamAllowance(const VContainer *data, VAbstractPattern *doc, quint32 toolId, QWidget *parent = nullptr); DialogSeamAllowance(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogSeamAllowance(); @@ -82,6 +82,7 @@ protected: virtual void showEvent( QShowEvent *event ) override; virtual void resizeEvent(QResizeEvent *event) override; virtual bool IsValid() const final; + virtual void SetPatternDoc(VAbstractPattern *doc) final; private slots: void NameDetailChanged(); @@ -155,9 +156,13 @@ private slots: void DetailPinPointChanged(); void PatternPinPointChanged(); - void EditLabel(); + void EditPieceLabel(); void SetMoveControls(); + void PatternLabelDataChanged(); + void EditPatternLabel(); + void ManagePatternMaterials(); + private: Q_DISABLE_COPY(DialogSeamAllowance) @@ -194,10 +199,18 @@ private: bool flagName; bool flagFormula; bool m_bAddMode; + bool m_patternLabelDataChanged{false}; + bool m_askSavePatternLabelData{false}; + bool m_patternTemplateDataChanged{false}; + bool m_patternMaterialsChanged{false}; QPointer m_dialog; QPointer m_visSpecialPoints; + QVector m_patternTemplateLines{}; + + QMap m_patternMaterials{}; + int m_iRotBaseHeight; int m_iLenBaseHeight; int m_DLWidthBaseHeight; @@ -223,6 +236,8 @@ private: QHash m_newPlaceLabels; QHash m_newPaths; + VAbstractPattern *m_doc{nullptr}; + VPiece CreatePiece() const; void NewMainPathItem(const VPieceNode &node); @@ -287,6 +302,10 @@ private: void EnableGrainlineFormulaControls(bool enable); void EnableDetailLabelFormulaControls(bool enable); void EnablePatternLabelFormulaControls(bool enable); + + void SavePatternLabelData(); + void SavePatternTemplateData(); + void SavePatternMaterialData(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui index 53e4f474e..37345eb6c 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui @@ -6,8 +6,8 @@ 0 0 - 579 - 500 + 628 + 516
@@ -28,8 +28,8 @@ 0 0 - 559 - 480 + 608 + 496 @@ -225,6 +225,207 @@ + + + Pattern label data + + + + + + + + Label template: + + + + + + + Edit pattern label + + + Edit template + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 1 + + + + Label data + + + + QFormLayout::ExpandingFieldsGrow + + + + + Pattern name: + + + + + + + 30 + + + + + + + Pattern number: + + + + + + + 30 + + + + + + + Company/Designer name: + + + + + + + 30 + + + + + + + Customer name: + + + + + + + 30 + + + + + + + Date format: + + + + + + + + + + Time format: + + + + + + + + + + Customer birth date: + + + + + + + yyyy-MM-dd + + + + + + + Customer email: + + + + + + + + + + + + + Materials + + + + QFormLayout::ExpandingFieldsGrow + + + + + Pattern materials: + + + + + + + Manage list of pattern materials + + + Manage + + + + + + + + + + Qt::Vertical + + + + 20 + 38000 + + + + + + Labels @@ -243,7 +444,7 @@ Options to control position a detail label. <b>Not available if a detail label template is empty</b>. - Detail label visible + Piece label visible true