Cleaning GUI.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-18 09:25:57 +03:00
parent 12fa4399e8
commit 96df1db48e
7 changed files with 12 additions and 385 deletions

View File

@ -43,15 +43,6 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
ui->graphOutputCheck->setChecked(qApp->ValentinaSettings()->GetGraphicalOutput());
ui->undoCount->setValue(qApp->ValentinaSettings()->GetUndoCount());
connect(ui->userMaterialClearButton, &QPushButton::clicked, this, [this]()
{
VSettings* pSet = qApp->ValentinaSettings();
pSet->ClearUserDefinedMaterial();
pSet->sync();
QString qsMsg = tr("All user defined materials have been deleted!");
QMessageBox::information(this, QCoreApplication::applicationName(), qsMsg);
});
InitDefaultSeamAllowance();
ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>381</width>
<height>444</height>
<height>513</height>
</rect>
</property>
<property name="windowTitle">
@ -75,28 +75,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>User defined materials</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="userMaterialClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete all</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">

View File

@ -80,7 +80,6 @@ const QString settingIncrementsDialogSize = QStringLiteral("toolIncrement
const QString settingFormulaWizardDialogSize = QStringLiteral("formulaWizardDialogSize");
const QString settingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion");
const QString settingDateOfLastRemind = QStringLiteral("dateOfLastRemind");
const QString settingUserDefinedMaterials = QStringLiteral("configuration/userDefinedMaterials");
const QString settingCSVWithHeader = QStringLiteral("csv/withHeader");
const QString settingCSVCodec = QStringLiteral("csv/withCodec");
@ -649,27 +648,6 @@ void VCommonSettings::SetDateOfLastRemind(const QDate &date)
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);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetForbidWorkpieceFlipping() const
{

View File

@ -139,10 +139,6 @@ public:
QDate GetDateOfLastRemind() const;
void SetDateOfLastRemind(const QDate &date);
QStringList GetUserDefinedMaterials() const;
void AddUserDefinedMaterial(QString qsMaterial);
void ClearUserDefinedMaterial();
bool GetForbidWorkpieceFlipping() const;
void SetForbidWorkpieceFlipping(bool value);

View File

@ -104,9 +104,6 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
m_my(0),
m_dialog(),
m_visPins(),
m_qslMaterials(),
m_qslPlacements(),
m_conMCP(),
m_oldData(),
m_oldGeom(),
m_oldGrainline(),
@ -252,14 +249,6 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
uiTabLabels->checkBoxFold->setChecked(piece.GetPatternPieceData().IsOnFold());
m_templateLines = piece.GetPatternPieceData().GetLabelTemplate();
m_conMCP.clear();
for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i)
{
m_conMCP << piece.GetPatternPieceData().GetMCP(i);
}
UpdateList();
uiTabGrainline->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType()));
m_oldData = piece.GetPatternPieceData();
@ -464,105 +453,6 @@ void DialogSeamAllowance::resizeEvent(QResizeEvent *event)
DialogTool::resizeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateList()
{
uiTabLabels->listWidgetMCP->clear();
for (int i = 0; i < m_conMCP.count(); ++i)
{
MaterialCutPlacement mcp = m_conMCP.at(i);
QString qsText = tr("Cut %1 of %2%3").arg(mcp.m_iCutNumber);
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
{
qsText = qsText.arg(m_qslMaterials[int(mcp.m_eMaterial)]);
}
else
{
qsText = qsText.arg(mcp.m_qsMaterialUserDef);
}
if (mcp.m_ePlacement == PlacementType::ptCutOnFold)
{
qsText = qsText.arg(QLatin1String(" ") + tr("on Fold"));
}
else
{
qsText = qsText.arg("");
}
uiTabLabels->listWidgetMCP->addItem(qsText);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::AddUpdate()
{
MaterialCutPlacement mcp;
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
const int i = uiTabLabels->comboBoxMaterial->currentData().toInt();
QString qsMat = uiTabLabels->comboBoxMaterial->currentText();
if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[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();
uiTabLabels->comboBoxMaterial->addItem(mcp.m_qsMaterialUserDef, int(MaterialType::mtUserDefined));
}
}
mcp.m_iCutNumber = uiTabLabels->spinBoxCutNumber->value();
mcp.m_ePlacement = PlacementType(uiTabLabels->comboBoxPlacement->currentIndex());
if (m_bAddMode == true)
{
m_conMCP << mcp;
}
else
{
int iR = uiTabLabels->listWidgetMCP->currentRow();
SCASSERT(iR >= 0)
m_conMCP[iR] = mcp;
SetAddMode();
}
UpdateList();
ClearFields();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::Cancel()
{
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::Remove()
{
int iR = uiTabLabels->listWidgetMCP->currentRow();
SCASSERT(iR >= 0)
m_conMCP.removeAt(iR);
UpdateList();
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NameDetailChanged()
{
@ -589,12 +479,6 @@ void DialogSeamAllowance::NameDetailChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::MaterialChanged()
{
uiTabLabels->pushButtonAdd->setEnabled(uiTabLabels->comboBoxMaterial->currentText().isEmpty() == false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
{
@ -1534,53 +1418,6 @@ void DialogSeamAllowance::UpdatePatternLabelValues()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetAddMode()
{
uiTabLabels->pushButtonAdd->setText(tr("Add"));
uiTabLabels->pushButtonCancel->hide();
uiTabLabels->pushButtonRemove->hide();
uiTabLabels->listWidgetMCP->setCurrentRow(-1);
m_bAddMode = true;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetEditMode()
{
int iR = uiTabLabels->listWidgetMCP->currentRow();
// this method can be called by clicking on item or by update. In the latter case there is nothing else to do!
if (iR < 0 || iR >= m_conMCP.count())
{
return;
}
uiTabLabels->pushButtonAdd->setText(tr("Update"));
uiTabLabels->pushButtonCancel->show();
uiTabLabels->pushButtonRemove->show();
MaterialCutPlacement mcp = m_conMCP.at(iR);
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
int iRow = qApp->Settings()->GetUserDefinedMaterials().indexOf(mcp.m_qsMaterialUserDef);
if (iRow >= 0)
{
uiTabLabels->comboBoxMaterial->setCurrentIndex(iRow + m_qslMaterials.count());
}
else
{
uiTabLabels->comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
}
}
else
{
uiTabLabels->comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial));
}
uiTabLabels->spinBoxCutNumber->setValue(mcp.m_iCutNumber);
uiTabLabels->comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));
m_bAddMode = false;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnabledGrainline()
{
@ -2137,12 +1974,6 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.GetPatternPieceData().SetQuantity(uiTabLabels->spinBoxQuantity->value());
piece.GetPatternPieceData().SetOnFold(uiTabLabels->checkBoxFold->isChecked());
piece.GetPatternPieceData().SetLabelTemplate(m_templateLines);
for (int i = 0; i < m_conMCP.count(); ++i)
{
piece.GetPatternPieceData().Append(m_conMCP[i]);
}
piece.GetPatternPieceData().SetPos(m_oldData.GetPos());
piece.GetPatternPieceData().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditDLWidthFormula));
piece.GetPatternPieceData().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditDLHeightFormula));
@ -2669,34 +2500,7 @@ void DialogSeamAllowance::InitPatternPieceDataTab()
uiTabLabels->lineEditLetter->setClearButtonEnabled(true);
connect(uiTabLabels->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged);
m_qslMaterials << QApplication::translate("Detail", "Fabric", nullptr)
<< QApplication::translate("Detail", "Lining", nullptr)
<< QApplication::translate("Detail", "Interfacing", nullptr)
<< QApplication::translate("Detail", "Interlining", nullptr);
for (int i = 0; i < m_qslMaterials.count(); ++i)
{
uiTabLabels->comboBoxMaterial->addItem(m_qslMaterials[i], i);
}
const QStringList qsl = qApp->Settings()->GetUserDefinedMaterials();
for (int i = 0; i < qsl.count(); ++i)
{
uiTabLabels->comboBoxMaterial->addItem(qsl.at(i), int(MaterialType::mtUserDefined));
}
m_qslPlacements << tr("None") << tr("Cut on fold");
uiTabLabels->comboBoxPlacement->addItems(m_qslPlacements);
connect(uiTabLabels->pushButtonAdd, &QPushButton::clicked, this, &DialogSeamAllowance::AddUpdate);
connect(uiTabLabels->pushButtonCancel, &QPushButton::clicked, this, &DialogSeamAllowance::Cancel);
connect(uiTabLabels->pushButtonRemove, &QPushButton::clicked, this, &DialogSeamAllowance::Remove);
connect(uiTabLabels->listWidgetMCP, &QListWidget::itemClicked, this, &DialogSeamAllowance::SetEditMode);
connect(uiTabLabels->comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogSeamAllowance::MaterialChanged);
connect(uiTabLabels->pushButtonEditPieceLabel, &QPushButton::clicked, this, &DialogSeamAllowance::EditLabel);
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
@ -2902,14 +2706,6 @@ void DialogSeamAllowance::UpdateCurrentInternalPathRecord()
item->setText(GetPathName(path));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ClearFields()
{
uiTabLabels->comboBoxMaterial->setCurrentIndex(0);
uiTabLabels->spinBoxCutNumber->setValue(0);
uiTabLabels->comboBoxPlacement->setCurrentIndex(0);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula)
{

View File

@ -75,15 +75,8 @@ protected:
virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE;
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
protected slots:
void UpdateList();
void AddUpdate();
void Cancel();
void Remove();
private slots:
void NameDetailChanged();
void MaterialChanged();
void ShowMainPathContextMenu(const QPoint &pos);
void ShowCustomSAContextMenu(const QPoint &pos);
void ShowInternalPathsContextMenu(const QPoint &pos);
@ -111,9 +104,6 @@ private slots:
void UpdateDetailLabelValues();
void UpdatePatternLabelValues();
void SetAddMode();
void SetEditMode();
void EditGrainlineFormula();
void EditDLFormula();
void EditPLFormula();
@ -192,14 +182,9 @@ private:
QPointer<DialogTool> m_dialog;
QPointer<VisPiecePins> m_visPins;
QStringList m_qslMaterials;
QStringList m_qslPlacements;
// temporary container for Material/Cut/Placement 3-tuples
MCPContainer m_conMCP;
VPieceLabelData m_oldData;
VPieceLabelData m_oldData;
VPatternLabelData m_oldGeom;
VGrainlineData m_oldGrainline;
VGrainlineData m_oldGrainline;
int m_iRotBaseHeight;
int m_iLenBaseHeight;
int m_DLWidthBaseHeight;
@ -231,7 +216,6 @@ private:
bool MainPathIsClockwise() const;
void UpdateCurrentCustomSARecord();
void UpdateCurrentInternalPathRecord();
void ClearFields();
QListWidgetItem *GetItemById(quint32 id);

View File

@ -161,113 +161,17 @@
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Material/Cut number/Placement</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Cut number:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Material type:</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<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">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QSpinBox" name="spinBoxCutNumber">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Placement:</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxPlacement"/>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButtonAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QPushButton" name="pushButtonCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pushButtonRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QListWidget" name="listWidgetMCP">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>