Merged in BojanKverh/valentina-issue24a/feature (pull request #138)

Improvements for feature "New feature: Label on detail" ref #24.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-08-22 11:33:22 +03:00
commit 7dd88da82d
23 changed files with 299 additions and 33 deletions

View File

@ -43,6 +43,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QDirIterator> #include <QDirIterator>
#include <QFormLayout> #include <QFormLayout>
#include <QPushButton>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
ConfigurationPage::ConfigurationPage(QWidget *parent) ConfigurationPage::ConfigurationPage(QWidget *parent)

View File

@ -39,6 +39,8 @@
#include <QLineEdit> #include <QLineEdit>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QFormLayout> #include <QFormLayout>
#include <QMessageBox>
#include <QPushButton>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PatternPage::PatternPage(QWidget *parent): PatternPage::PatternPage(QWidget *parent):
@ -50,16 +52,20 @@ PatternPage::PatternPage(QWidget *parent):
graphOutputCheck(nullptr), graphOutputCheck(nullptr),
undoGroup(nullptr), undoGroup(nullptr),
undoCount(nullptr), undoCount(nullptr),
countStepsLabel(nullptr) countStepsLabel(nullptr),
userMaterialsGroup(nullptr),
userMaterialClearButton(nullptr)
{ {
QGroupBox *userGroup = UserGroup(); QGroupBox *userGroup = UserGroup();
QGroupBox *graphOutputGroup = GraphOutputGroup(); QGroupBox *graphOutputGroup = GraphOutputGroup();
QGroupBox *undoGroup = UndoGroup(); QGroupBox *undoGroup = UndoGroup();
QGroupBox *userMatGroup = UserMaterialGroup();
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(userGroup); mainLayout->addWidget(userGroup);
mainLayout->addWidget(graphOutputGroup); mainLayout->addWidget(graphOutputGroup);
mainLayout->addWidget(undoGroup); mainLayout->addWidget(undoGroup);
mainLayout->addWidget(userMatGroup);
mainLayout->addStretch(1); mainLayout->addStretch(1);
setLayout(mainLayout); setLayout(mainLayout);
} }
@ -81,6 +87,16 @@ void PatternPage::Apply()
settings->SetUndoCount(undoCount->value()); settings->SetUndoCount(undoCount->value());
} }
//---------------------------------------------------------------------------------------------------------------------
void PatternPage::ClearUserDefinedMaterials()
{
VSettings* pSet = qApp->ValentinaSettings();
pSet->ClearUserDefinedMaterial();
pSet->sync();
QString qsMsg = tr("All user defined materials have been deleted!");
QMessageBox::information(this, QApplication::applicationName(), qsMsg);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PatternPage::changeEvent(QEvent *event) void PatternPage::changeEvent(QEvent *event)
{ {
@ -152,6 +168,21 @@ QGroupBox *PatternPage::UndoGroup()
return undoGroup; return undoGroup;
} }
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::UserMaterialGroup()
{
userMaterialsGroup = new QGroupBox(tr("User defined materials"));
userMaterialClearButton = new QPushButton(tr("Delete all"));
connect(userMaterialClearButton, &QPushButton::clicked, this, &PatternPage::ClearUserDefinedMaterials);
QHBoxLayout* pLayout = new QHBoxLayout;
pLayout->addWidget(userMaterialClearButton);
pLayout->addStretch(1);
userMaterialsGroup->setLayout(pLayout);
return userMaterialsGroup;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PatternPage::RetranslateUi() void PatternPage::RetranslateUi()
{ {

View File

@ -37,6 +37,7 @@ class QSpinBox;
class QGroupBox; class QGroupBox;
class QLineEdit; class QLineEdit;
class QLabel; class QLabel;
class QPushButton;
class PatternPage : public QWidget class PatternPage : public QWidget
{ {
@ -44,6 +45,8 @@ class PatternPage : public QWidget
public: public:
explicit PatternPage(QWidget *parent = nullptr); explicit PatternPage(QWidget *parent = nullptr);
void Apply(); void Apply();
public slots:
void ClearUserDefinedMaterials();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private: private:
@ -56,9 +59,13 @@ private:
QGroupBox *undoGroup; QGroupBox *undoGroup;
QSpinBox *undoCount; QSpinBox *undoCount;
QLabel *countStepsLabel; QLabel *countStepsLabel;
QGroupBox *userMaterialsGroup;
QPushButton* userMaterialClearButton;
QGroupBox *UserGroup() Q_REQUIRED_RESULT; QGroupBox *UserGroup() Q_REQUIRED_RESULT;
QGroupBox *GraphOutputGroup() Q_REQUIRED_RESULT; QGroupBox *GraphOutputGroup() Q_REQUIRED_RESULT;
QGroupBox *UndoGroup() Q_REQUIRED_RESULT; QGroupBox *UndoGroup() Q_REQUIRED_RESULT;
QGroupBox *UserMaterialGroup() Q_REQUIRED_RESULT;
void RetranslateUi(); void RetranslateUi();
}; };

View File

@ -1139,8 +1139,11 @@
</item> </item>
<item row="6" column="1"> <item row="6" column="1">
<widget class="QLineEdit" name="lineEditSize"> <widget class="QLineEdit" name="lineEditSize">
<property name="toolTip">
<string>Use %size% and %height% to insert pattern size and height</string>
</property>
<property name="maxLength"> <property name="maxLength">
<number>30</number> <number>40</number>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -1222,6 +1222,7 @@ void MainWindow::changeEvent(QEvent *event)
helpLabel->setText(QObject::tr("Changes applied.")); helpLabel->setText(QObject::tr("Changes applied."));
patternPieceLabel->setText(tr("Pattern Piece:")); patternPieceLabel->setText(tr("Pattern Piece:"));
UpdateWindowTitle(); UpdateWindowTitle();
emit sceneDetails->LanguageChanged();
} }
// remember to call base class implementation // remember to call base class implementation
QMainWindow::changeEvent(event); QMainWindow::changeEvent(event);
@ -2805,6 +2806,7 @@ void MainWindow::ChangedSize(const QString & text)
if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), text.toInt(), static_cast<int>(pattern->height()))) if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), text.toInt(), static_cast<int>(pattern->height())))
{ {
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
emit sceneDetails->DimensionsChanged();
} }
else else
{ {
@ -2833,6 +2835,7 @@ void MainWindow::ChangedHeight(const QString &text)
if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), static_cast<int>(pattern->size()), text.toInt())) if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), static_cast<int>(pattern->size()), text.toInt()))
{ {
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
emit sceneDetails->DimensionsChanged();
} }
else else
{ {

View File

@ -470,7 +470,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
{ {
date = QDate::currentDate(); date = QDate::currentDate();
} }
det.SetPatternInfo(pDoc, geom, qApp->font()); det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height());
} }
det.setWidth(qApp->toPixel(d.getWidth())); det.setWidth(qApp->toPixel(d.getWidth()));
det.CreateTextItems(); det.CreateTextItems();

