From 7c18e85305109ce43f570ef1c43878838bf11c3a Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 26 Mar 2014 06:39:07 +0200 Subject: [PATCH] Dialog Increment still not tested. --HG-- branch : feature --- .../schema/individual_measurements.xsd | 350 +++++++------- share/resources/schema/pattern.xsd | 24 +- .../schema/standard_measurements.xsd | 16 +- share/tables/individual/indivindual_ru.vit | 102 +++-- share/tables/standard/GOST_man_ru.vst | 1 + src/dialogs/app/dialoghistory.cpp | 2 +- src/dialogs/app/dialogincrements.cpp | 2 + src/dialogs/app/dialogincrements.ui | 426 ++++++++++++------ .../app/dialogindividualmeasurements.cpp | 25 +- .../app/dialogindividualmeasurements.h | 1 + .../app/dialogindividualmeasurements.ui | 122 ++--- src/dialogs/tools/dialogdetail.cpp | 2 +- src/dialogs/tools/dialogtool.cpp | 2 +- src/mainwindow.cpp | 60 +-- src/mainwindow.h | 1 + src/options.h | 5 +- src/tablewindow.cpp | 14 +- src/tools/drawTools/vabstractspline.cpp | 6 +- src/tools/drawTools/vdrawtool.h | 2 +- src/tools/drawTools/vtoolarc.cpp | 10 +- src/tools/drawTools/vtoolcutarc.cpp | 4 +- src/tools/drawTools/vtoolline.cpp | 10 +- src/tools/drawTools/vtoollinepoint.cpp | 6 +- src/tools/drawTools/vtoolpoint.cpp | 40 +- src/tools/drawTools/vtoolsinglepoint.cpp | 2 +- src/tools/drawTools/vtoolspline.cpp | 4 +- src/tools/drawTools/vtoolsplinepath.cpp | 4 +- src/tools/drawTools/vtooltriangle.cpp | 2 +- src/tools/nodeDetails/vnodearc.cpp | 6 +- src/tools/nodeDetails/vnodepoint.cpp | 6 +- src/tools/nodeDetails/vnodespline.cpp | 6 +- src/tools/nodeDetails/vnodesplinepath.cpp | 6 +- src/widgets/textdelegate.cpp | 5 +- src/widgets/vapplication.cpp | 49 +- src/widgets/vapplication.h | 39 +- src/widgets/vcontrolpointspline.cpp | 12 +- src/widgets/vitem.cpp | 6 +- src/widgets/vsimplearc.cpp | 12 +- src/widgets/vsimplespline.cpp | 14 +- src/widgets/vsimplesplinepath.cpp | 4 +- src/xml/vindividualmeasurements.cpp | 64 ++- src/xml/vindividualmeasurements.h | 15 +- src/xml/vpattern.cpp | 6 + 43 files changed, 910 insertions(+), 585 deletions(-) diff --git a/share/resources/schema/individual_measurements.xsd b/share/resources/schema/individual_measurements.xsd index 130b5b1cc..39928eaa9 100644 --- a/share/resources/schema/individual_measurements.xsd +++ b/share/resources/schema/individual_measurements.xsd @@ -9,22 +9,23 @@ - - + + + - + - - + + @@ -33,8 +34,8 @@ - - + + @@ -43,8 +44,8 @@ - - + + @@ -53,8 +54,8 @@ - - + + @@ -69,8 +70,8 @@ - - + + @@ -79,8 +80,8 @@ - - + + @@ -89,8 +90,8 @@ - - + + @@ -99,8 +100,8 @@ - - + + @@ -109,8 +110,8 @@ - - + + @@ -119,8 +120,8 @@ - - + + @@ -129,8 +130,8 @@ - - + + @@ -139,8 +140,8 @@ - - + + @@ -149,8 +150,8 @@ - - + + @@ -159,8 +160,8 @@ - - + + @@ -169,8 +170,8 @@ - - + + @@ -179,8 +180,8 @@ - - + + @@ -189,8 +190,8 @@ - - + + @@ -199,8 +200,8 @@ - - + + @@ -209,8 +210,8 @@ - - + + @@ -219,8 +220,8 @@ - - + + @@ -229,8 +230,8 @@ - - + + @@ -239,8 +240,8 @@ - - + + @@ -249,8 +250,8 @@ - - + + @@ -259,8 +260,8 @@ - - + + @@ -269,8 +270,8 @@ - - + + @@ -279,8 +280,8 @@ - - + + @@ -289,8 +290,8 @@ - - + + @@ -299,8 +300,8 @@ - - + + @@ -309,8 +310,8 @@ - - + + @@ -319,8 +320,8 @@ - - + + @@ -329,8 +330,8 @@ - - + + @@ -339,8 +340,8 @@ - - + + @@ -349,8 +350,8 @@ - - + + @@ -359,8 +360,8 @@ - - + + @@ -369,8 +370,8 @@ - - + + @@ -379,8 +380,8 @@ - - + + @@ -389,8 +390,8 @@ - - + + @@ -399,8 +400,8 @@ - - + + @@ -409,8 +410,8 @@ - - + + @@ -419,8 +420,8 @@ - - + + @@ -429,8 +430,8 @@ - - + + @@ -439,8 +440,8 @@ - - + + @@ -449,8 +450,8 @@ - - + + @@ -459,8 +460,8 @@ - - + + @@ -469,8 +470,8 @@ - - + + @@ -479,8 +480,8 @@ - - + + @@ -489,8 +490,8 @@ - - + + @@ -499,8 +500,8 @@ - - + + @@ -509,8 +510,8 @@ - - + + @@ -525,8 +526,8 @@ - - + + @@ -535,8 +536,8 @@ - - + + @@ -545,8 +546,8 @@ - - + + @@ -555,8 +556,8 @@ - - + + @@ -565,8 +566,8 @@ - - + + @@ -575,8 +576,8 @@ - - + + @@ -585,8 +586,8 @@ - - + + @@ -595,8 +596,8 @@ - - + + @@ -605,8 +606,8 @@ - - + + @@ -615,8 +616,8 @@ - - + + @@ -631,8 +632,8 @@ - - + + @@ -641,8 +642,8 @@ - - + + @@ -651,8 +652,8 @@ - - + + @@ -667,8 +668,8 @@ - - + + @@ -677,8 +678,8 @@ - - + + @@ -687,8 +688,8 @@ - - + + @@ -697,8 +698,8 @@ - - + + @@ -707,8 +708,8 @@ - - + + @@ -717,8 +718,8 @@ - - + + @@ -727,8 +728,8 @@ - - + + @@ -743,8 +744,8 @@ - - + + @@ -753,8 +754,8 @@ - - + + @@ -769,8 +770,8 @@ - - + + @@ -779,8 +780,8 @@ - - + + @@ -789,8 +790,8 @@ - - + + @@ -799,8 +800,8 @@ - - + + @@ -809,8 +810,8 @@ - - + + @@ -819,8 +820,8 @@ - - + + @@ -829,8 +830,8 @@ - - + + @@ -839,8 +840,8 @@ - - + + @@ -849,8 +850,8 @@ - - + + @@ -866,4 +867,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/share/resources/schema/pattern.xsd b/share/resources/schema/pattern.xsd index cfc6524a5..532c2a12e 100644 --- a/share/resources/schema/pattern.xsd +++ b/share/resources/schema/pattern.xsd @@ -9,9 +9,9 @@ - + - + @@ -23,7 +23,7 @@ - + @@ -211,4 +211,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/share/resources/schema/standard_measurements.xsd b/share/resources/schema/standard_measurements.xsd index 98f4759ad..ebff0c5bf 100644 --- a/share/resources/schema/standard_measurements.xsd +++ b/share/resources/schema/standard_measurements.xsd @@ -4,7 +4,7 @@ - + @@ -22,7 +22,7 @@ - + @@ -36,4 +36,16 @@ + + + + + + + + + + + + diff --git a/share/tables/individual/indivindual_ru.vit b/share/tables/individual/indivindual_ru.vit index 29bbdc85b..b7329e774 100644 --- a/share/tables/individual/indivindual_ru.vit +++ b/share/tables/individual/indivindual_ru.vit @@ -1,105 +1,107 @@ + ru - - + 1900-01-01 + male + username@example.com mm - + - + - + - - + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - - - + + + - + - + - - + + - + - - - - + + + + diff --git a/share/tables/standard/GOST_man_ru.vst b/share/tables/standard/GOST_man_ru.vst index 4d61516ab..ca4a1c00a 100644 --- a/share/tables/standard/GOST_man_ru.vst +++ b/share/tables/standard/GOST_man_ru.vst @@ -1,3 +1,4 @@ + Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см mm diff --git a/src/dialogs/app/dialoghistory.cpp b/src/dialogs/app/dialoghistory.cpp index 366f277ed..fbf9e1576 100644 --- a/src/dialogs/app/dialoghistory.cpp +++ b/src/dialogs/app/dialoghistory.cpp @@ -395,7 +395,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Valentina::NodeSplinePath: break; default: - qWarning()<tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementsChanged); } + ui->toolBoxMeasurements->setCurrentIndex(1); + FillMeasurements(); FillIncrements(); FillLengthLines(); diff --git a/src/dialogs/app/dialogincrements.ui b/src/dialogs/app/dialogincrements.ui index 96d7eb33a..ae387ab7a 100644 --- a/src/dialogs/app/dialogincrements.ui +++ b/src/dialogs/app/dialogincrements.ui @@ -6,8 +6,8 @@ 0 0 - 897 - 566 + 979 + 574 @@ -42,21 +42,42 @@ 0 + + + 0 + 0 + + Measurements - + - + + 6 + + + + + 0 + 0 + + Load another measurements table - + + + + 0 + 0 + + ... @@ -70,153 +91,264 @@ - - - - - Family name - - - - - - - - - - - - - - - 84 - 0 - - - - Given name - - - - - - - - - - - - - - - 84 - 0 - - - - Birth date - - - - - - - - - - - - - - - 84 - 0 - - - - Sex - - - - - - - - - - - - true + + + + 0 + 1 + - - QAbstractItemView::NoEditTriggers + + + 0 + 0 + - - true + + 1 - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false - - - 95 - - - 25 - - - false - - - true - - - false - - - 45 - - - 8 - - - - Name + + + + 0 + 0 + 939 + 411 + - - - - The calculated value + + Personal information + + + + + + 6 + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + Family name + + + + + + + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Given name + + + + + + + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Birth date + + + + + + + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Sex + + + + + + + + + + + + + + + 0 + 0 + + + + + 84 + 0 + + + + Mail + + + + + + + + + + + + + + layoutWidget + label_5 + + + + + 0 + 0 + 939 + 411 + - - - - Base value - - - - - In sizes - - - - - In heights - - - - - Description - - + + Measurements + + + + + + true + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + 95 + + + 25 + + + false + + + true + + + false + + + 45 + + + 8 + + + + Name + + + + + The calculated value + + + + + Base value + + + + + In sizes + + + + + In heights + + + + + Description + + + + + + diff --git a/src/dialogs/app/dialogindividualmeasurements.cpp b/src/dialogs/app/dialogindividualmeasurements.cpp index 073669c23..19096b078 100644 --- a/src/dialogs/app/dialogindividualmeasurements.cpp +++ b/src/dialogs/app/dialogindividualmeasurements.cpp @@ -56,6 +56,7 @@ DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, con ui->lineEditName->setText(_name); LoadIndividualTables(); + InitUnits(); CheckState(); connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogIndividualMeasurements::CheckState); @@ -92,7 +93,7 @@ void DialogIndividualMeasurements::DialogAccepted() if ( iMeasur.copy(_tablePath) == false ) { QMessageBox::warning(this, tr("Could not create measurements file"), tr("Please try again or change file")); - return; + DialogRejected(); } } try @@ -100,13 +101,25 @@ void DialogIndividualMeasurements::DialogAccepted() VDomDocument::ValidateXML("://schema/individual_measurements.xsd", _tablePath); VIndividualMeasurements m(data); m.setContent(_tablePath); + const qint32 index = ui->comboBoxUnits->currentIndex(); + Valentina::Units unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString()); + m.setUnit(unit); qApp->setPatternUnit( m.Unit()); + QFile iMeasur(_tablePath); + if (iMeasur.open(QIODevice::WriteOnly| QIODevice::Truncate)) + { + const int Indent = 4; + QTextStream out(&iMeasur); + out.setCodec("UTF-8"); + m.save(out, Indent); + iMeasur.close(); + } } catch(VException &e) { e.CriticalMessageBox(tr("File error."), this); qWarning()<<"File error."<lineEditPathNewM->setEnabled(false); ui->toolButtonOpenNew->setEnabled(false); ui->comboBoxLang->setEnabled(false); + ui->comboBoxUnits->setEnabled(false); if (ui->lineEditPathExistM->text().isEmpty() == false) { @@ -146,6 +160,7 @@ void DialogIndividualMeasurements::CheckState() ui->lineEditPathNewM->setEnabled(true); ui->toolButtonOpenNew->setEnabled(true); ui->comboBoxLang->setEnabled(true); + ui->comboBoxUnits->setEnabled(true); ui->toolButtonOpenExist->setEnabled(false); ui->lineEditPathExistM->setEnabled(false); @@ -259,3 +274,9 @@ void DialogIndividualMeasurements::NewTable() ui->lineEditPathNewM->setToolTip(name); CheckState(); } + +void DialogIndividualMeasurements::InitUnits() +{ + ui->comboBoxUnits->addItem(tr("centimeter"), QVariant(VDomDocument::UnitsToStr(Valentina::Cm))); + ui->comboBoxUnits->addItem(tr("inch"), QVariant(VDomDocument::UnitsToStr(Valentina::Inch))); +} diff --git a/src/dialogs/app/dialogindividualmeasurements.h b/src/dialogs/app/dialogindividualmeasurements.h index f0e609ea6..51362d31e 100644 --- a/src/dialogs/app/dialogindividualmeasurements.h +++ b/src/dialogs/app/dialogindividualmeasurements.h @@ -58,6 +58,7 @@ private: void LoadIndividualTables(); void OpenTable(); void NewTable(); + void InitUnits(); }; inline QString DialogIndividualMeasurements::name() const diff --git a/src/dialogs/app/dialogindividualmeasurements.ui b/src/dialogs/app/dialogindividualmeasurements.ui index 595c4acc1..522a6a3de 100644 --- a/src/dialogs/app/dialogindividualmeasurements.ui +++ b/src/dialogs/app/dialogindividualmeasurements.ui @@ -6,14 +6,14 @@ 0 0 - 358 - 247 + 397 + 280 Dialog - + @@ -76,7 +76,7 @@ - + @@ -91,59 +91,73 @@ - + - - - - - Language: - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - + + + Language: + + - - - - - Path: - - - - - - - - - - ... - - - - - - - - - + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + + + Units: + + + + + + + + + + + + + + Path: + + + + + + + true + + + + + + + ... + + + + + + + diff --git a/src/dialogs/tools/dialogdetail.cpp b/src/dialogs/tools/dialogdetail.cpp index d192889cf..3b159c351 100644 --- a/src/dialogs/tools/dialogdetail.cpp +++ b/src/dialogs/tools/dialogdetail.cpp @@ -136,7 +136,7 @@ void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const N break; } default: - qWarning()<statusBar->addWidget(helpLabel); - connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); - connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); - connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, &MainWindow::ToolAlongLine); - connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this, &MainWindow::ToolShoulderPoint); - connect(ui->toolButtonNormal, &QToolButton::clicked, this, &MainWindow::ToolNormal); - connect(ui->toolButtonBisector, &QToolButton::clicked, this, &MainWindow::ToolBisector); - connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this, &MainWindow::ToolLineIntersect); - connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline); - connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc); - connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath); - connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact); - connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail); - connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight); - connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle); - connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection); - connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline); - connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath); - connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails); - connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc); - pattern = new VContainer(); doc = new VPattern(pattern, comboBoxDraws, &mode); @@ -159,7 +140,7 @@ void MainWindow::ActionNewDraw() } if (doc->appendDraw(patternPieceName) == false) { - qWarning()<(&QComboBox::currentIndexChanged), @@ -577,9 +558,8 @@ void MainWindow::ToolBarOption() void MainWindow::ToolBarDraws() { - QLabel * labelNameDraw = new QLabel; - labelNameDraw ->setText(tr("Pattern Piece: ")); - ui->toolBarDraws->addWidget(labelNameDraw); + QLabel *labelPtternPieceName = new QLabel(tr("Pattern Piece: ")); + ui->toolBarDraws->addWidget(labelPtternPieceName); comboBoxDraws = new QComboBox; ui->toolBarDraws->addWidget(comboBoxDraws); @@ -602,6 +582,29 @@ void MainWindow::ToolBarDraws() ui->actionLayout->setEnabled(false); } +void MainWindow::InitToolButtons() +{ + connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); + connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); + connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, &MainWindow::ToolAlongLine); + connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this, &MainWindow::ToolShoulderPoint); + connect(ui->toolButtonNormal, &QToolButton::clicked, this, &MainWindow::ToolNormal); + connect(ui->toolButtonBisector, &QToolButton::clicked, this, &MainWindow::ToolBisector); + connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this, &MainWindow::ToolLineIntersect); + connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline); + connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc); + connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath); + connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact); + connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail); + connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight); + connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle); + connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection); + connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline); + connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath); + connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails); + connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc); +} + void MainWindow::currentDrawChanged( int index ) { if (index != -1) @@ -1119,7 +1122,7 @@ bool MainWindow::SavePattern(const QString &fileName) } if (fileName.isEmpty()) { - qWarning()<save(out, Indent); tempFile.close(); } @@ -1146,7 +1150,7 @@ bool MainWindow::SavePattern(const QString &fileName) { if ( tempFile.copy(patternFile.fileName()) == false ) { - qWarning()< #include +#include #define SceneSize 50000 @@ -100,6 +101,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Tools ) Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Sources ) Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Draws ) Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Units ) +Q_DECLARE_METATYPE(Valentina::Unit) namespace Pattern { @@ -111,7 +113,4 @@ namespace Pattern } Q_DECLARE_OPERATORS_FOR_FLAGS( Pattern::Measurements ) -#define widthMainLine 1.2 //mm -#define widthHairLine widthMainLine/3 - #endif // OPTIONS_H diff --git a/src/tablewindow.cpp b/src/tablewindow.cpp index 783e75627..1986bd3af 100644 --- a/src/tablewindow.cpp +++ b/src/tablewindow.cpp @@ -81,7 +81,7 @@ void TableWindow::AddPaper() shadowPaper->setBrush(QBrush(Qt::black)); tableScene->addItem(shadowPaper); paper = new QGraphicsRectItem(QRectF(x1, y1, x2, y2)); - paper->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine))); + paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); paper->setBrush(QBrush(Qt::white)); tableScene->addItem(paper); qDebug()<rect().size().toSize(); @@ -243,7 +243,7 @@ void TableWindow::saveScene() qWarning() << "Bad file suffix"<setPen(QPen(Qt::black, qApp->toPixel(widthMainLine))); + paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); brush->setColor( QColor( Qt::gray ) ); brush->setStyle( Qt::SolidPattern ); tableScene->setBackgroundBrush( *brush ); @@ -317,7 +317,7 @@ void TableWindow::itemColliding(QList list, int number) { VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(i) ); Q_CHECK_PTR(bitem); - bitem->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine))); + bitem->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); listCollidingItems.removeAt(i); } } @@ -326,7 +326,7 @@ void TableWindow::itemColliding(QList list, int number) { VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(0) ); Q_CHECK_PTR(bitem); - bitem->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine))); + bitem->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); listCollidingItems.clear(); collidingItems = true; } @@ -436,7 +436,7 @@ void TableWindow::SvgFile(const QString &name) const painter.begin(&generator); painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->toPixel(widthHairLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); tableScene->render(&painter); painter.end(); @@ -453,7 +453,7 @@ void TableWindow::PngFile(const QString &name) const QPainter painter(&image); painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); tableScene->render(&painter); image.save(name); @@ -477,7 +477,7 @@ void TableWindow::PdfFile(const QString &name) const } painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); tableScene->render(&painter); painter.end(); diff --git a/src/tools/drawTools/vabstractspline.cpp b/src/tools/drawTools/vabstractspline.cpp index f3d8d4b32..9d77cdf54 100644 --- a/src/tools/drawTools/vabstractspline.cpp +++ b/src/tools/drawTools/vabstractspline.cpp @@ -54,7 +54,7 @@ void VAbstractSpline::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); this->setAcceptHoverEvents (selectable); emit setEnabledPoint(selectable); @@ -75,13 +75,13 @@ void VAbstractSpline::SetFactor(qreal factor) void VAbstractSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor)); } void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); } QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) diff --git a/src/tools/drawTools/vdrawtool.h b/src/tools/drawTools/vdrawtool.h index 801771591..d6e86c05d 100644 --- a/src/tools/drawTools/vdrawtool.h +++ b/src/tools/drawTools/vdrawtool.h @@ -196,7 +196,7 @@ protected: { currentColor = color; } - item->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); } } private: diff --git a/src/tools/drawTools/vtoolarc.cpp b/src/tools/drawTools/vtoolarc.cpp index 032ca5d9b..e45eb80e7 100644 --- a/src/tools/drawTools/vtoolarc.cpp +++ b/src/tools/drawTools/vtoolarc.cpp @@ -42,7 +42,7 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Valentina: path.addPath(arc->GetPath()); path.setFillRule( Qt::WindingFill ); this->setPath(path); - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); @@ -155,7 +155,7 @@ void VToolArc::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); this->setAcceptHoverEvents (selectable); VDrawTool::ChangedActivDraw(newName); @@ -218,14 +218,14 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor)); } //cppcheck-suppress unusedFunction void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); } void VToolArc::RemoveReferens() @@ -278,7 +278,7 @@ void VToolArc::SaveDialog(QDomElement &domElement) void VToolArc::RefreshGeometry() { - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); const VArc *arc = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(arc->GetPath()); diff --git a/src/tools/drawTools/vtoolcutarc.cpp b/src/tools/drawTools/vtoolcutarc.cpp index ef3ccad11..c363d4723 100644 --- a/src/tools/drawTools/vtoolcutarc.cpp +++ b/src/tools/drawTools/vtoolcutarc.cpp @@ -185,8 +185,8 @@ void VToolCutArc::ChangedActivDraw(const QString &newName) secondArc->setFlag(QGraphicsItem::ItemIsSelectable, false); secondArc->setAcceptHoverEvents(false); } - firstArc->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); - secondArc->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + firstArc->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + secondArc->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); VToolPoint::ChangedActivDraw(newName); } diff --git a/src/tools/drawTools/vtoolline.cpp b/src/tools/drawTools/vtoolline.cpp index 143022e42..e62d9f09f 100644 --- a/src/tools/drawTools/vtoolline.cpp +++ b/src/tools/drawTools/vtoolline.cpp @@ -45,7 +45,7 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor, LineStyle())); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); if (typeCreation == Valentina::FromGui) { @@ -142,7 +142,7 @@ void VToolLine::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle())); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); this->setAcceptHoverEvents (selectable); VDrawTool::ChangedActivDraw(newName); } @@ -177,13 +177,13 @@ void VToolLine::RefreshDataInFile() void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor, LineStyle())); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyle())); } void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle())); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); } void VToolLine::RemoveReferens() @@ -245,5 +245,5 @@ void VToolLine::RefreshGeometry() const VPointF *first = VAbstractTool::data.GeometricObject(firstPoint); const VPointF *second = VAbstractTool::data.GeometricObject(secondPoint); this->setLine(QLineF(first->toQPointF(), second->toQPointF())); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle())); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); } diff --git a/src/tools/drawTools/vtoollinepoint.cpp b/src/tools/drawTools/vtoollinepoint.cpp index e19aec719..7c7bde930 100644 --- a/src/tools/drawTools/vtoollinepoint.cpp +++ b/src/tools/drawTools/vtoollinepoint.cpp @@ -39,7 +39,7 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i QPointF point1 = data->GeometricObject(basePointId)->toQPointF(); QPointF point2 = data->GeometricObject(id)->toQPointF(); mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); - mainLine->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor, LineStyle())); + mainLine->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); } @@ -53,13 +53,13 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName) { currentColor = Qt::gray; } - mainLine->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle())); + mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); VToolPoint::ChangedActivDraw(newName); } void VToolLinePoint::RefreshGeometry() { - mainLine->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle())); + mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); QPointF point = VDrawTool::data.GeometricObject(id)->toQPointF(); QPointF basePoint = VDrawTool::data.GeometricObject(basePointId)->toQPointF(); diff --git a/src/tools/drawTools/vtoolpoint.cpp b/src/tools/drawTools/vtoolpoint.cpp index a2fe84741..f4ae47e14 100644 --- a/src/tools/drawTools/vtoolpoint.cpp +++ b/src/tools/drawTools/vtoolpoint.cpp @@ -30,9 +30,27 @@ const QString VToolPoint::TagName = QStringLiteral("point"); +#define DefRadius 2.0//mm + VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent):VDrawTool(doc, data, id), - QGraphicsEllipseItem(parent), radius(qApp->toPixel(2)), namePoint(0), lineName(0) + QGraphicsEllipseItem(parent), radius(DefRadius), namePoint(0), lineName(0) { + switch(qApp->patternUnit()) + { + case Valentina::Mm: + radius = qApp->toPixel(DefRadius); + break; + case Valentina::Cm: + radius = qApp->toPixel(DefRadius/10.0); + break; + case Valentina::Inch: + radius = qApp->toPixel(DefRadius/25.4); + break; + default: + radius = qApp->toPixel(DefRadius); + break; + } + namePoint = new VGraphicsSimpleTextItem(this); connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::ShowContextMenu); namePoint->setBrush(Qt::black); @@ -81,7 +99,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); this->setAcceptHoverEvents (selectable); namePoint->setFlag(QGraphicsItem::ItemIsMovable, selectable); @@ -89,7 +107,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName) namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, selectable); namePoint->setBrush(QBrush(currentColor)); namePoint->setAcceptHoverEvents(selectable); - lineName->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); VDrawTool::ChangedActivDraw(newName); } @@ -121,31 +139,29 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor)); } void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); } void VToolPoint::RefreshPointGeometry(const VPointF &point) { - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); QRectF rec = QRectF(0, 0, radius*2/factor, radius*2/factor); rec.translate(-rec.center().x(), -rec.center().y()); this->setRect(rec); this->setPos(point.toQPointF()); - disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VToolPoint::NameChangePosition); + disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition); QFont font = namePoint->font(); font.setPointSize(static_cast(namePoint->FontSize()/factor)); namePoint->setFont(font); namePoint->setText(point.name()); namePoint->setPos(QPointF(point.mx(), point.my())); - connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, - &VToolPoint::NameChangePosition); + connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition); RefreshLine(); } @@ -158,11 +174,11 @@ void VToolPoint::RefreshLine() lineName->setLine(QLineF(p1, pRec - scenePos())); if (currentColor == Qt::gray) { - lineName->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); } else { - lineName->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor)); + lineName->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); } if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4)) { diff --git a/src/tools/drawTools/vtoolsinglepoint.cpp b/src/tools/drawTools/vtoolsinglepoint.cpp index b723bff54..561c0646d 100644 --- a/src/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/tools/drawTools/vtoolsinglepoint.cpp @@ -150,7 +150,7 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement) void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) { namePoint->setBrush(color); - lineName->setPen(QPen(color, qApp->toPixel(widthHairLine)/factor)); + lineName->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor)); } void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) diff --git a/src/tools/drawTools/vtoolspline.cpp b/src/tools/drawTools/vtoolspline.cpp index 6c545c5ee..ce1a7f6e1 100644 --- a/src/tools/drawTools/vtoolspline.cpp +++ b/src/tools/drawTools/vtoolspline.cpp @@ -40,7 +40,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Vale path.addPath(spl->GetPath()); path.setFillRule( Qt::WindingFill ); this->setPath(path); - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); @@ -256,7 +256,7 @@ void VToolSpline::SaveDialog(QDomElement &domElement) void VToolSpline::RefreshGeometry() { - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); const VSpline *spl = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(spl->GetPath()); diff --git a/src/tools/drawTools/vtoolsplinepath.cpp b/src/tools/drawTools/vtoolsplinepath.cpp index 50586b9b6..fd0f47c00 100644 --- a/src/tools/drawTools/vtoolsplinepath.cpp +++ b/src/tools/drawTools/vtoolsplinepath.cpp @@ -39,7 +39,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co path.addPath(splPath->GetPath()); path.setFillRule( Qt::WindingFill ); this->setPath(path); - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); @@ -284,7 +284,7 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement) void VToolSplinePath::RefreshGeometry() { - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); const VSplinePath *splPath = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(splPath->GetPath()); diff --git a/src/tools/drawTools/vtooltriangle.cpp b/src/tools/drawTools/vtooltriangle.cpp index 5fb1a7a0f..b757ea2cc 100644 --- a/src/tools/drawTools/vtooltriangle.cpp +++ b/src/tools/drawTools/vtooltriangle.cpp @@ -152,7 +152,7 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c if (c*c < a*a + b*b) { //Still don't know why this code handled. Need to think about that. - qWarning()<setPen(QPen(baseColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); if (typeCreation == Valentina::FromGui) { @@ -129,13 +129,13 @@ void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); } void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); } void VNodeArc::RefreshGeometry() diff --git a/src/tools/nodeDetails/vnodepoint.cpp b/src/tools/nodeDetails/vnodepoint.cpp index 25126cf02..0b2a0204c 100644 --- a/src/tools/nodeDetails/vnodepoint.cpp +++ b/src/tools/nodeDetails/vnodepoint.cpp @@ -44,7 +44,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo lineName = new QGraphicsLineItem(this); connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VNodePoint::NameChangePosition); - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine))); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); this->setBrush(QBrush(Qt::NoBrush)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setAcceptHoverEvents(true); @@ -146,13 +146,13 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); } void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); } diff --git a/src/tools/nodeDetails/vnodespline.cpp b/src/tools/nodeDetails/vnodespline.cpp index 3ffd0ad8f..a9ad3124e 100644 --- a/src/tools/nodeDetails/vnodespline.cpp +++ b/src/tools/nodeDetails/vnodespline.cpp @@ -40,7 +40,7 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); - this->setPen(QPen(baseColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); if (typeCreation == Valentina::FromGui) { @@ -133,13 +133,13 @@ void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); } void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); } void VNodeSpline::RefreshGeometry() diff --git a/src/tools/nodeDetails/vnodesplinepath.cpp b/src/tools/nodeDetails/vnodesplinepath.cpp index 5c3c208b8..c8a01a065 100644 --- a/src/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/tools/nodeDetails/vnodesplinepath.cpp @@ -40,7 +40,7 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); - this->setPen(QPen(baseColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); if (typeCreation == Valentina::FromGui) { @@ -136,13 +136,13 @@ void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine()))); } void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); } void VNodeSplinePath::RefreshGeometry() diff --git a/src/widgets/textdelegate.cpp b/src/widgets/textdelegate.cpp index 45c57d6c6..d45b228cf 100644 --- a/src/widgets/textdelegate.cpp +++ b/src/widgets/textdelegate.cpp @@ -41,9 +41,8 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem Q_UNUSED(option); Q_UNUSED(index); QLineEdit *editor = new QLineEdit(parent); - QRegExp re("^(([^+ -/()\\^*%:;\"\'=.,><0-9]){1,1}[^+ -/()\\^*%:;\"\'=><]([0-9]){0,}){0,}$"); - QRegExpValidator *v = new QRegExpValidator(re); - editor->setValidator( v ); + //Same regex pattern in xsd file + editor->setValidator( new QRegExpValidator(QRegExp("([\\p{L}]|[^0-9])[_\\p{L}0-9]*")) ); connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor); return editor; } diff --git a/src/widgets/vapplication.cpp b/src/widgets/vapplication.cpp index c33c7b579..45ecac5d6 100644 --- a/src/widgets/vapplication.cpp +++ b/src/widgets/vapplication.cpp @@ -38,13 +38,16 @@ const qreal VApplication::PrintDPI = 96.0; -// reimplemented from QApplication so we can throw exceptions in slots -VApplication::VApplication(int &argc, char **argv) - : QApplication(argc, argv), _patternUnit(Valentina::Cm), _patternType(Pattern::Individual) -{ +#define DefWidth 1.2//mm +VApplication::VApplication(int &argc, char **argv) + : QApplication(argc, argv), _patternUnit(Valentina::Cm), _patternType(Pattern::Individual), + _widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0) +{ + InitLineWidth(); } +// reimplemented from QApplication so we can throw exceptions in slots bool VApplication::notify(QObject *receiver, QEvent *event) { try @@ -157,13 +160,41 @@ QString VApplication::pathToTables() const QString VApplication::translationsPath() const { - #ifdef Q_OS_WIN - return QApplication::applicationDirPath() + QStringLiteral("/translations"); - #else - #ifdef QT_DEBUG - return QApplication::applicationDirPath() + QStringLiteral("/translations"); +#ifdef Q_OS_WIN + return QApplication::applicationDirPath() + QStringLiteral("/translations"); +#else +#ifdef QT_DEBUG + return QApplication::applicationDirPath() + QStringLiteral("/translations"); #else return QStringLiteral("/usr/share/valentina/translations"); #endif #endif } + + +void VApplication::InitLineWidth() +{ + switch(_patternUnit) + { + case Valentina::Mm: + _widthMainLine = DefWidth; + break; + case Valentina::Cm: + _widthMainLine = DefWidth/10.0; + break; + case Valentina::Inch: + _widthMainLine = DefWidth/25.4; + break; + default: + _widthMainLine = DefWidth; + break; + } + _widthHairLine = _widthMainLine/3.0; +} + + +void VApplication::setPatternUnit(const Valentina::Units &patternUnit) +{ + _patternUnit = patternUnit; + InitLineWidth(); +} diff --git a/src/widgets/vapplication.h b/src/widgets/vapplication.h index 6d3b63eae..c6a3ff14f 100644 --- a/src/widgets/vapplication.h +++ b/src/widgets/vapplication.h @@ -59,19 +59,24 @@ public: * @param event event. * @return value that is returned from the receiver's event handler. */ - virtual bool notify(QObject * receiver, QEvent * event); - Valentina::Units patternUnit() const; - void setPatternUnit(const Valentina::Units &patternUnit); + virtual bool notify(QObject * receiver, QEvent * event); + Valentina::Units patternUnit() const; + void setPatternUnit(const Valentina::Units &patternUnit); Pattern::Measurements patternType() const; - void setPatternType(const Pattern::Measurements &patternType); - double toPixel(double unit) const; - double fromPixel(double pix) const; - static const qreal PrintDPI; - QString translationsPath() const; - QString pathToTables() const; + void setPatternType(const Pattern::Measurements &patternType); + double toPixel(double unit) const; + double fromPixel(double pix) const; + static const qreal PrintDPI; + QString translationsPath() const; + QString pathToTables() const; + qreal widthMainLine() const; + qreal widthHairLine() const; private: - Valentina::Units _patternUnit; + Valentina::Units _patternUnit; Pattern::Measurements _patternType; + qreal _widthMainLine; + qreal _widthHairLine; + void InitLineWidth(); }; inline Valentina::Units VApplication::patternUnit() const @@ -79,11 +84,6 @@ inline Valentina::Units VApplication::patternUnit() const return _patternUnit; } -inline void VApplication::setPatternUnit(const Valentina::Units &patternUnit) -{ - _patternUnit = patternUnit; -} - inline Pattern::Measurements VApplication::patternType() const { return _patternType; @@ -94,5 +94,14 @@ inline void VApplication::setPatternType(const Pattern::Measurements &patternTyp _patternType = patternType; } +inline qreal VApplication::widthMainLine() const +{ + return _widthMainLine; +} + +inline qreal VApplication::widthHairLine() const +{ + return _widthHairLine; +} #endif // VAPPLICATION_H diff --git a/src/widgets/vcontrolpointspline.cpp b/src/widgets/vcontrolpointspline.cpp index 2db37ee54..9f850ff44 100644 --- a/src/widgets/vcontrolpointspline.cpp +++ b/src/widgets/vcontrolpointspline.cpp @@ -42,7 +42,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint: QRectF rec = QRectF(0, 0, radius*2, radius*2); rec.translate(-rec.center().x(), -rec.center().y()); this->setRect(rec); - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine))); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); this->setBrush(QBrush(Qt::NoBrush)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true); @@ -53,20 +53,20 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint: QPointF p1, p2; VAbstractTool::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2); controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this); - controlLine->setPen(QPen(Qt::red, qApp->toPixel(widthHairLine))); + controlLine->setPen(QPen(Qt::red, qApp->toPixel(qApp->widthHairLine()))); controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); } void VControlPointSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine))); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); } void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine))); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); } QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) @@ -95,14 +95,14 @@ void VControlPointSpline::setEnabledPoint(bool enable) { if (enable == true) { - this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine))); + this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setAcceptHoverEvents(true); } else { - this->setPen(QPen(Qt::gray, qApp->toPixel(widthHairLine))); + this->setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine()))); this->setFlag(QGraphicsItem::ItemIsSelectable, false); this->setFlag(QGraphicsItem::ItemIsMovable, false); this->setAcceptHoverEvents(false); diff --git a/src/widgets/vitem.cpp b/src/widgets/vitem.cpp index 5ef3d68da..698a1e1f2 100644 --- a/src/widgets/vitem.cpp +++ b/src/widgets/vitem.cpp @@ -63,19 +63,19 @@ void VItem::checkItemChange() QRectF myrect = sceneBoundingRect(); if ( rect.contains( myrect )==true ) { - setPen(QPen(Qt::black, qApp->toPixel(widthMainLine))); + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()))); emit itemOut( numInOutList, false ); } else { - setPen(QPen(Qt::red, qApp->toPixel(widthMainLine))); + setPen(QPen(Qt::red, qApp->toPixel(qApp->widthMainLine()))); emit itemOut( numInOutList, true ); } QList list = QGraphicsItem::collidingItems (); if ( list.size() - 2 > 0 ) { list.append( this ); - setPen(QPen(Qt::red, qApp->toPixel(widthMainLine))); + setPen(QPen(Qt::red, qApp->toPixel(qApp->widthMainLine()))); emit itemColliding( list, 1 );//Detail intersect with other details. } else diff --git a/src/widgets/vsimplearc.cpp b/src/widgets/vsimplearc.cpp index 68cb158e9..a734fea9a 100644 --- a/src/widgets/vsimplearc.cpp +++ b/src/widgets/vsimplearc.cpp @@ -34,11 +34,11 @@ VSimpleArc::VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, { if (factor == nullptr) { - setPen(QPen(Qt::black, qApp->toPixel(widthHairLine))); + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); } else { - setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/ *factor)); + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/ *factor)); } setFlag(QGraphicsItem::ItemIsSelectable, true); setAcceptHoverEvents(true); @@ -58,11 +58,11 @@ void VSimpleArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == nullptr) { - this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine))); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine()))); } else { - this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine)/ *factor)); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine())/ *factor)); } } @@ -71,10 +71,10 @@ void VSimpleArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == nullptr) { - this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine()))); } else { - this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)/ *factor)); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); } } diff --git a/src/widgets/vsimplespline.cpp b/src/widgets/vsimplespline.cpp index d3786517d..fb0d54e10 100644 --- a/src/widgets/vsimplespline.cpp +++ b/src/widgets/vsimplespline.cpp @@ -34,11 +34,11 @@ VSimpleSpline::VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *f { if (factor == nullptr) { - setPen(QPen(Qt::black, qApp->toPixel(widthHairLine))); + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); } else { - setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/ *factor)); + setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/ *factor)); } setFlag(QGraphicsItem::ItemIsSelectable, true); setAcceptHoverEvents(true); @@ -48,7 +48,7 @@ void VSimpleSpline::ChangedActivDraw(const bool &flag) { setFlag(QGraphicsItem::ItemIsSelectable, flag); setAcceptHoverEvents(flag); - setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)/ *factor)); + setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); } void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) @@ -65,11 +65,11 @@ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == nullptr) { - this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine))); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine()))); } else { - this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine)/ *factor)); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine())/ *factor)); } } @@ -78,10 +78,10 @@ void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == nullptr) { - this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine))); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine()))); } else { - this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)/ *factor)); + this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); } } diff --git a/src/widgets/vsimplesplinepath.cpp b/src/widgets/vsimplesplinepath.cpp index ccd0021d5..c247823a9 100644 --- a/src/widgets/vsimplesplinepath.cpp +++ b/src/widgets/vsimplesplinepath.cpp @@ -46,11 +46,11 @@ void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/ *factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/ *factor)); } void VSimpleSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/ *factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); } diff --git a/src/xml/vindividualmeasurements.cpp b/src/xml/vindividualmeasurements.cpp index 28f870602..867099140 100644 --- a/src/xml/vindividualmeasurements.cpp +++ b/src/xml/vindividualmeasurements.cpp @@ -28,28 +28,58 @@ #include "vindividualmeasurements.h" -const QString VIndividualMeasurements::AttrIgnore = QStringLiteral("ignore"); -const QString VIndividualMeasurements::AttrName = QStringLiteral("name"); -const QString VIndividualMeasurements::AttrM_number = QStringLiteral("m_number"); -const QString VIndividualMeasurements::AttrGui_text = QStringLiteral("gui_text"); -const QString VIndividualMeasurements::AttrValue = QStringLiteral("value"); +const QString VIndividualMeasurements::AttrIgnore = QStringLiteral("ignore"); +const QString VIndividualMeasurements::AttrName = QStringLiteral("name"); +const QString VIndividualMeasurements::AttrM_number = QStringLiteral("m_number"); +const QString VIndividualMeasurements::AttrGui_text = QStringLiteral("gui_text"); +const QString VIndividualMeasurements::AttrValue = QStringLiteral("value"); const QString VIndividualMeasurements::AttrDescription = QStringLiteral("description"); -const QString VIndividualMeasurements::AttrLang = QStringLiteral("lang"); -const QString VIndividualMeasurements::AttrFamily_name = QStringLiteral("family-name"); -const QString VIndividualMeasurements::AttrGiven_name = QStringLiteral("given-name"); -const QString VIndividualMeasurements::AttrBirth_date = QStringLiteral("birth-date"); -const QString VIndividualMeasurements::AttrSex = QStringLiteral("sex"); + +const QString VIndividualMeasurements::TagLang = QStringLiteral("lang"); +const QString VIndividualMeasurements::TagFamily_name = QStringLiteral("family-name"); +const QString VIndividualMeasurements::TagGiven_name = QStringLiteral("given-name"); +const QString VIndividualMeasurements::TagBirth_date = QStringLiteral("birth-date"); +const QString VIndividualMeasurements::TagSex = QStringLiteral("sex"); +const QString VIndividualMeasurements::TagUnit = QStringLiteral("unit"); VIndividualMeasurements::VIndividualMeasurements(VContainer *data):VDomDocument(data) { } -Valentina::Units VIndividualMeasurements::Unit() +Valentina::Units VIndividualMeasurements::Unit() const { - const QString unit = UniqueTagText(AttrUnit, UnitCM); + const QString unit = UniqueTagText(TagUnit, UnitCM); return VDomDocument::StrToUnits(unit); } +void VIndividualMeasurements::setUnit(const Valentina::Units &unit) +{ + const QDomNodeList nodeList = this->elementsByTagName(AttrUnit); + if (nodeList.isEmpty()) + { + qWarning()<<"Can't save measurements units"<