diff --git a/src/app/valentina/dialogs/dialogknownmaterials.cpp b/src/app/valentina/dialogs/dialogknownmaterials.cpp new file mode 100644 index 000000000..312fec1dd --- /dev/null +++ b/src/app/valentina/dialogs/dialogknownmaterials.cpp @@ -0,0 +1,161 @@ +/************************************************************************ + ** + ** @file dialogknownmaterials.cpp + ** @author Roman Telezhynskyi + ** @date 28 8, 2017 + ** + ** @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) 2017 Valentina project + ** 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 . + ** + *************************************************************************/ + +#include "dialogknownmaterials.h" +#include "ui_dialogknownmaterials.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogKnownMaterials::DialogKnownMaterials(QWidget *parent) + : QDialog(parent), + ui(new Ui::DialogKnownMaterials) +{ + ui->setupUi(this); + + ui->lineEditMaterial->setClearButtonEnabled(true); + + connect(ui->toolButtonAdd, &QToolButton::clicked, this, &DialogKnownMaterials::Add); + connect(ui->toolButtonRemove, &QToolButton::clicked, this, &DialogKnownMaterials::Remove); + connect(ui->lineEditMaterial, &QLineEdit::textEdited, this, &DialogKnownMaterials::SaveText); + connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogKnownMaterials::ShowDetails); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogKnownMaterials::~DialogKnownMaterials() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogKnownMaterials::SetList(const QStringList &list) +{ + ui->listWidget->blockSignals(true); + ui->listWidget->clear(); + + int row = -1; + + for (int i=0; ilistWidget->insertItem(++row, item); + } + } + + ui->listWidget->blockSignals(false); + + if (ui->listWidget->count() > 0) + { + ui->listWidget->setCurrentRow(0); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QStringList DialogKnownMaterials::GetList() const +{ + QStringList list; + + for (int i=0; ilistWidget->count(); ++i) + { + if (const QListWidgetItem *item = ui->listWidget->item(i)) + { + if (not item->text().isEmpty()) + { + list.append(item->text()); + } + } + } + + return list; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogKnownMaterials::ShowDetails() +{ + if (ui->listWidget->count() > 0) + { + const QListWidgetItem *line = ui->listWidget->currentItem(); + if (line) + { + ui->lineEditMaterial->blockSignals(true); + ui->lineEditMaterial->setText(line->text()); + ui->lineEditMaterial->blockSignals(false); + } + } + + SetupControls(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogKnownMaterials::Add() +{ + int row = ui->listWidget->currentRow(); + ui->listWidget->insertItem(++row, new QListWidgetItem(tr("User material"))); + ui->listWidget->setCurrentRow(row); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogKnownMaterials::Remove() +{ + ui->listWidget->blockSignals(true); + QListWidgetItem *curLine = ui->listWidget->takeItem(ui->listWidget->currentRow()); + if (curLine) + { + delete curLine; + } + ui->listWidget->blockSignals(false); + ShowDetails(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogKnownMaterials::SaveText(const QString &text) +{ + QListWidgetItem *curLine = ui->listWidget->currentItem(); + if (curLine) + { + curLine->setText(text); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogKnownMaterials::SetupControls() +{ + const bool enabled = ui->listWidget->count() > 0; + + if (not enabled) + { + ui->lineEditMaterial->blockSignals(true); + ui->lineEditMaterial->clear(); + ui->lineEditMaterial->blockSignals(false); + } + + ui->toolButtonAdd->setEnabled(true); + + ui->toolButtonRemove->setEnabled(enabled); + ui->lineEditMaterial->setEnabled(enabled); +} diff --git a/src/app/valentina/dialogs/dialogknownmaterials.h b/src/app/valentina/dialogs/dialogknownmaterials.h new file mode 100644 index 000000000..d3e08ab37 --- /dev/null +++ b/src/app/valentina/dialogs/dialogknownmaterials.h @@ -0,0 +1,63 @@ +/************************************************************************ + ** + ** @file dialogknownmaterials.h + ** @author Roman Telezhynskyi + ** @date 28 8, 2017 + ** + ** @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) 2017 Valentina project + ** 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 . + ** + *************************************************************************/ + +#ifndef DIALOGKNOWNMATERIALS_H +#define DIALOGKNOWNMATERIALS_H + +#include + +namespace Ui +{ + class DialogKnownMaterials; +} + +class DialogKnownMaterials : public QDialog +{ + Q_OBJECT + +public: + explicit DialogKnownMaterials(QWidget *parent = nullptr); + virtual ~DialogKnownMaterials(); + + void SetList(const QStringList &list); + QStringList GetList() const; + +private slots: + void ShowDetails(); + void Add(); + void Remove(); + void SaveText(const QString &text); + +private: + Q_DISABLE_COPY(DialogKnownMaterials) + Ui::DialogKnownMaterials *ui; + + void SetupControls(); +}; + +#endif // DIALOGKNOWNMATERIALS_H diff --git a/src/app/valentina/dialogs/dialogknownmaterials.ui b/src/app/valentina/dialogs/dialogknownmaterials.ui new file mode 100644 index 000000000..ec6bf6225 --- /dev/null +++ b/src/app/valentina/dialogs/dialogknownmaterials.ui @@ -0,0 +1,149 @@ + + + DialogKnownMaterials + + + + 0 + 0 + 365 + 369 + + + + Known materials + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + true + + + + + + + + + Material: + + + + + + + false + + + + 1 + 0 + + + + Name of material + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + ... + + + + .. + + + + + + + false + + + ... + + + + .. + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + VLineEdit + QLineEdit +
vlineedit.h
+
+
+ + + + + + buttonBox + accepted() + DialogKnownMaterials + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogKnownMaterials + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 8619ea58a..d0e10e8ca 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -39,6 +39,7 @@ #include "../vpatterndb/vcontainer.h" #include "../core/vapplication.h" #include "../vtools/dialogs/support/dialogeditlabel.h" +#include "dialogknownmaterials.h" // calc how many combinations we have static const int heightsCount = (static_cast(GHeights::H200) - @@ -181,6 +182,9 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel); + connect(ui->pushButtonKnownMaterials, &QPushButton::clicked, this, &DialogPatternProperties::ManageKnownMaterials); + connect(ui->pushButtonPatternMaterials, &QPushButton::clicked, this, + &DialogPatternProperties::ManagePatternMaterials); InitComboBoxFormats(ui->comboBoxDateFormat, VSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(), @@ -900,3 +904,23 @@ void DialogPatternProperties::EditLabel() templateDataChanged = true; } } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::ManageKnownMaterials() +{ + VSettings *settings = qApp->ValentinaSettings(); + + DialogKnownMaterials editor; + editor.SetList(settings->GetKnownMaterials()); + + if (QDialog::Accepted == editor.exec()) + { + settings->SetKnownMaterials(editor.GetList()); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::ManagePatternMaterials() +{ + +} diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index ac826ff26..3fdfeffd2 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -62,6 +62,8 @@ private slots: void ChangeImage(); void SaveImage(); void EditLabel(); + void ManageKnownMaterials(); + void ManagePatternMaterials(); private: Q_DISABLE_COPY(DialogPatternProperties) Ui::DialogPatternProperties *ui; diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index 5c6448248..2ced74b87 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -21,7 +21,7 @@ - 0 + 3 @@ -1239,7 +1239,7 @@ Label data - + QFormLayout::ExpandingFieldsGrow @@ -1322,6 +1322,65 @@ + + + + Materials + + + + QFormLayout::ExpandingFieldsGrow + + + + + Known materials: + + + + + + + Manage list of known materials + + + Manage + + + + + + + Pattern materials: + + + + + + + Manage list of pattern materials + + + Manage + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/app/valentina/dialogs/dialogs.pri b/src/app/valentina/dialogs/dialogs.pri index 155d4041e..601d138d7 100644 --- a/src/app/valentina/dialogs/dialogs.pri +++ b/src/app/valentina/dialogs/dialogs.pri @@ -17,7 +17,8 @@ HEADERS += \ $$PWD/configpages/preferencesconfigurationpage.h \ $$PWD/configpages/preferencespatternpage.h \ $$PWD/configpages/preferencespathpage.h \ - $$PWD/dialogdatetimeformats.h + $$PWD/dialogdatetimeformats.h \ + $$PWD/dialogknownmaterials.h SOURCES += \ $$PWD/dialogincrements.cpp \ @@ -34,7 +35,8 @@ SOURCES += \ $$PWD/configpages/preferencesconfigurationpage.cpp \ $$PWD/configpages/preferencespatternpage.cpp \ $$PWD/configpages/preferencespathpage.cpp \ - $$PWD/dialogdatetimeformats.cpp + $$PWD/dialogdatetimeformats.cpp \ + $$PWD/dialogknownmaterials.cpp FORMS += \ $$PWD/dialogincrements.ui \ @@ -51,4 +53,5 @@ FORMS += \ $$PWD/configpages/preferencesconfigurationpage.ui \ $$PWD/configpages/preferencespatternpage.ui \ $$PWD/configpages/preferencespathpage.ui \ - $$PWD/dialogdatetimeformats.ui + $$PWD/dialogdatetimeformats.ui \ + $$PWD/dialogknownmaterials.ui diff --git a/src/libs/vmisc/vsettings.cpp b/src/libs/vmisc/vsettings.cpp index 5cab4a234..7a87f840a 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/libs/vmisc/vsettings.cpp @@ -52,6 +52,7 @@ const QString settingPathsPattern = QStringLiteral("paths/pattern"); const QString settingPathsLayout = QStringLiteral("paths/layout"); const QString settingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput"); +const QString settingPatternKnownMaterials = QStringLiteral("pattern/knownMaterials"); const QString settingCommunityServer = QStringLiteral("community/server"); const QString settingCommunityServerSecure = QStringLiteral("community/serverSecure"); @@ -606,3 +607,14 @@ void VSettings::SetTextAsPaths(bool value) setValue(settingTextAsPaths, value); } +//--------------------------------------------------------------------------------------------------------------------- +QStringList VSettings::GetKnownMaterials() const +{ + return value(settingPatternKnownMaterials, QStringList()).toStringList(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetKnownMaterials(const QStringList &list) +{ + setValue(settingPatternKnownMaterials, list); +} diff --git a/src/libs/vmisc/vsettings.h b/src/libs/vmisc/vsettings.h index 39454c69c..7c0bae8da 100644 --- a/src/libs/vmisc/vsettings.h +++ b/src/libs/vmisc/vsettings.h @@ -155,6 +155,9 @@ public: static bool GetDefTextAsPaths(); void SetTextAsPaths(bool value); + QStringList GetKnownMaterials() const; + void SetKnownMaterials(const QStringList &list); + private: Q_DISABLE_COPY(VSettings) };