View File

@ -689,7 +689,10 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
MaterialCutPlacement mcp; MaterialCutPlacement mcp;
QDomElement domMCP = nodeListMCP.at(iMCP).toElement(); QDomElement domMCP = nodeListMCP.at(iMCP).toElement();
mcp.m_eMaterial = MaterialType(GetParametrUInt(domMCP, AttrMaterial, 0)); mcp.m_eMaterial = MaterialType(GetParametrUInt(domMCP, AttrMaterial, 0));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, ""); mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, "");
}
mcp.m_iCutNumber = GetParametrUInt(domMCP, AttrCutNumber, 0); mcp.m_iCutNumber = GetParametrUInt(domMCP, AttrCutNumber, 0);
mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0)); mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0));
detail.GetPatternPieceData().Append(mcp); detail.GetPatternPieceData().Append(mcp);

View File

@ -153,7 +153,8 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont &font) void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont &font,
qreal dSize, qreal dHeight)
{ {
d->patternGeom = geom; d->patternGeom = geom;
qreal dAng = qDegreesToRadians(geom.GetRotation()); qreal dAng = qDegreesToRadians(geom.GetRotation());
@ -173,7 +174,7 @@ void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternI
d->m_tmPattern.SetFont(font); d->m_tmPattern.SetFont(font);
d->m_tmPattern.SetFontSize(geom.GetFontSize()); d->m_tmPattern.SetFontSize(geom.GetFontSize());
d->m_tmPattern.Update(pDoc); d->m_tmPattern.Update(pDoc, dSize, dHeight);
// generate lines of text // generate lines of text
d->m_tmPattern.SetFontSize(geom.GetFontSize()); d->m_tmPattern.SetFontSize(geom.GetFontSize());
d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight()); d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());

