Move Pattern Label Data tab to piece dialog. Closes #89

This commit is contained in:
Roman Telezhynskyi 2021-01-23 20:27:51 +02:00
parent d30ca54297
commit 8123c67e7c
27 changed files with 486 additions and 451 deletions

View File

@ -39,6 +39,7 @@
#include "../qmuparser/qmuparsererror.h"
#include "../mainwindow.h"
#include "../vmisc/qt_dispatch/qt_dispatch.h"
#include "../vmisc/vsettings.h"
#include <QtDebug>
#include <QDir>
@ -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<VSettings *>(settings);
}
//---------------------------------------------------------------------------------------------------------------------
bool VApplication::IsGUIMode()
{

View File

@ -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;

View File

@ -30,6 +30,7 @@
#include "ui_preferencesconfigurationpage.h"
#include "../../core/vapplication.h"
#include "../vpatterndb/pmsystems.h"
#include "../vmisc/vsettings.h"
#include <QDir>
#include <QDirIterator>

View File

@ -32,6 +32,7 @@
#include "../ifc/xml/vabstractpattern.h"
#include "../dialogdatetimeformats.h"
#include "../dialogknownmaterials.h"
#include "../vmisc/vsettings.h"
#include <QMessageBox>
#include <QDate>

View File

@ -35,6 +35,7 @@
#include <QtDebug>
#include "../core/vapplication.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/vsettings.h"
//---------------------------------------------------------------------------------------------------------------------
DialogAboutApp::DialogAboutApp(QWidget *parent) :

View File

@ -29,6 +29,7 @@
#include "dialoglayoutprogress.h"
#include "ui_dialoglayoutprogress.h"
#include "../core/vapplication.h"
#include "../vmisc/vsettings.h"
#include <QMessageBox>
#include <QPushButton>

View File

@ -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("<Empty>"));
@ -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<int>::of(&QComboBox::currentIndexChanged),
this, &DialogPatternProperties::LabelDataChanged);
connect(ui->comboBoxTimeFormat, QOverload<int>::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 &currentFormat)
{
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());
}
}
}

View File

@ -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<VLabelTemplateLine> templateLines;
QMap<int, QString> patternMaterials;
void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString &currentFormat);
void SaveDescription();
void SaveLabelData();
void SaveTemplateData();
void SaveMaterialData();
void SaveReadOnlyState();
void InitImage();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>726</width>
<height>507</height>
<width>571</width>
<height>491</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -247,207 +247,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Label data</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_32">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Label template:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditPatternLabel">
<property name="toolTip">
<string>Edit pattern label</string>
</property>
<property name="text">
<string>Edit template</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Label data</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Pattern name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="VLineEdit" name="lineEditPatternName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Pattern number:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="VLineEdit" name="lineEditPatternNumber">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Company/Designer name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="VLineEdit" name="lineEditCompanyName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Customer name:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="VLineEdit" name="lineEditCustomerName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Date format:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="comboBoxDateFormat"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Time format:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="comboBoxTimeFormat"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Customer birth date:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDateEdit" name="dateEditCustomerBirthDate">
<property name="displayFormat">
<string>yyyy-MM-dd</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Customer email:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCustomerEmail"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Materials</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Pattern materials:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonPatternMaterials">
<property name="toolTip">
<string>Manage list of pattern materials</string>
</property>
<property name="text">
<string>Manage</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>9000</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
@ -468,11 +267,6 @@
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
<customwidget>
<class>VLineEdit</class>
<extends>QLineEdit</extends>
<header>vlineedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>

View File

@ -32,6 +32,7 @@
#include "configpages/preferencesconfigurationpage.h"
#include "configpages/preferencespatternpage.h"
#include "configpages/preferencespathpage.h"
#include "../vmisc/vsettings.h"
#include <QMessageBox>
#include <QPushButton>

View File

@ -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

View File

@ -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;
}

View File

