From 96df1db48ee160793a7dc52ba4d523e724b81a48 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 18 Aug 2017 09:25:57 +0300 Subject: [PATCH] Cleaning GUI. --HG-- branch : feature --- .../configpages/preferencespatternpage.cpp | 9 - .../configpages/preferencespatternpage.ui | 24 +-- src/libs/vmisc/vcommonsettings.cpp | 22 -- src/libs/vmisc/vcommonsettings.h | 4 - .../tools/piece/dialogseamallowance.cpp | 204 ------------------ .../dialogs/tools/piece/dialogseamallowance.h | 20 +- .../dialogs/tools/piece/tabs/tablabels.ui | 114 +--------- 7 files changed, 12 insertions(+), 385 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 2b3f5e632..041d87572 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -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()); diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui index 461ef356a..e4e7e9b4a 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui @@ -7,7 +7,7 @@ 0 0 381 - 444 + 513 @@ -75,28 +75,6 @@ - - - - User defined materials - - - - - - - 0 - 0 - - - - Delete all - - - - - - diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index ded19bd84..a71df04ed 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -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 { diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index c5d7d153d..fa3c8c037 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -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); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index dfd5ce7d6..be24b9e52 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -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) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index ed89ee6da..383379535 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -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 m_dialog; QPointer 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); diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui index a44f5c0ec..3681b96cf 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui @@ -161,113 +161,17 @@ - + - Qt::Horizontal + Qt::Vertical - - - - - - Material/Cut number/Placement - - - - - - Cut number: - - - - - - - Material type: - - - - - - - You can choose one of the predefined materials or enter a new one - - - true - - - - - - - 1 - - - 1000 - - - - - - - Placement: - - - - - - - - - - Add - - - - - - - Cancel - - - - - - - Remove - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 180 - 0 - - - - Qt::ClickFocus - - - + + + 20 + 40 + + +