View File

@ -77,7 +77,8 @@ public:
void SetDetail(const QString &qsName, const VPatternPieceData& data, const QFont& font); void SetDetail(const QString &qsName, const VPatternPieceData& data, const QFont& font);
void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font); void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font,
qreal dSize, qreal dHeight);
QTransform GetMatrix() const; QTransform GetMatrix() const;
void SetMatrix(const QTransform &matrix); void SetMatrix(const QTransform &matrix);

View File

@ -1,8 +1,37 @@
/************************************************************************
**
** @file vpatternpiecedata.cpp
** @author Bojan Kverh
** @date July 19, 2016
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include <QDate> #include <QDate>
#include <QFileInfo> #include <QFileInfo>
#include <QFontMetrics> #include <QFontMetrics>
#include <QLatin1String> #include <QLatin1String>
#include <QRegularExpression> #include <QRegularExpression>
#include <QApplication>
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/vpatternpiecedata.h" #include "../vpatterndb/vpatternpiecedata.h"
@ -212,6 +241,11 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data)
AddLine(tl); AddLine(tl);
} }
// MCP // MCP
QStringList qslMaterials;
qslMaterials << QApplication::translate("Detail", "Fabric", 0)
<< QApplication::translate("Detail", "Lining", 0)
<< QApplication::translate("Detail", "Interfacing", 0)
<< QApplication::translate("Detail", "Interlining", 0);
QString qsText = tr("Cut %1 on %2%3"); QString qsText = tr("Cut %1 on %2%3");
QStringList qslPlace; QStringList qslPlace;
qslPlace << "" << QLatin1String(" ") + tr("on Fold"); qslPlace << "" << QLatin1String(" ") + tr("on Fold");
@ -222,7 +256,16 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data)
MaterialCutPlacement mcp = data.GetMCP(i); MaterialCutPlacement mcp = data.GetMCP(i);
if (mcp.m_iCutNumber > 0) if (mcp.m_iCutNumber > 0)
{ {
tl.m_qsText = qsText.arg(mcp.m_iCutNumber).arg(mcp.m_qsMaterialUserDef). QString qsMat;
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
qsMat = mcp.m_qsMaterialUserDef;
}
else
{
qsMat = qslMaterials[int(mcp.m_eMaterial)];
}
tl.m_qsText = qsText.arg(mcp.m_iCutNumber).arg(qsMat).
arg(qslPlace[int(mcp.m_ePlacement)]); arg(qslPlace[int(mcp.m_ePlacement)]);
AddLine(tl); AddLine(tl);
} }
@ -234,7 +277,7 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data)
* @brief VTextManager::Update updates the text lines with pattern info * @brief VTextManager::Update updates the text lines with pattern info
* @param pDoc pointer to the abstract pattern object * @param pDoc pointer to the abstract pattern object
*/ */
void VTextManager::Update(const VAbstractPattern *pDoc) void VTextManager::Update(const VAbstractPattern *pDoc, qreal dSize, qreal dHeight)
{ {
Clear(); Clear();
TextLine tl; TextLine tl;
@ -281,6 +324,8 @@ void VTextManager::Update(const VAbstractPattern *pDoc)
tl.m_qsText = pDoc->GetPatternSize(); tl.m_qsText = pDoc->GetPatternSize();
if (tl.m_qsText.isEmpty() == false) if (tl.m_qsText.isEmpty() == false)
{ {
tl.m_qsText.replace(QApplication::translate("Detail", "%size%", 0), QString::number(dSize));
tl.m_qsText.replace(QApplication::translate("Detail", "%height%", 0), QString::number(dHeight));
tl.m_eFontWeight = QFont::Normal; tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal; tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 0; tl.m_iFontSize = 0;

View File

@ -1,3 +1,31 @@
/************************************************************************
**
** @file vpatternpiecedata.cpp
** @author Bojan Kverh
** @date July 19, 2016
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VTEXTMANAGER_H #ifndef VTEXTMANAGER_H
#define VTEXTMANAGER_H #define VTEXTMANAGER_H
@ -57,7 +85,7 @@ public:
bool IsBigEnough(qreal fW, qreal fH, int iFontSize); bool IsBigEnough(qreal fW, qreal fH, int iFontSize);
void FitFontSize(qreal fW, qreal fH); void FitFontSize(qreal fW, qreal fH);
void Update(const QString& qsName, const VPatternPieceData& data); void Update(const QString& qsName, const VPatternPieceData& data);
void Update(const VAbstractPattern* pDoc); void Update(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight);
protected: protected:
static QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm); static QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm);

View File

@ -70,6 +70,7 @@ const QString VCommonSettings::SettingGeneralToolbarsState = QString
const QString VCommonSettings::SettingPreferenceDialogSize = QStringLiteral("preferenceDialogSize"); const QString VCommonSettings::SettingPreferenceDialogSize = QStringLiteral("preferenceDialogSize");
const QString VCommonSettings::SettingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion"); const QString VCommonSettings::SettingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion");
const QString VCommonSettings::SettingDateOfLastRemind = QStringLiteral("dateOfLastRemind"); const QString VCommonSettings::SettingDateOfLastRemind = QStringLiteral("dateOfLastRemind");
const QString VCommonSettings::SettingUserDefinedMaterials = QStringLiteral("configuration/userDefinedMaterials");
static const QString commonIniFilename = QStringLiteral("common"); static const QString commonIniFilename = QStringLiteral("common");
@ -464,3 +465,24 @@ void VCommonSettings::SetDateOfLastRemind(const QDate &date)
settings.setValue(SettingDateOfLastRemind, date); settings.setValue(SettingDateOfLastRemind, date);
settings.sync(); settings.sync();
} }
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::GetUserDefinedMaterials() const
{
return value(SettingUserDefinedMaterials).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::AddUserDefinedMaterial(QString qsMaterial)
{
QStringList qsl = GetUserDefinedMaterials();
qsl << qsMaterial;
setValue(SettingUserDefinedMaterials, qsl);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::ClearUserDefinedMaterial()
{
QStringList qsl;
setValue(SettingUserDefinedMaterials, qsl);
}

View File

@ -118,6 +118,10 @@ public:
QDate GetDateOfLastRemind() const; QDate GetDateOfLastRemind() const;
void SetDateOfLastRemind(const QDate &date); void SetDateOfLastRemind(const QDate &date);
QStringList GetUserDefinedMaterials() const;
void AddUserDefinedMaterial(QString qsMaterial);
void ClearUserDefinedMaterial();
private: private:
Q_DISABLE_COPY(VCommonSettings) Q_DISABLE_COPY(VCommonSettings)
@ -146,6 +150,7 @@ private:
static const QString SettingPreferenceDialogSize; static const QString SettingPreferenceDialogSize;
static const QString SettingLatestSkippedVersion; static const QString SettingLatestSkippedVersion;
static const QString SettingDateOfLastRemind; static const QString SettingDateOfLastRemind;
static const QString SettingUserDefinedMaterials;
}; };
#endif // VCOMMONSETTINGS_H #endif // VCOMMONSETTINGS_H

View File

@ -598,3 +598,4 @@ void VSettings::SetMultiplier(quint8 value)
{ {
setValue(SettingMultiplier, value); setValue(SettingMultiplier, value);
} }

View File

@ -124,9 +124,22 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
connect(ui.toolButtonUp, &QToolButton::clicked, this, &DialogDetail::ScrollUp); connect(ui.toolButtonUp, &QToolButton::clicked, this, &DialogDetail::ScrollUp);
connect(ui.toolButtonDown, &QToolButton::clicked, this, &DialogDetail::ScrollDown); connect(ui.toolButtonDown, &QToolButton::clicked, this, &DialogDetail::ScrollDown);
m_qslMaterials << tr("Fabric") << tr("Lining") << tr("Interfacing") << tr("Interlining"); m_qslMaterials << QApplication::translate("Detail", "Fabric", 0)
<< QApplication::translate("Detail", "Lining", 0)
<< QApplication::translate("Detail", "Interfacing", 0)
<< QApplication::translate("Detail", "Interlining", 0);
for (int i = 0; i < m_qslMaterials.count(); ++i)
{
ui.comboBoxMaterial->addItem(m_qslMaterials[i], i);
}
QStringList qsl = qApp->Settings()->GetUserDefinedMaterials();
for (int i = 0; i < qsl.count(); ++i)
{
ui.comboBoxMaterial->addItem(qsl[i], int(MaterialType::mtUserDefined));
}
ui.comboBoxMaterial->addItems(m_qslMaterials);
m_qslPlacements << tr("None") << tr("Cut on fold"); m_qslPlacements << tr("None") << tr("Cut on fold");
ui.comboBoxPlacement->addItems(m_qslPlacements); ui.comboBoxPlacement->addItems(m_qslPlacements);
@ -134,6 +147,7 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
connect(ui.pushButtonCancel, &QPushButton::clicked, this, &DialogDetail::Cancel); connect(ui.pushButtonCancel, &QPushButton::clicked, this, &DialogDetail::Cancel);
connect(ui.pushButtonRemove, &QPushButton::clicked, this, &DialogDetail::Remove); connect(ui.pushButtonRemove, &QPushButton::clicked, this, &DialogDetail::Remove);
connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode); connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode);
connect(ui.comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogDetail::MaterialChanged);
SetAddMode(); SetAddMode();
ui.tabWidget->setCurrentIndex(0); ui.tabWidget->setCurrentIndex(0);
@ -235,13 +249,33 @@ void DialogDetail::UpdateList()
void DialogDetail::AddUpdate() void DialogDetail::AddUpdate()
{ {
MaterialCutPlacement mcp; MaterialCutPlacement mcp;
mcp.m_qsMaterialUserDef = ui.comboBoxMaterial->currentText(); QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
mcp.m_eMaterial = MaterialType::mtUserDefined;
for (int i = 0; i < m_qslMaterials.count(); ++i) int i = ui.comboBoxMaterial->currentData().toInt();
{ QString qsMat = ui.comboBoxMaterial->currentText();
if (mcp.m_qsMaterialUserDef == m_qslMaterials[i]) if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i])
{ {
mcp.m_eMaterial = MaterialType(i); mcp.m_eMaterial = MaterialType(i);
mcp.m_qsMaterialUserDef.clear();
}
else
{
mcp.m_eMaterial = MaterialType::mtUserDefined;
mcp.m_qsMaterialUserDef = qsMat;
// check if we have new user defined material
bool bFound = false;
for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i)
{
if (mcp.m_qsMaterialUserDef == qslUserMaterials[i])
{
bFound = true;
}
}
if (bFound == false)
{
qApp->Settings()->AddUserDefinedMaterial(mcp.m_qsMaterialUserDef);
qApp->Settings()->sync();
ui.comboBoxMaterial->addItem(mcp.m_qsMaterialUserDef, int(MaterialType::mtUserDefined));
} }
} }
@ -306,6 +340,12 @@ void DialogDetail::NameDetailChanged()
CheckState(); CheckState();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::MaterialChanged()
{
ui.pushButtonAdd->setEnabled(ui.comboBoxMaterial->currentText().isEmpty() == false);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief NewItem add new object (point, arc, spline or spline path) to list * @brief NewItem add new object (point, arc, spline or spline path) to list
@ -413,8 +453,6 @@ VDetail DialogDetail::CreateDetail() const
detail.GetPatternPieceData().SetRotation(m_oldData.GetRotation()); detail.GetPatternPieceData().SetRotation(m_oldData.GetRotation());
detail.GetPatternPieceData().SetVisible(ui.checkBoxDetail->isChecked()); detail.GetPatternPieceData().SetVisible(ui.checkBoxDetail->isChecked());
qDebug() << "DD VISIBLE" << detail.GetPatternPieceData().IsVisible();
detail.GetPatternInfo() = m_oldGeom; detail.GetPatternInfo() = m_oldGeom;
detail.GetPatternInfo().SetVisible(ui.checkBoxPattern->isChecked()); detail.GetPatternInfo().SetVisible(ui.checkBoxPattern->isChecked());
@ -780,7 +818,22 @@ void DialogDetail::SetEditMode()
ui.pushButtonRemove->show(); ui.pushButtonRemove->show();
MaterialCutPlacement mcp = m_conMCP.at(iR); MaterialCutPlacement mcp = m_conMCP.at(iR);
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
int iRow = qApp->Settings()->GetUserDefinedMaterials().indexOf(mcp.m_qsMaterialUserDef);
if (iRow >= 0)
{
ui.comboBoxMaterial->setCurrentIndex(iRow + m_qslMaterials.count());
}
else
{
ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef); ui.comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
}
}
else
{
ui.comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial));
}
ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber); ui.spinBoxCutNumber->setValue(mcp.m_iCutNumber);
ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement)); ui.comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));

View File

@ -84,6 +84,7 @@ protected slots:
private slots: private slots:
void NameDetailChanged(); void NameDetailChanged();
void MaterialChanged();
private: private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */

View File

@ -305,7 +305,8 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-down"> <iconset theme="go-down">
<normaloff>.</normaloff>.</iconset> <normaloff/>
</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -319,7 +320,8 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-up"> <iconset theme="go-up">
<normaloff>.</normaloff>.</iconset> <normaloff/>
</iconset>
</property> </property>
</widget> </widget>
</item> </item>
@ -419,6 +421,9 @@
</item> </item>
<item row="0" column="2" colspan="2"> <item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxMaterial"> <widget class="QComboBox" name="comboBoxMaterial">
<property name="toolTip">
<string>You can choose one of the predefined materials or enter a new one</string>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -229,6 +229,23 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
return; return;
} }
if (fW > parentItem()->boundingRect().width())
{
fW = parentItem()->boundingRect().width();
}
if (fW < MIN_W)
{
fW = MIN_W;
}
if (fH > parentItem()->boundingRect().height())
{
fH = parentItem()->boundingRect().height();
}
if (fH < m_iMinH)
{
fH = m_iMinH;
}
m_rectBoundingBox.setTopLeft(QPointF(0, 0)); m_rectBoundingBox.setTopLeft(QPointF(0, 0));
m_rectBoundingBox.setWidth(fW); m_rectBoundingBox.setWidth(fW);
m_rectBoundingBox.setHeight(fH); m_rectBoundingBox.setHeight(fH);
@ -308,9 +325,9 @@ void VTextGraphicsItem::UpdateData(const QString &qsName, const VPatternPieceDat
* @brief VTextGraphicsItem::UpdateData Updates the pattern label * @brief VTextGraphicsItem::UpdateData Updates the pattern label
* @param pDoc pointer to the pattern object * @param pDoc pointer to the pattern object
*/ */
void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc) void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight)
{ {
m_tm.Update(pDoc); m_tm.Update(pDoc, dSize, dHeight);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -88,7 +88,7 @@ public:
void Update(); void Update();
bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const; bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const;
void UpdateData(const QString& qsName, const VPatternPieceData& data); void UpdateData(const QString& qsName, const VPatternPieceData& data);
void UpdateData(const VAbstractPattern* pDoc); void UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight);
int GetTextLines() const; int GetTextLines() const;
protected: protected:

View File

@ -205,6 +205,11 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo); connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdatePatternInfo); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdatePatternInfo);
connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdateLabel);
connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdatePatternInfo);
connect(sceneDetails, &VMainGraphicsScene::LanguageChanged, this, &VToolDetail::retranslateUi);
UpdateLabel(); UpdateLabel();
UpdatePatternInfo(); UpdatePatternInfo();
} }
@ -443,7 +448,14 @@ void VToolDetail::AddToFile()
MaterialCutPlacement mcp = data.GetMCP(i); MaterialCutPlacement mcp = data.GetMCP(i);
QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP); QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP);
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
}
else
{
domMCP.removeAttribute(VAbstractPattern::AttrUserDefined);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP); domData.appendChild(domMCP);
@ -502,7 +514,14 @@ void VToolDetail::RefreshDataInFile()
MaterialCutPlacement mcp = data.GetMCP(i); MaterialCutPlacement mcp = data.GetMCP(i);
QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP); QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP);
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
}
else
{
domMCP.removeAttribute(VAbstractPattern::AttrUserDefined);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP); domData.appendChild(domMCP);
@ -763,8 +782,8 @@ void VToolDetail::UpdateLabel()
QPointF pt = data.GetPos(); QPointF pt = data.GetPos();
QRectF rectBB; QRectF rectBB;
rectBB.setTopLeft(pt); rectBB.setTopLeft(pt);
rectBB.setWidth(data.GetLabelWidth()); rectBB.setWidth(dataLabel->boundingRect().width());
rectBB.setHeight(data.GetLabelHeight()); rectBB.setHeight(dataLabel->boundingRect().height());
qreal dX; qreal dX;
qreal dY; qreal dY;
if (dataLabel->IsContained(rectBB, data.GetRotation(), dX, dY) == false) if (dataLabel->IsContained(rectBB, data.GetRotation(), dX, dY) == false)
@ -804,13 +823,13 @@ void VToolDetail::UpdatePatternInfo()
fnt.setPixelSize(iFS); fnt.setPixelSize(iFS);
patternInfo->SetFont(fnt); patternInfo->SetFont(fnt);
patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight()); patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight());
patternInfo->UpdateData(doc); patternInfo->UpdateData(doc, getData()->size(), getData()->height());
QPointF pt = geom.GetPos(); QPointF pt = geom.GetPos();
QRectF rectBB; QRectF rectBB;
rectBB.setTopLeft(pt); rectBB.setTopLeft(pt);
rectBB.setWidth(geom.GetLabelWidth()); rectBB.setWidth(patternInfo->boundingRect().width());
rectBB.setHeight(geom.GetLabelHeight()); rectBB.setHeight(patternInfo->boundingRect().height());
qreal dX; qreal dX;
qreal dY; qreal dY;
if (patternInfo->IsContained(rectBB, geom.GetRotation(), dX, dY) == false) if (patternInfo->IsContained(rectBB, geom.GetRotation(), dX, dY) == false)
@ -1122,3 +1141,10 @@ void VToolDetail::UpdateAll()
sceneDetails->update(); sceneDetails->update();
update(); update();
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolDetail::retranslateUi()
{
UpdateLabel();
UpdatePatternInfo();
}