@ -54,6 +54,7 @@
#include "../ifc/xml/vvstconverter.h"
#include "../ifc/xml/vvitconverter.h"
#include "../ifc/xml/vwatermarkconverter.h"
#include "../vmisc/vsettings.h"
#include <QFileDialog>
#include <QFileInfo>

View File

@ -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) :

View File

@ -26,7 +26,8 @@
**
*************************************************************************/
#include "vabstractvalapplication.h"
#include "../vmisc/customevents.h"
#include "customevents.h"
#include "vsettings.h"
#include <QWidget>
@ -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<VSettings *>(settings);
}

View File

@ -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{};

View File

@ -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

View File

@ -45,7 +45,7 @@
#include <QDate>
//---------------------------------------------------------------------------------------------------------------------
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)),

View File

@ -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<VLabelTemplateLine> 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<QString, QPair<QString, QString>> m_placeholders;

View File

@ -809,6 +809,12 @@ void DialogTool::SetPiecesList(const QVector<quint32> &list)
Q_UNUSED(list);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::SetPatternDoc(VAbstractPattern *doc)
{
Q_UNUSED(doc);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::SetAssociatedTool(VAbstractTool *tool)
{

View File

@ -86,6 +86,7 @@ public:
virtual void ShowDialog(bool click);
virtual void Build(const Tool &type);
virtual void SetPiecesList(const QVector<quint32> &list);
virtual void SetPatternDoc(VAbstractPattern *doc);
quint32 GetToolId() const;
void SetToolId(const quint32 &value);

View File

@ -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
{

View File

@ -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 <QMenu>
#include <QMessageBox>
#include <QTimer>
#include <QtNumeric>
@ -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 &currentFormat)
{
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<int>::of(&QComboBox::currentIndexChanged),
this, &DialogSeamAllowance::PatternLabelDataChanged);
connect(uiTabLabels->comboBoxTimeFormat, QOverload<int>::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());
}
}
}

View File

@ -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<DialogTool> m_dialog;
QPointer<VisPieceSpecialPoints> m_visSpecialPoints;
QVector<VLabelTemplateLine> m_patternTemplateLines{};
QMap<int, QString> m_patternMaterials{};
int m_iRotBaseHeight;
int m_iLenBaseHeight;
int m_DLWidthBaseHeight;
@ -223,6 +236,8 @@ private:
QHash<quint32, VPlaceLabelItem> m_newPlaceLabels;
QHash<quint32, VPiecePath> 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();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>579</width>
<height>500</height>
<width>628</width>
<height>516</height>
</rect>
</property>
<property name="windowTitle">
@ -28,8 +28,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<height>480</height>
<width>608</width>
<height>496</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -225,6 +225,207 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabPatternLabelData">
<attribute name="title">
<string>Pattern label data</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_31">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Label template:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditPatternLabel">
<property name="toolTip">
<string>Edit pattern label</string>
</property>
<property name="text">
<string>Edit template</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Label data</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Pattern name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="VLineEdit" name="lineEditPatternName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Pattern number:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="VLineEdit" name="lineEditPatternNumber">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Company/Designer name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="VLineEdit" name="lineEditCompanyName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Customer name:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="VLineEdit" name="lineEditCustomerName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Date format:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="comboBoxDateFormat"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Time format:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="comboBoxTimeFormat"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Customer birth date:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDateEdit" name="dateEditCustomerBirthDate">
<property name="displayFormat">
<string>yyyy-MM-dd</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Customer email:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCustomerEmail"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Materials</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Pattern materials:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonPatternMaterials">
<property name="toolTip">
<string>Manage list of pattern materials</string>
</property>
<property name="text">
<string>Manage</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>38000</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabLabels">
<attribute name="title">
<string>Labels</string>
@ -243,7 +444,7 @@
<string>Options to control position a detail label. &lt;b&gt;Not available if a detail label template is empty&lt;/b&gt;.</string>
</property>
<property name="title">
<string>Detail label visible</string>
<string>Piece label visible</string>
</property>
<property name="flat">
<bool>true</bool>