diff --git a/src/app/dialogs/app/configpages/configurationpage.cpp b/src/app/dialogs/app/configpages/configurationpage.cpp index 6c91267d1..46bddce59 100644 --- a/src/app/dialogs/app/configpages/configurationpage.cpp +++ b/src/app/dialogs/app/configpages/configurationpage.cpp @@ -43,8 +43,8 @@ //--------------------------------------------------------------------------------------------------------------------- ConfigurationPage::ConfigurationPage(QWidget *parent) - : QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), unitCombo(nullptr), - osOptionCheck(nullptr), langChanged(false), unitChanged(false) + : QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), labelCombo(nullptr), + unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), unitChanged(false), labelLangChanged(false) { QGroupBox *saveGroup = SaveGroup(); QGroupBox *langGroup = LangGroup(); @@ -93,6 +93,12 @@ void ConfigurationPage::Apply() QString text = QString(tr("Default unit updated and will be used the next pattern creation")); QMessageBox::information(this, QApplication::applicationName(), text); } + if (labelLangChanged) + { + QString locale = qvariant_cast(labelCombo->itemData(labelCombo->currentIndex())); + qApp->getSettings()->setValue("configuration/label_language", locale); + labelLangChanged = false; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -107,6 +113,12 @@ void ConfigurationPage::UnitChanged() this->unitChanged = true; } +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::LabelLangChanged() +{ + labelLangChanged = true; +} + //--------------------------------------------------------------------------------------------------------------------- QGroupBox *ConfigurationPage::SaveGroup() { @@ -227,13 +239,47 @@ QGroupBox *ConfigurationPage::LangGroup() UnitLayout->addWidget(unitLabel); UnitLayout->addWidget(this->unitCombo); - //----------------------- Unit setup + //----------------------- Label language + + QLabel *labelName = new QLabel(tr("Label language")); + labelCombo = new QComboBox; + + QString checkedLabelLocale = settings->value("configuration/label_language", defaultLocale).toString(); + + QStringList list{"de", "en" , "fr" , "ru" , "uk"}; + SetLabelComboBox(list); + + index = labelCombo->findData(checkedLabelLocale); + if (index != -1) + { + labelCombo->setCurrentIndex(index); + } + connect(labelCombo, static_cast(&QComboBox::currentIndexChanged), this, + &ConfigurationPage::LabelLangChanged); + + QHBoxLayout *labelLangLayout = new QHBoxLayout; + labelLangLayout->addWidget(labelName); + labelLangLayout->addWidget(labelCombo); + + //----------------------- QVBoxLayout *langLayout = new QVBoxLayout; langLayout->addLayout(guiLangLayout); langLayout->addLayout(separatorLayout); langLayout->addLayout(UnitLayout); + langLayout->addLayout(labelLangLayout); langGroup->setLayout(langLayout); return langGroup; } + +//--------------------------------------------------------------------------------------------------------------------- +void ConfigurationPage::SetLabelComboBox(const QStringList &list) +{ + for (int i = 0; i < list.size(); ++i) + { + QString lang = QLocale(list.at(i)).nativeLanguageName(); + QIcon ico(QString("%1/%2.png").arg("://icon/flags").arg(list.at(i))); + labelCombo->addItem(ico, lang, list.at(i)); + } +} diff --git a/src/app/dialogs/app/configpages/configurationpage.h b/src/app/dialogs/app/configpages/configurationpage.h index 9e32fee0e..0bad4043c 100644 --- a/src/app/dialogs/app/configpages/configurationpage.h +++ b/src/app/dialogs/app/configpages/configurationpage.h @@ -46,17 +46,22 @@ public: public slots: void LangChanged(); void UnitChanged(); + void LabelLangChanged(); private: Q_DISABLE_COPY(ConfigurationPage) QCheckBox *autoSaveCheck; QSpinBox *autoTime; QComboBox *langCombo; + QComboBox *labelCombo; QComboBox *unitCombo; QCheckBox *osOptionCheck; bool langChanged; bool unitChanged; + bool labelLangChanged; + QGroupBox *SaveGroup(); QGroupBox *LangGroup(); + void SetLabelComboBox(const QStringList &list); }; #endif // CONFIGURATIONPAGE_H diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index c2b67d9bb..90eaa2119 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -48,12 +48,13 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxFirstPoint); diff --git a/src/app/dialogs/tools/dialogalongline.ui b/src/app/dialogs/tools/dialogalongline.ui index 37da60097..7fea4abba 100644 --- a/src/app/dialogs/tools/dialogalongline.ui +++ b/src/app/dialogs/tools/dialogalongline.ui @@ -220,43 +220,6 @@ - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 2526aa7d4..edc00b560 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -49,12 +49,12 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxFirstPoint); diff --git a/src/app/dialogs/tools/dialogbisector.ui b/src/app/dialogs/tools/dialogbisector.ui index 0172c1140..e004708ac 100644 --- a/src/app/dialogs/tools/dialogbisector.ui +++ b/src/app/dialogs/tools/dialogbisector.ui @@ -217,43 +217,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index 599960f14..e681290de 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -33,6 +33,7 @@ #include "../../container/vcontainer.h" #include "../../visualization/vistoolcutarc.h" #include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -47,12 +48,12 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxArcs(ui->comboBoxArc); diff --git a/src/app/dialogs/tools/dialogcutarc.ui b/src/app/dialogs/tools/dialogcutarc.ui index 7efe094bc..f13d05840 100644 --- a/src/app/dialogs/tools/dialogcutarc.ui +++ b/src/app/dialogs/tools/dialogcutarc.ui @@ -238,43 +238,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index 985c1d512..13cd130c3 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -31,6 +31,7 @@ #include "../../geometry/vspline.h" #include "../../container/vcontainer.h" +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -45,12 +46,12 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancel(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxSplines(ui->comboBoxSpline); diff --git a/src/app/dialogs/tools/dialogcutspline.ui b/src/app/dialogs/tools/dialogcutspline.ui index ea8f6e9b9..4e474569d 100644 --- a/src/app/dialogs/tools/dialogcutspline.ui +++ b/src/app/dialogs/tools/dialogcutspline.ui @@ -238,43 +238,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index 7448318a9..2d4acf4ae 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -31,6 +31,7 @@ #include "../../geometry/vsplinepath.h" #include "../../container/vcontainer.h" +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -45,12 +46,12 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 & ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancel(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxSplinesPath(ui->comboBoxSplinePath); diff --git a/src/app/dialogs/tools/dialogcutsplinepath.ui b/src/app/dialogs/tools/dialogcutsplinepath.ui index 881de2939..3a1cb2a0f 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.ui +++ b/src/app/dialogs/tools/dialogcutsplinepath.ui @@ -238,43 +238,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index f1bc2253e..a6e281666 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -49,13 +49,13 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeightAngle = ui->plainTextEditAngle->height(); InitOkCancelApply(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxBasePoint); diff --git a/src/app/dialogs/tools/dialogendline.ui b/src/app/dialogs/tools/dialogendline.ui index 49b0313da..cdee81112 100644 --- a/src/app/dialogs/tools/dialogendline.ui +++ b/src/app/dialogs/tools/dialogendline.ui @@ -423,43 +423,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index 5fb40d6b1..aa09f8012 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -46,9 +46,9 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr) { ui->setupUi(this); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; InitOkCancelApply(ui); - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxBasePoint); diff --git a/src/app/dialogs/tools/dialogheight.ui b/src/app/dialogs/tools/dialogheight.ui index 006e1817b..5acad9cd7 100644 --- a/src/app/dialogs/tools/dialogheight.ui +++ b/src/app/dialogs/tools/dialogheight.ui @@ -31,43 +31,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 674eb5ac9..7b6ca9fed 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -33,6 +33,7 @@ #include "../../container/vcontainer.h" #include "../../visualization/vistoollineintersect.h" #include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -47,8 +48,8 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 & ui->setupUi(this); number = 0; InitOkCancelApply(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; - flagName = false; FillComboBoxPoints(ui->comboBoxP1Line1); FillComboBoxPoints(ui->comboBoxP2Line1); diff --git a/src/app/dialogs/tools/dialoglineintersect.ui b/src/app/dialogs/tools/dialoglineintersect.ui index 96d2bc764..53e5d3f89 100644 --- a/src/app/dialogs/tools/dialoglineintersect.ui +++ b/src/app/dialogs/tools/dialoglineintersect.ui @@ -31,43 +31,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index 72122f60f..e28916508 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -45,12 +45,12 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxFirstPoint); diff --git a/src/app/dialogs/tools/dialognormal.ui b/src/app/dialogs/tools/dialognormal.ui index 4ec34e02b..6ea7bf7f6 100644 --- a/src/app/dialogs/tools/dialognormal.ui +++ b/src/app/dialogs/tools/dialognormal.ui @@ -220,43 +220,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index 207306b3c..6d39c8fac 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -32,6 +32,7 @@ #include "../../container/vcontainer.h" #include "../../visualization/vistoolpointofcontact.h" #include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -46,12 +47,12 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxFirstPoint); diff --git a/src/app/dialogs/tools/dialogpointofcontact.ui b/src/app/dialogs/tools/dialogpointofcontact.ui index 30ed3122d..8098355be 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.ui +++ b/src/app/dialogs/tools/dialogpointofcontact.ui @@ -220,43 +220,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index 4dd2c5bd9..b38cc5884 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -33,6 +33,7 @@ #include "../../container/vcontainer.h" #include "../../visualization/vistoolpointofintersection.h" #include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -45,10 +46,10 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, con firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr) { ui->setupUi(this); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; InitOkCancelApply(ui); - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxFirstPoint); diff --git a/src/app/dialogs/tools/dialogpointofintersection.ui b/src/app/dialogs/tools/dialogpointofintersection.ui index db3a4c052..f31727a7c 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.ui +++ b/src/app/dialogs/tools/dialogpointofintersection.ui @@ -28,43 +28,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 2fbaf4b69..9ae01db84 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -49,12 +49,12 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 & ui->setupUi(this); InitVariables(ui); InitFormulaUI(ui); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; - flagName = false; CheckState(); FillComboBoxTypeLine(ui->comboBoxLineType); diff --git a/src/app/dialogs/tools/dialogshoulderpoint.ui b/src/app/dialogs/tools/dialogshoulderpoint.ui index 2696419e7..1325d9919 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.ui +++ b/src/app/dialogs/tools/dialogshoulderpoint.ui @@ -220,43 +220,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogsinglepoint.ui b/src/app/dialogs/tools/dialogsinglepoint.ui index 24aa830f2..aa0bcbc91 100644 --- a/src/app/dialogs/tools/dialogsinglepoint.ui +++ b/src/app/dialogs/tools/dialogsinglepoint.ui @@ -73,43 +73,6 @@ 17 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index a4e4f0112..fb8a8f5b5 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -32,6 +32,7 @@ #include "../../container/vcontainer.h" #include "../../visualization/vistooltriangle.h" #include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -44,10 +45,10 @@ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QW axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr) { ui->setupUi(this); + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; InitOkCancelApply(ui); - flagName = false; CheckState(); FillComboBoxPoints(ui->comboBoxAxisP1); diff --git a/src/app/dialogs/tools/dialogtriangle.ui b/src/app/dialogs/tools/dialogtriangle.ui index 4ac997de3..b743f48f3 100644 --- a/src/app/dialogs/tools/dialogtriangle.ui +++ b/src/app/dialogs/tools/dialogtriangle.ui @@ -31,43 +31,6 @@ 0 - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - Point label diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 3be346f08..bd4121e9e 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -105,6 +105,7 @@ MainWindow::MainWindow(QWidget *parent) connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI); connect(doc, &VPattern::CheckLayout, this, &MainWindow::Layout); + qApp->setCurrentDocument(doc); connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified); @@ -194,7 +195,8 @@ void MainWindow::ActionNewPP() pattern->ClearGObjects(); //Create single point - const quint32 id = pattern->AddGObject(new VPointF(20+comboBoxDraws->count()*5, 20, "А", 5, 10)); + QString label = doc->GenerateLabel(LabelType::NewPatternPiece); + const quint32 id = pattern->AddGObject(new VPointF(30+comboBoxDraws->count()*5, 40, label, 5, 10)); VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Source::FromGui, patternPieceName, path); sceneDraw->addItem(spoint); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); diff --git a/src/app/widgets/vapplication.cpp b/src/app/widgets/vapplication.cpp index ecd8e5c0f..f7399e2d8 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/widgets/vapplication.cpp @@ -58,7 +58,7 @@ VApplication::VApplication(int &argc, char **argv) guiTexts(QMap()), descriptions(QMap()), variables(QMap()), functions(QMap()), postfixOperators(QMap()), undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), - autoSaveTimer(nullptr), mainWindow(nullptr), openingPattern(false), settings(nullptr) + autoSaveTimer(nullptr), mainWindow(nullptr), openingPattern(false), settings(nullptr), doc(nullptr) { undoStack = new QUndoStack(this); diff --git a/src/app/widgets/vapplication.h b/src/app/widgets/vapplication.h index 8cdbb5e11..a80b72fe5 100644 --- a/src/app/widgets/vapplication.h +++ b/src/app/widgets/vapplication.h @@ -38,6 +38,7 @@ class VApplication;// used in define class QUndoStack; class VMainGraphicsView; class VMainGraphicsScene; +class VPattern; #if defined(qApp) #undef qApp @@ -91,6 +92,9 @@ public: QSettings *getSettings(); VMainGraphicsScene *getCurrentScene() const; void setCurrentScene(VMainGraphicsScene *value); + + void setCurrentDocument(VPattern *doc); + VPattern *getCurrentDocument()const; private: Q_DISABLE_COPY(VApplication) Unit _patternUnit; @@ -121,6 +125,8 @@ private: * @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable. */ QSettings *settings; + + VPattern *doc; void InitLineWidth(); void InitMeasurements(); void InitVariables(); @@ -197,4 +203,17 @@ inline void VApplication::setAutoSaveTimer(QTimer *value) autoSaveTimer = value; } +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setCurrentDocument(VPattern *doc) +{ + this->doc = doc; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VPattern *VApplication::getCurrentDocument() const +{ + SCASSERT(doc != nullptr) + return doc; +} + #endif // VAPPLICATION_H diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index bbab2102d..f0fb41f94 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -45,6 +45,7 @@ #include #include +#include const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagCalculation = QStringLiteral("calculation"); @@ -1619,6 +1620,68 @@ void VPattern::CheckTagExists(const QString &tag) } } +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GetLabelBase(unsigned int index) const +{ + QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" + defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de" + QString checkedLocale = qApp->getSettings()->value("configuration/label_language", defaultLocale).toString(); + + QStringList list{"de", "en" , "fr" , "ru" , "uk"}; + + QStringList alphabet; + switch(list.indexOf(checkedLocale)) + { + case 0: // de + { + QString al = QStringLiteral("A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,ß,T,U,Ü,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + case 1: // en + { + QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + case 2: // fr + { + QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + case 3: // ru + { + QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,И,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Э,Ю,Я"); + alphabet = al.split(","); + break; + } + case 4: // uk + { + QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Є,Ю,Я"); + alphabet = al.split(","); + break; + } + default: // en + { + QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); + alphabet = al.split(","); + break; + } + } + + QString base; + int count = qFloor(index/alphabet.size()); + int number = index - alphabet.size() * count; + int i = 0; + do + { + base.append(alphabet.at(number)); + ++i; + } while (i < count); + return base; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ParseSplineElement parse spline tag. @@ -2280,6 +2343,66 @@ void VPattern::SetVersion() emit patternChanged(false); } +//--------------------------------------------------------------------------------------------------------------------- +QString VPattern::GenerateLabel(const LabelType &type) const +{ + QDomNodeList drawList = elementsByTagName(TagDraw); + + if (type == LabelType::NewPatternPiece) + { + QString name; + int i = 0; + for(;;) + { + name = GetLabelBase(drawList.size() + i); + if (data->IsUnique(name)) + { + return name; + } + if (i == INT_MAX) + { + break; + } + ++i; + } + return name; + } + else if (type == LabelType::NewLabel) + { + if (drawList.isEmpty()) + { + return GetLabelBase(0); + } + + int index = 0; + for (int i = 0; i < drawList.size(); ++i) + { + QDomElement node = drawList.at(i).toElement(); + if (node.attribute(AttrName) == nameActivPP) + { + index = i; + break; + } + } + + QString labelBase = GetLabelBase(index); + + qint32 num = 1; + QString name; + do + { + name = QString("%1%2").arg(labelBase).arg(num); + num++; + if (num == INT_MAX) + { + break; + } + } while (data->IsUnique(name) == false); + return name; + } + return QString(); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique. diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 1a264244c..d2e76a447 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -36,6 +36,7 @@ class VDataTool; class VMainGraphicsScene; enum class Document : char { LiteParse, LitePPParse, FullParse }; +enum class LabelType : char {NewPatternPiece, NewLabel}; /* VAL_VERSION is (major << 16) + (minor << 8) + patch. @@ -179,6 +180,8 @@ public: QString GetVersion() const; void SetVersion(); + + QString GenerateLabel(const LabelType &type)const; signals: /** * @brief ChangedActivDraw change active pattern peace. @@ -280,6 +283,7 @@ private: QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const; void ParseCurrentPP(); void CheckTagExists(const QString &tag); + QString GetLabelBase(unsigned int index)const; }; //---------------------------------------------------------------------------------------------------------------------