View File

@ -99,6 +99,7 @@ public slots:
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
virtual void ResetChildren(QGraphicsItem* pItem); virtual void ResetChildren(QGraphicsItem* pItem);
virtual void UpdateAll(); virtual void UpdateAll();
virtual void retranslateUi();
protected: protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) Q_DECL_OVERRIDE; QWidget *widget) Q_DECL_OVERRIDE;

View File

@ -161,7 +161,16 @@ void SaveDetailOptions::SavePatternPieceData(QDomElement &domElement, const VDet
MaterialCutPlacement mcp = data.GetMCP(i); MaterialCutPlacement mcp = data.GetMCP(i);
QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP); QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP);
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial)); doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
qDebug() << "USER DEFINED MATERIAL";
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
}
else
{
qDebug() << "PREDEFINED MATERIAL";
domMCP.removeAttribute(VAbstractPattern::AttrUserDefined);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP); domData.appendChild(domMCP);

View File

@ -146,6 +146,9 @@ signals:
void EnableNodePointItemHover(bool enabled); void EnableNodePointItemHover(bool enabled);
void EnableDetailItemHover(bool enabled); void EnableDetailItemHover(bool enabled);
void EnableLineItemHover(bool enabled); void EnableLineItemHover(bool enabled);
void DimensionsChanged();
void LanguageChanged();
private: private:
/** @brief horScrollBar value horizontal scroll bar. */ /** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar; qint32 horScrollBar;