From 2bb95154cd04d6b8ef9000168b432840ca091732 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 6 Feb 2021 15:52:21 +0200 Subject: [PATCH] Fix Tape crash. --- .../tapepreferencesconfigurationpage.cpp | 25 +- .../configpages/tapepreferencespathpage.cpp | 14 +- src/app/tape/dialogs/dialogmdatabase.cpp | 18 +- .../tape/dialogs/dialogtapepreferences.cpp | 8 +- src/app/tape/mapplication.cpp | 14 +- src/app/tape/mapplication.h | 7 +- src/app/tape/tape.pro | 20 +- src/app/tape/tmainwindow.cpp | 170 +++---- src/app/valentina/core/vapplication.cpp | 20 +- src/app/valentina/core/vapplication.h | 7 +- src/app/valentina/core/vformulaproperty.cpp | 2 +- .../valentina/core/vformulapropertyeditor.cpp | 6 +- .../core/vtooloptionspropertybrowser.cpp | 22 +- .../preferencesconfigurationpage.cpp | 25 +- .../configpages/preferencespathpage.cpp | 18 +- .../configpages/preferencespatternpage.cpp | 19 +- src/app/valentina/dialogs/dialogaboutapp.cpp | 3 +- .../dialogs/dialogfinalmeasurements.cpp | 45 +- src/app/valentina/dialogs/dialoghistory.cpp | 2 +- .../valentina/dialogs/dialogincrements.cpp | 48 +- .../dialogs/dialoglayoutprogress.cpp | 3 +- .../dialogs/dialoglayoutsettings.cpp | 17 +- .../valentina/dialogs/dialognewpattern.cpp | 6 +- .../dialogs/dialogpatternproperties.cpp | 17 +- .../valentina/dialogs/dialogpreferences.cpp | 9 +- .../valentina/dialogs/dialogsavelayout.cpp | 22 +- src/app/valentina/dialogs/vwidgetdetails.cpp | 18 +- src/app/valentina/dialogs/vwidgetgroups.cpp | 13 +- src/app/valentina/mainwindow.cpp | 425 +++++++++--------- src/app/valentina/mainwindowsnogui.cpp | 73 +-- src/app/valentina/valentina.pro | 20 +- src/app/valentina/watermarkwindow.cpp | 19 +- src/app/valentina/xml/vpattern.cpp | 72 +-- src/libs/fervor/fvupdater.cpp | 10 +- src/libs/ifc/xml/vabstractpattern.cpp | 6 +- src/libs/vdxf/dxiface.cpp | 3 +- .../vdxf/libdxfrw/intern/drw_textcodec.cpp | 4 +- src/libs/vformat/vpatternrecipe.cpp | 15 +- src/libs/vgeometry/vabstractcubicbezier.cpp | 2 +- src/libs/vgeometry/vabstractcurve.cpp | 6 +- src/libs/vgeometry/varc_p.h | 2 +- src/libs/vgeometry/vellipticalarc.cpp | 2 +- src/libs/vgeometry/vellipticalarc_p.h | 6 +- src/libs/vgeometry/vgobject.cpp | 4 +- src/libs/vgeometry/vspline_p.h | 8 +- .../vlayout/dialogs/dialoglayoutscale.cpp | 14 +- src/libs/vlayout/vabstractpiece.cpp | 4 +- src/libs/vlayout/vbank.cpp | 4 +- src/libs/vlayout/vlayoutpiece.cpp | 54 +-- src/libs/vlayout/vposter.cpp | 10 +- src/libs/vlayout/vprintlayout.cpp | 7 +- src/libs/vlayout/vtextmanager.cpp | 42 +- src/libs/vmisc/def.cpp | 5 +- src/libs/vmisc/dialogs/dialogexporttocsv.cpp | 2 +- src/libs/vmisc/testvapplication.h | 10 +- src/libs/vmisc/vabstractapplication.cpp | 6 + src/libs/vmisc/vabstractapplication.h | 9 +- src/libs/vmisc/vabstractvalapplication.cpp | 8 +- src/libs/vmisc/vabstractvalapplication.h | 7 +- src/libs/vpatterndb/calculator.cpp | 6 +- src/libs/vpatterndb/pmsystems.cpp | 5 +- src/libs/vpatterndb/vformula.cpp | 7 +- src/libs/vpatterndb/vpassmark.cpp | 42 +- src/libs/vpatterndb/vpiece.cpp | 12 +- src/libs/vpatterndb/vpiecenode.cpp | 20 +- src/libs/vpatterndb/vpiecepath.cpp | 8 +- .../vpatterndb/vtranslatemeasurements.cpp | 10 +- src/libs/vpatterndb/vtranslatevars.cpp | 47 +- src/libs/vtools/dialogs/dialogtoolbox.cpp | 9 +- .../dialogs/support/dialogeditlabel.cpp | 59 ++- .../support/dialogeditwrongformula.cpp | 114 +++-- .../dialogs/support/dialogeditwrongformula.h | 31 +- .../vtools/dialogs/support/dialogundo.cpp | 4 +- .../vtools/dialogs/tools/dialogalongline.cpp | 13 +- src/libs/vtools/dialogs/tools/dialogarc.cpp | 22 +- .../dialogs/tools/dialogarcwithlength.cpp | 26 +- .../vtools/dialogs/tools/dialogbisector.cpp | 13 +- .../dialogs/tools/dialogcubicbezier.cpp | 6 +- .../dialogs/tools/dialogcubicbezierpath.cpp | 9 +- .../tools/dialogcurveintersectaxis.cpp | 17 +- .../vtools/dialogs/tools/dialogcutarc.cpp | 13 +- .../vtools/dialogs/tools/dialogcutspline.cpp | 13 +- .../dialogs/tools/dialogcutsplinepath.cpp | 13 +- .../dialogs/tools/dialogellipticalarc.cpp | 36 +- .../vtools/dialogs/tools/dialogendline.cpp | 27 +- .../dialogs/tools/dialogflippingbyaxis.cpp | 7 +- .../dialogs/tools/dialogflippingbyline.cpp | 7 +- .../vtools/dialogs/tools/dialogheight.cpp | 3 +- .../dialogs/tools/dialoglineintersect.cpp | 3 +- .../dialogs/tools/dialoglineintersectaxis.cpp | 17 +- src/libs/vtools/dialogs/tools/dialogmove.cpp | 44 +- .../vtools/dialogs/tools/dialognormal.cpp | 13 +- .../tools/dialogpointfromarcandtangent.cpp | 3 +- .../tools/dialogpointfromcircleandtangent.cpp | 15 +- .../dialogs/tools/dialogpointofcontact.cpp | 13 +- .../tools/dialogpointofintersection.cpp | 3 +- .../tools/dialogpointofintersectionarcs.cpp | 3 +- .../dialogpointofintersectioncircles.cpp | 27 +- .../tools/dialogpointofintersectioncurves.cpp | 2 +- .../vtools/dialogs/tools/dialogrotation.cpp | 21 +- .../dialogs/tools/dialogshoulderpoint.cpp | 13 +- .../dialogs/tools/dialogsinglepoint.cpp | 19 +- .../vtools/dialogs/tools/dialogspline.cpp | 96 ++-- .../vtools/dialogs/tools/dialogsplinepath.cpp | 105 +++-- src/libs/vtools/dialogs/tools/dialogtool.h | 5 +- .../vtools/dialogs/tools/dialogtriangle.cpp | 3 +- .../vtools/dialogs/tools/dialogtruedarts.cpp | 5 +- .../tools/piece/dialogpatternmaterials.cpp | 2 +- .../dialogs/tools/piece/dialogpiecepath.cpp | 74 +-- .../dialogs/tools/piece/dialogplacelabel.cpp | 44 +- .../tools/piece/dialogseamallowance.cpp | 159 ++++--- .../flipping/vtoolflippingbyaxis.cpp | 4 +- .../flipping/vtoolflippingbyline.cpp | 4 +- .../operation/vabstractoperation.cpp | 42 +- .../tools/drawTools/operation/vtoolmove.cpp | 22 +- .../drawTools/operation/vtoolrotation.cpp | 7 +- .../drawTools/toolcurve/vabstractspline.cpp | 13 +- .../drawTools/toolcurve/vabstractspline.h | 2 +- .../tools/drawTools/toolcurve/vtoolarc.cpp | 21 +- .../toolcurve/vtoolarcwithlength.cpp | 25 +- .../toolcurve/vtoolellipticalarc.cpp | 32 +- .../tools/drawTools/toolcurve/vtoolspline.cpp | 28 +- .../drawTools/toolcurve/vtoolsplinepath.cpp | 28 +- .../tooldoublepoint/vtooldoublepoint.cpp | 28 +- .../toolsinglepoint/toolcut/vtoolcut.cpp | 4 +- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 17 +- .../toolcut/vtoolcutspline.cpp | 17 +- .../toolcut/vtoolcutsplinepath.cpp | 19 +- .../toollinepoint/vtoolalongline.cpp | 12 +- .../toollinepoint/vtoolbisector.cpp | 6 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 7 +- .../toollinepoint/vtoolendline.cpp | 9 +- .../toollinepoint/vtoolheight.cpp | 8 +- .../toollinepoint/vtoollineintersectaxis.cpp | 15 +- .../toollinepoint/vtoollinepoint.cpp | 6 +- .../toollinepoint/vtoolnormal.cpp | 5 +- .../toollinepoint/vtoolshoulderpoint.cpp | 12 +- .../toolsinglepoint/vtoolbasepoint.cpp | 22 +- .../toolsinglepoint/vtoollineintersect.cpp | 15 +- .../vtoolpointfromarcandtangent.cpp | 4 +- .../vtoolpointfromcircleandtangent.cpp | 9 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 25 +- .../vtoolpointofintersectionarcs.cpp | 4 +- .../vtoolpointofintersectioncircles.cpp | 14 +- .../vtoolpointofintersectioncurves.cpp | 4 +- .../toolsinglepoint/vtoolsinglepoint.cpp | 12 +- .../toolsinglepoint/vtooltriangle.cpp | 4 +- src/libs/vtools/tools/drawTools/vdrawtool.cpp | 6 +- src/libs/vtools/tools/drawTools/vdrawtool.h | 17 +- src/libs/vtools/tools/drawTools/vtoolline.cpp | 6 +- .../vtools/tools/nodeDetails/vnodepoint.cpp | 13 +- .../tools/nodeDetails/vtoolpiecepath.cpp | 4 +- .../vtools/tools/nodeDetails/vtoolpin.cpp | 2 +- .../tools/nodeDetails/vtoolplacelabel.cpp | 8 +- src/libs/vtools/tools/vabstracttool.cpp | 17 +- src/libs/vtools/tools/vabstracttool.h | 2 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 99 ++-- src/libs/vtools/tools/vtooluniondetails.cpp | 4 +- src/libs/vtools/undocommands/addpiece.cpp | 2 +- src/libs/vtools/undocommands/addtocalc.cpp | 10 +- .../undocommands/deletepatternpiece.cpp | 4 +- src/libs/vtools/undocommands/deletepiece.cpp | 2 +- src/libs/vtools/undocommands/deltool.cpp | 4 +- .../undocommands/label/movedoublelabel.cpp | 26 +- .../vtools/undocommands/label/movelabel.cpp | 10 +- .../undocommands/label/operationmovelabel.cpp | 10 +- .../undocommands/label/operationshowlabel.cpp | 4 +- .../undocommands/label/showdoublelabel.cpp | 4 +- .../vtools/undocommands/label/showlabel.cpp | 4 +- src/libs/vtools/undocommands/movepiece.cpp | 10 +- src/libs/vtools/undocommands/movespline.cpp | 2 +- .../vtools/undocommands/movesplinepath.cpp | 2 +- src/libs/vtools/undocommands/movespoint.cpp | 8 +- src/libs/vtools/undocommands/undogroup.cpp | 41 +- .../line/operation/visoperation.cpp | 2 +- .../line/operation/vistoolmove.cpp | 19 +- .../line/operation/vistoolrotation.cpp | 2 +- .../visualization/line/vistoolendline.cpp | 9 +- .../line/vistoolpointofintersectionarcs.cpp | 2 +- .../vistoolpointofintersectioncircles.cpp | 2 +- .../path/vispiecespecialpoints.cpp | 2 +- .../path/vistoolpointofintersectioncurves.cpp | 2 +- .../visualization/path/vistoolspline.cpp | 2 +- .../visualization/path/vistoolsplinepath.cpp | 3 +- .../vtools/visualization/visualization.cpp | 9 +- src/libs/vtools/visualization/visualization.h | 2 +- src/libs/vwidgets/global.cpp | 2 +- src/libs/vwidgets/scalesceneitems.cpp | 5 +- src/libs/vwidgets/vabstractmainwindow.cpp | 24 +- src/libs/vwidgets/vcurvepathitem.cpp | 2 +- src/libs/vwidgets/vgrainlineitem.cpp | 8 +- src/libs/vwidgets/vgraphicssimpletextitem.cpp | 10 +- src/libs/vwidgets/vmaingraphicsview.cpp | 12 +- src/libs/vwidgets/vnobrushscalepathitem.cpp | 2 +- src/libs/vwidgets/vscenepoint.cpp | 6 +- src/libs/vwidgets/vsimplecurve.cpp | 3 +- src/test/CollectionTest/CollectionTest.pro | 20 +- .../TranslationsTest/TranslationsTest.pro | 20 +- src/test/ValentinaTest/ValentinaTest.pro | 20 +- src/test/ValentinaTest/tst_vpiece.cpp | 2 +- src/test/ValentinaTest/tst_vtranslatevars.cpp | 2 +- 201 files changed, 2129 insertions(+), 1637 deletions(-) diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp index 0525e3d29..2e49a0060 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp @@ -50,29 +50,30 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare }); //-------------------- Decimal separator setup - ui->osOptionCheck->setChecked(qApp->TapeSettings()->GetOsSeparator()); + ui->osOptionCheck->setChecked(MApplication::VApp()->TapeSettings()->GetOsSeparator()); // Theme - ui->darkModeCheck->setChecked(qApp->TapeSettings()->GetDarkMode()); + ui->darkModeCheck->setChecked(MApplication::VApp()->TapeSettings()->GetDarkMode()); // Native dialogs - ui->checkBoxDontUseNativeDialog->setChecked(qApp->TapeSettings()->IsDontUseNativeDialog()); + ui->checkBoxDontUseNativeDialog->setChecked(MApplication::VApp()->TapeSettings()->IsDontUseNativeDialog()); //---------------------- Pattern making system ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing()); connect(ui->systemCombo, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() { m_systemChanged = true; - QString text = qApp->TrVars()->PMSystemAuthor(ui->systemCombo->currentData().toString()); + QString text = VAbstractApplication::VApp()->TrVars() + ->PMSystemAuthor(ui->systemCombo->currentData().toString()); ui->systemAuthorValueLabel->setText(text); ui->systemAuthorValueLabel->setToolTip(text); - text = qApp->TrVars()->PMSystemBook(ui->systemCombo->currentData().toString()); + text = VAbstractApplication::VApp()->TrVars()->PMSystemBook(ui->systemCombo->currentData().toString()); ui->systemBookValueLabel->setPlainText(text); }); // set default pattern making system - int index = ui->systemCombo->findData(qApp->TapeSettings()->GetPMSystemCode()); + int index = ui->systemCombo->findData(MApplication::VApp()->TapeSettings()->GetPMSystemCode()); if (index != -1) { ui->systemCombo->setCurrentIndex(index); @@ -81,11 +82,11 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare //----------------------------- Measurements Editing connect(ui->resetWarningsButton, &QPushButton::released, this, []() { - qApp->TapeSettings()->SetConfirmFormatRewriting(true); + MApplication::VApp()->TapeSettings()->SetConfirmFormatRewriting(true); }); //----------------------- Toolbar - ui->toolBarStyleCheck->setChecked(qApp->TapeSettings()->GetToolBarStyle()); + ui->toolBarStyleCheck->setChecked(MApplication::VApp()->TapeSettings()->GetToolBarStyle()); } //--------------------------------------------------------------------------------------------------------------------- @@ -98,7 +99,7 @@ TapePreferencesConfigurationPage::~TapePreferencesConfigurationPage() QStringList TapePreferencesConfigurationPage::Apply() { QStringList preferences; - VTapeSettings *settings = qApp->TapeSettings(); + VTapeSettings *settings = MApplication::VApp()->TapeSettings(); settings->SetOsSeparator(ui->osOptionCheck->isChecked()); settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked()); @@ -124,12 +125,12 @@ QStringList TapePreferencesConfigurationPage::Apply() settings->SetPMSystemCode(code); m_systemChanged = false; - qApp->LoadTranslation(locale); + VAbstractApplication::VApp()->LoadTranslation(locale); qApp->processEvents();// force to call changeEvent // Part about measurments will not be updated automatically - qApp->RetranslateTables(); - qApp->RetranslateGroups(); + MApplication::VApp()->RetranslateTables(); + MApplication::VApp()->RetranslateGroups(); } return preferences; diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp index 15d964d22..c40ec8b8b 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp @@ -65,7 +65,7 @@ TapePreferencesPathPage::~TapePreferencesPathPage() //--------------------------------------------------------------------------------------------------------------------- void TapePreferencesPathPage::Apply() { - VTapeSettings *settings = qApp->TapeSettings(); + VTapeSettings *settings = MApplication::VApp()->TapeSettings(); settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text()); settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text()); settings->SetPathPattern(ui->pathTable->item(2, 1)->text()); @@ -126,17 +126,17 @@ void TapePreferencesPathPage::EditPath() switch (row) { case 0: // individual measurements - path = qApp->TapeSettings()->GetPathIndividualMeasurements(); + path = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); break; case 1: // multisize measurements - path = qApp->TapeSettings()->GetPathMultisizeMeasurements(); + path = MApplication::VApp()->TapeSettings()->GetPathMultisizeMeasurements(); path = VCommonSettings::PrepareMultisizeTables(path); break; case 2: // pattern path - path = qApp->TapeSettings()->GetPathPattern(); + path = MApplication::VApp()->TapeSettings()->GetPathPattern(); break; case 3: // templates - path = qApp->TapeSettings()->GetPathTemplate(); + path = MApplication::VApp()->TapeSettings()->GetPathTemplate(); break; default: break; @@ -151,7 +151,7 @@ void TapePreferencesPathPage::EditPath() const QString dir = QFileDialog::getExistingDirectory( this, tr("Open Directory"), path, - qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); + VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); if (dir.isEmpty()) { if (usedNotExistedDir) @@ -174,7 +174,7 @@ void TapePreferencesPathPage::InitTable() ui->pathTable->setRowCount(4); ui->pathTable->setColumnCount(2); - const VTapeSettings *settings = qApp->TapeSettings(); + const VTapeSettings *settings = MApplication::VApp()->TapeSettings(); { ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); diff --git a/src/app/tape/dialogs/dialogmdatabase.cpp b/src/app/tape/dialogs/dialogmdatabase.cpp index 0d5c14c0d..d8f4e4f9a 100644 --- a/src/app/tape/dialogs/dialogmdatabase.cpp +++ b/src/app/tape/dialogs/dialogmdatabase.cpp @@ -181,7 +181,8 @@ void DialogMDataBase::RetranslateGroups() QString DialogMDataBase::ImgTag(const QString &number) { QString imgUrl(""); // In case of error - const QString filePath = QString("://diagrams/%1.svg").arg(MapDiagrams(qApp->TrVars(), number)); + const QString filePath = QString("://diagrams/%1.svg") + .arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number)); if (QFileInfo::exists(filePath)) { // Load your SVG @@ -508,7 +509,8 @@ void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name UpdateChecks(m, 0); } - const QString text = qApp->TrVars()->MNumber(name) + ". " + qApp->TrVars()->MToUser(name); + const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " + + VAbstractApplication::VApp()->TrVars()->MToUser(name); m->setText(0, text); m->setToolTip(0, text); m->setData(0, Qt::UserRole, name); @@ -517,13 +519,13 @@ void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name //--------------------------------------------------------------------------------------------------------------------- void DialogMDataBase::ReadSettings() { - restoreGeometry(qApp->TapeSettings()->GetDataBaseGeometry()); + restoreGeometry(MApplication::VApp()->TapeSettings()->GetDataBaseGeometry()); } //--------------------------------------------------------------------------------------------------------------------- void DialogMDataBase::WriteSettings() { - qApp->TapeSettings()->SetDataBaseGeometry(saveGeometry()); + MApplication::VApp()->TapeSettings()->SetDataBaseGeometry(saveGeometry()); } //--------------------------------------------------------------------------------------------------------------------- @@ -540,7 +542,7 @@ QString DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showIma return QString(); } - const QString number = qApp->TrVars()->MNumber(name); + const QString number = VAbstractApplication::VApp()->TrVars()->MNumber(name); QString imgTag; if (showImage) @@ -552,7 +554,8 @@ QString DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showIma "normal\"> %1
%2. %3

" "

%4

") - .arg(imgTag, number, qApp->TrVars()->GuiText(name), qApp->TrVars()->Description(name)); + .arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name), + VAbstractApplication::VApp()->TrVars()->Description(name)); return text; } @@ -572,7 +575,8 @@ void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &gr //--------------------------------------------------------------------------------------------------------------------- void DialogMDataBase::RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name) { - const QString text = qApp->TrVars()->MNumber(name) + ". " + qApp->TrVars()->MToUser(name); + const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " + + VAbstractApplication::VApp()->TrVars()->MToUser(name); QTreeWidgetItem *m = group->child(index); m->setText(0, text); diff --git a/src/app/tape/dialogs/dialogtapepreferences.cpp b/src/app/tape/dialogs/dialogtapepreferences.cpp index 2d2bc0f6c..11cf0e732 100644 --- a/src/app/tape/dialogs/dialogtapepreferences.cpp +++ b/src/app/tape/dialogs/dialogtapepreferences.cpp @@ -50,7 +50,7 @@ DialogTapePreferences::DialogTapePreferences(QWidget *parent) setWindowFlags(Qt::Window); #endif - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); SCASSERT(bOk != nullptr) @@ -88,7 +88,7 @@ void DialogTapePreferences::showEvent(QShowEvent *event) } // do your init stuff here - QSize sz = qApp->Settings()->GetPreferenceDialogSize(); + QSize sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize(); if (sz.isEmpty() == false) { resize(sz); @@ -106,7 +106,7 @@ void DialogTapePreferences::resizeEvent(QResizeEvent *event) // dialog creating, which would if (m_isInitialized) { - qApp->Settings()->SetPreferenceDialogSize(size()); + VAbstractApplication::VApp()->Settings()->SetPreferenceDialogSize(size()); } } @@ -137,7 +137,7 @@ void DialogTapePreferences::Apply() QMessageBox::information(this, QCoreApplication::applicationName(), text); } - qApp->TapeSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + MApplication::VApp()->TapeSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); emit UpdateProperties(); setResult(QDialog::Accepted); } diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index 82e901109..007e83305 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -151,7 +151,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con } QString logMsg = msg; - const bool isWarningMessage = qApp->IsWarningMessage(msg); + const bool isWarningMessage = VAbstractApplication::VApp()->IsWarningMessage(msg); if (isWarningMessage) { logMsg = logMsg.remove(VAbstractApplication::warningMessageSignature); @@ -219,7 +219,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) { - if (not qApp->IsTestMode()) + if (not MApplication::VApp()->IsTestMode()) { if (topWinAllowsPop) { @@ -432,7 +432,7 @@ void MApplication::InitOptions() void MApplication::ActivateDarkMode() { - VTapeSettings *settings = qApp->TapeSettings(); + VTapeSettings *settings = MApplication::VApp()->TapeSettings(); if (settings->GetDarkMode()) { QFile f(":qdarkstyle/style.qss"); @@ -839,12 +839,18 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS } } +//--------------------------------------------------------------------------------------------------------------------- +auto MApplication::VApp() -> MApplication * +{ + return qobject_cast(QCoreApplication::instance()); +} + //--------------------------------------------------------------------------------------------------------------------- TMainWindow *MApplication::NewMainWindow() { TMainWindow *tape = new TMainWindow(); mainWindows.prepend(tape); - if (not qApp->IsTestMode()) + if (not MApplication::VApp()->IsTestMode()) { tape->show(); } diff --git a/src/app/tape/mapplication.h b/src/app/tape/mapplication.h index dc8cea765..5725b6bbd 100644 --- a/src/app/tape/mapplication.h +++ b/src/app/tape/mapplication.h @@ -39,11 +39,6 @@ class MApplication;// use in define class TMainWindow; class QLocalServer; -#if defined(qApp) -#undef qApp -#endif -#define qApp (static_cast(VAbstractApplication::instance())) - enum class SocketConnection : bool {Client = false, Server = true}; class MApplication : public VAbstractApplication @@ -78,6 +73,8 @@ public: void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); + static MApplication *VApp(); + public slots: void ProcessCMD(); diff --git a/src/app/tape/tape.pro b/src/app/tape/tape.pro index a1bfd651e..6e6017317 100644 --- a/src/app/tape/tape.pro +++ b/src/app/tape/tape.pro @@ -352,16 +352,7 @@ DEPENDPATH += $$PWD/../../libs/vformat win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a -# VLayout static library (depend on IFC, VGeometry, VPatternDB) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout - -INCLUDEPATH += $$PWD/../../libs/vlayout -DEPENDPATH += $$PWD/../../libs/vlayout - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a - -#VPatternDB static library (depend on vgeometry, vmisc) +#VPatternDB static library (depend on vgeometry, vmisc, VLayout) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb INCLUDEPATH += $$PWD/../../libs/vpatterndb @@ -370,6 +361,15 @@ DEPENDPATH += $$PWD/../../libs/vpatterndb win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a +# VLayout static library (depend on IFC, VGeometry) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout + +INCLUDEPATH += $$PWD/../../libs/vlayout +DEPENDPATH += $$PWD/../../libs/vlayout + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + # Fervor static library (depend on VMisc, IFC) unix|win32: LIBS += -L$$OUT_PWD/../../libs/fervor/$${DESTDIR}/ -lfervor diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 2293c4e0e..b154c4eed 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -111,7 +111,7 @@ TMainWindow::TMainWindow(QWidget *parent) { ui->setupUi(this); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); ui->lineEditFind->setClearButtonEnabled(true); ui->lineEditName->setClearButtonEnabled(true); @@ -269,7 +269,7 @@ bool TMainWindow::LoadFile(const QString &path) if (not QFileInfo::exists(path)) { qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path))); - if (qApp->IsTestMode()) + if (MApplication::VApp()->IsTestMode()) { qApp->exit(V_EX_NOINPUT); } @@ -277,7 +277,7 @@ bool TMainWindow::LoadFile(const QString &path) } // Check if file already opened - const QList list = qApp->MainWindows(); + const QList list = MApplication::VApp()->MainWindows(); for (auto w : list) { if (w->CurrentFile() == path) @@ -300,7 +300,7 @@ bool TMainWindow::LoadFile(const QString &path) try { - data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace()); + data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); m = new VMeasurements(data); m->setXMLContent(path); @@ -373,7 +373,7 @@ bool TMainWindow::LoadFile(const QString &path) data = nullptr; lock.reset(); - if (qApp->IsTestMode()) + if (MApplication::VApp()->IsTestMode()) { qApp->exit(V_EX_NOINPUT); } @@ -382,7 +382,7 @@ bool TMainWindow::LoadFile(const QString &path) } else { - return qApp->NewMainWindow()->LoadFile(path); + return MApplication::VApp()->NewMainWindow()->LoadFile(path); } return true; @@ -418,7 +418,7 @@ void TMainWindow::FileNew() return; } - data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace()); + data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); m = new VMeasurements(mUnit, setup.Dimensions(), data); m->SetFullCircumference(setup.FullCircumference()); @@ -429,7 +429,7 @@ void TMainWindow::FileNew() } else { - data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace()); + data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); m = new VMeasurements(mUnit, data); m_curFileFormatVersion = VVITConverter::MeasurementMaxVer; @@ -450,7 +450,7 @@ void TMainWindow::FileNew() } else { - qApp->NewMainWindow()->FileNew(); + MApplication::VApp()->NewMainWindow()->FileNew(); } } @@ -460,7 +460,7 @@ void TMainWindow::OpenIndividual() const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit);;") + tr("Multisize measurements") + QStringLiteral(" (*.vst);;") + tr("All files") + QStringLiteral(" (*.*)"); //Use standard path to individual measurements - const QString pathTo = qApp->TapeSettings()->GetPathIndividualMeasurements(); + const QString pathTo = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); bool usedNotExistedDir = false; QDir directory(pathTo); @@ -483,7 +483,7 @@ void TMainWindow::OpenMultisize() const QString filter = tr("Multisize measurements") + QStringLiteral(" (*.vst);;") + tr("Individual measurements") + QStringLiteral(" (*.vit);;") + tr("All files") + QStringLiteral(" (*.*)"); //Use standard path to multisize measurements - QString pathTo = qApp->TapeSettings()->GetPathMultisizeMeasurements(); + QString pathTo = MApplication::VApp()->TapeSettings()->GetPathMultisizeMeasurements(); pathTo = VCommonSettings::PrepareMultisizeTables(pathTo); Open(pathTo, filter); @@ -495,7 +495,7 @@ void TMainWindow::OpenTemplate() const QString filter = tr("Measurements") + QStringLiteral(" (*.vst *.vit);;") + tr("All files") + QStringLiteral(" (*.*)"); //Use standard path to template files - QString pathTo = qApp->TapeSettings()->GetPathTemplate(); + QString pathTo = MApplication::VApp()->TapeSettings()->GetPathTemplate(); pathTo = VCommonSettings::PrepareStandardTemplates(pathTo); Open(pathTo, filter); @@ -511,7 +511,7 @@ void TMainWindow::CreateFromExisting() { const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit)"); //Use standard path to individual measurements - const QString pathTo = qApp->TapeSettings()->GetPathIndividualMeasurements(); + const QString pathTo = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); bool usedNotExistedDir = false; QDir directory(pathTo); @@ -521,7 +521,7 @@ void TMainWindow::CreateFromExisting() } const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), pathTo, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (not mPath.isEmpty()) { @@ -531,7 +531,7 @@ void TMainWindow::CreateFromExisting() } else { - qApp->NewMainWindow()->CreateFromExisting(); + MApplication::VApp()->NewMainWindow()->CreateFromExisting(); } } @@ -597,7 +597,7 @@ void TMainWindow::changeEvent(QEvent *event) { if (event->type() == QEvent::LanguageChange) { - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); // retranslate designer form (single inheritance approach) ui->retranslateUi(this); @@ -667,7 +667,7 @@ bool TMainWindow::eventFilter(QObject *object, QEvent *event) auto *keyEvent = static_cast(event); if ((keyEvent->key() == Qt::Key_Period) && ((keyEvent->modifiers() & Qt::KeypadModifier) != 0u)) { - if (qApp->Settings()->GetOsSeparator()) + if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) { plainTextEdit->insertPlainText(QLocale().decimalPoint()); } @@ -686,7 +686,7 @@ bool TMainWindow::eventFilter(QObject *object, QEvent *event) auto *keyEvent = static_cast(event); if ((keyEvent->key() == Qt::Key_Period) && ((keyEvent->modifiers() & Qt::KeypadModifier) != 0u)) { - if (qApp->Settings()->GetOsSeparator()) + if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) { textEdit->insert(QLocale().decimalPoint()); } @@ -756,7 +756,7 @@ void TMainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int //--------------------------------------------------------------------------------------------------------------------- QStringList TMainWindow::RecentFileList() const { - return qApp->TapeSettings()->GetRecentFileList(); + return MApplication::VApp()->TapeSettings()->GetRecentFileList(); } //--------------------------------------------------------------------------------------------------------------------- @@ -876,11 +876,11 @@ bool TMainWindow::FileSaveAs() { if (mType == MeasurementsType::Individual) { - dir = qApp->TapeSettings()->GetPathIndividualMeasurements(); + dir = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); } else { - dir = qApp->TapeSettings()->GetPathMultisizeMeasurements(); + dir = MApplication::VApp()->TapeSettings()->GetPathMultisizeMeasurements(); dir = VCommonSettings::PrepareMultisizeTables(dir); } } @@ -897,7 +897,7 @@ bool TMainWindow::FileSaveAs() } QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() { @@ -998,7 +998,7 @@ void TMainWindow::ShowWindow() const if (v.canConvert()) { const int offset = qvariant_cast(v); - const QList windows = qApp->MainWindows(); + const QList windows = MApplication::VApp()->MainWindows(); windows.at(offset)->raise(); windows.at(offset)->activateWindow(); } @@ -1017,7 +1017,7 @@ void TMainWindow::ImportDataFromCSV() const QString suffix = QStringLiteral("csv"); QString fileName = QFileDialog::getOpenFileName(this, tr("Import from CSV"), QDir::homePath(), filters, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { @@ -1031,16 +1031,16 @@ void TMainWindow::ImportDataFromCSV() } DialogExportToCSV dialog(this); - dialog.SetWithHeader(qApp->Settings()->GetCSVWithHeader()); - dialog.SetSelectedMib(qApp->Settings()->GetCSVCodec()); - dialog.SetSeparator(qApp->Settings()->GetCSVSeparator()); + dialog.SetWithHeader(VAbstractApplication::VApp()->Settings()->GetCSVWithHeader()); + dialog.SetSelectedMib(VAbstractApplication::VApp()->Settings()->GetCSVCodec()); + dialog.SetSeparator(VAbstractApplication::VApp()->Settings()->GetCSVSeparator()); dialog.ShowFilePreview(fileName); if (dialog.exec() == QDialog::Accepted) { - qApp->Settings()->SetCSVSeparator(dialog.GetSeparator()); - qApp->Settings()->SetCSVCodec(dialog.GetSelectedMib()); - qApp->Settings()->SetCSVWithHeader(dialog.IsWithHeader()); + VAbstractApplication::VApp()->Settings()->SetCSVSeparator(dialog.GetSeparator()); + VAbstractApplication::VApp()->Settings()->SetCSVCodec(dialog.GetSelectedMib()); + VAbstractApplication::VApp()->Settings()->SetCSVWithHeader(dialog.IsWithHeader()); QSharedPointer columns; if (m->Type() == MeasurementsType::Multisize) @@ -1365,7 +1365,8 @@ void TMainWindow::Fx() auto *dialog = new DialogEditWrongFormula(meash->GetData(), NULL_ID, this); dialog->setWindowTitle(tr("Edit measurement")); dialog->SetMeasurementsMode(); - dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), true)); + dialog->SetFormula(VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), true)); const QString postfix = UnitsToStr(mUnit, true);//Show unit in dialog lable (cm, mm or inch) dialog->setPostfix(postfix); @@ -1433,7 +1434,7 @@ void TMainWindow::AddKnown() { if (mType == MeasurementsType::Individual) { - m->AddEmpty(name, qApp->TrVars()->MFormula(name)); + m->AddEmpty(name, VAbstractApplication::VApp()->TrVars()->MFormula(name)); } else { @@ -1452,7 +1453,7 @@ void TMainWindow::AddKnown() { if (mType == MeasurementsType::Individual) { - m->AddEmptyAfter(after, name, qApp->TrVars()->MFormula(name)); + m->AddEmptyAfter(after, name, VAbstractApplication::VApp()->TrVars()->MFormula(name)); } else { @@ -1485,10 +1486,10 @@ void TMainWindow::ImportFromPattern() const QString filter(tr("Pattern files (*.val)")); //Use standard path to individual measurements - QString pathTo = qApp->TapeSettings()->GetPathPattern(); + QString pathTo = MApplication::VApp()->TapeSettings()->GetPathPattern(); const QString mPath = QFileDialog::getOpenFileName(this, tr("Import from a pattern"), pathTo, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (mPath.isEmpty()) { return; @@ -1653,8 +1654,9 @@ void TMainWindow::ShowNewMData(bool fresh) else { //Show known - ui->plainTextEditDescription->setPlainText(qApp->TrVars()->Description(meash->GetName())); - ui->lineEditFullName->setText(qApp->TrVars()->GuiText(meash->GetName())); + ui->plainTextEditDescription->setPlainText( + VAbstractApplication::VApp()->TrVars()->Description(meash->GetName())); + ui->lineEditFullName->setText(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName())); ui->lineEditName->setText(nameField->text()); } connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName); @@ -1679,14 +1681,15 @@ void TMainWindow::ShowNewMData(bool fresh) if (meash->IsSpecialUnits()) { const qreal value = *data->DataVariables()->value(meash->GetName())->GetValue(); - calculatedValue = qApp->LocaleToString(value) + QChar(QChar::Space) + degreeSymbol; + calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + + degreeSymbol; } else { const QString postfix = UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch) const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), mUnit, pUnit); - calculatedValue = qApp->LocaleToString(value) + QChar(QChar::Space) + postfix; + calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + postfix; } ui->labelCalculatedValue->setText(calculatedValue); @@ -1714,7 +1717,9 @@ void TMainWindow::ShowNewMData(bool fresh) ui->plainTextEditFormula->blockSignals(true); - QString formula = VTranslateVars::TryFormulaToUser(meash->GetFormula(), qApp->Settings()->GetOsSeparator()); + QString formula = + VTranslateVars::TryFormulaToUser(meash->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormula->setPlainText(formula); ui->plainTextEditFormula->blockSignals(false); @@ -1736,7 +1741,7 @@ void TMainWindow::ShowNewMData(bool fresh) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ShowMDiagram(const QString &name) { - const VTranslateVars *trv = qApp->TrVars(); + const VTranslateVars *trv = VAbstractApplication::VApp()->TrVars(); const QString number = trv->MNumber(name); if (number.isEmpty()) @@ -1901,7 +1906,8 @@ void TMainWindow::SaveMValue() try { - const QString formula = qApp->TrVars()->FormulaFromUser(text, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); m->SetMValue(nameField->data(Qt::UserRole).toString(), formula); } catch (qmu::QmuParserError &e) // Just in case something bad will happen @@ -2189,7 +2195,7 @@ void TMainWindow::ExportToIndividual() QString dir; if (curFile.isEmpty()) { - dir = qApp->TapeSettings()->GetPathIndividualMeasurements(); + dir = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); } else { @@ -2206,7 +2212,7 @@ void TMainWindow::ExportToIndividual() QString filters = tr("Individual measurements") + QStringLiteral(" (*.vit)"); QString fName = tr("measurements.vit"); QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + QChar('/') + fName, - filters, nullptr, qApp->NativeFileDialog()); + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() { @@ -2228,7 +2234,8 @@ void TMainWindow::ExportToIndividual() fileName += QChar('.') + suffix; } - QScopedPointer tmpData(new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace())); + QScopedPointer tmpData( + new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace())); VMeasurements individualMeasurements(mUnit, tmpData.data()); @@ -2409,7 +2416,7 @@ void TMainWindow::SetupMenu() // Measurements connect(ui->actionAddCustom, &QAction::triggered, this, &TMainWindow::AddCustom); connect(ui->actionAddKnown, &QAction::triggered, this, &TMainWindow::AddKnown); - connect(ui->actionDatabase, &QAction::triggered, qApp, &MApplication::ShowDataBase); + connect(ui->actionDatabase, &QAction::triggered, MApplication::VApp(), &MApplication::ShowDataBase); connect(ui->actionImportFromPattern, &QAction::triggered, this, &TMainWindow::ImportFromPattern); // Window @@ -2524,7 +2531,7 @@ void TMainWindow::InitWindow() ui->comboBoxGender->setCurrentIndex(index); { - const QLocale dateLocale = QLocale(qApp->Settings()->GetLocale()); + const QLocale dateLocale = QLocale(VAbstractApplication::VApp()->Settings()->GetLocale()); ui->dateEditBirthDate->setLocale(dateLocale); ui->dateEditBirthDate->setDisplayFormat(dateLocale.dateFormat()); ui->dateEditBirthDate->setDate(m->BirthDate()); @@ -2969,7 +2976,7 @@ void TMainWindow::SetCurrentFile(const QString &fileName) ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(curFile)); ui->lineEditPathToFile->setCursorPosition(0); ui->pushButtonShowInExplorer->setEnabled(true); - auto settings = qApp->TapeSettings(); + auto settings = MApplication::VApp()->TapeSettings(); QStringList files = settings->GetRecentFileList(); files.removeAll(fileName); files.prepend(fileName); @@ -3100,8 +3107,8 @@ void TMainWindow::RefreshTable(bool freshCall) if (mType == MeasurementsType::Individual) { - QTableWidgetItem *item = AddCell(qApp->TrVars()->MToUser(meash->GetName()), currentRow, ColumnName, - Qt::AlignVCenter); // name + QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), + currentRow, ColumnName, Qt::AlignVCenter); // name item->setData(Qt::UserRole, meash->GetName()); if (meash->IsCustom()) @@ -3110,7 +3117,8 @@ void TMainWindow::RefreshTable(bool freshCall) } else { - AddCell(qApp->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, Qt::AlignVCenter); + AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, + Qt::AlignVCenter); } QString calculatedValue; @@ -3126,14 +3134,16 @@ void TMainWindow::RefreshTable(bool freshCall) AddCell(calculatedValue, currentRow, ColumnCalcValue, Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value - QString formula = VTranslateVars::TryFormulaToUser(meash->GetFormula(), qApp->Settings()->GetOsSeparator()); + QString formula = + VTranslateVars::TryFormulaToUser(meash->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); AddCell(formula, currentRow, ColumnFormula, Qt::AlignVCenter); // formula } else { - QTableWidgetItem *item = AddCell(qApp->TrVars()->MToUser(meash->GetName()), currentRow, 0, - Qt::AlignVCenter); // name + QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), + currentRow, 0, Qt::AlignVCenter); // name item->setData(Qt::UserRole, meash->GetName()); if (meash->IsCustom()) @@ -3142,7 +3152,8 @@ void TMainWindow::RefreshTable(bool freshCall) } else { - AddCell(qApp->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, Qt::AlignVCenter); + AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, + Qt::AlignVCenter); } QString calculatedValue; @@ -3196,7 +3207,8 @@ QString TMainWindow::GetCustomName() const QString name; do { - name = CustomMSign + qApp->TrVars()->InternalVarToUser(measurement_) + QString::number(num); + name = CustomMSign + VAbstractApplication::VApp()->TrVars()->InternalVarToUser(measurement_) + + QString::number(num); num++; } while (not data->IsUnique(name)); @@ -3305,7 +3317,7 @@ void TMainWindow::UpdateWindowTitle() } else { - showName = tr("untitled %1").arg(qApp->MainWindows().size()+1); + showName = tr("untitled %1").arg(MApplication::VApp()->MainWindows().size()+1); mType == MeasurementsType::Multisize ? showName += QLatin1String(".vst") : showName += QLatin1String(".vit"); } @@ -3375,7 +3387,8 @@ bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer QString f; if (fromUser) { - f = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + f = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } else { @@ -3396,7 +3409,7 @@ bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer result = UnitConvertor(result, mUnit, pUnit); } - label->setText(qApp->LocaleToString(result) + QChar(QChar::Space) +postfix); + label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) +postfix); label->setToolTip(tr("Value")); return true; } @@ -3412,7 +3425,7 @@ bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer void TMainWindow::Open(const QString &pathTo, const QString &filter) { const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), pathTo, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (not mPath.isEmpty()) { @@ -3422,7 +3435,7 @@ void TMainWindow::Open(const QString &pathTo, const QString &filter) } else { - qApp->NewMainWindow()->LoadFile(mPath); + MApplication::VApp()->NewMainWindow()->LoadFile(mPath); } } } @@ -3465,7 +3478,7 @@ void TMainWindow::MeasurementGUI() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ReadSettings() { - const VTapeSettings *settings = qApp->TapeSettings(); + const VTapeSettings *settings = MApplication::VApp()->TapeSettings(); if (settings->status() == QSettings::NoError) { @@ -3477,7 +3490,7 @@ void TMainWindow::ReadSettings() ToolBarStyles(); // Stack limit - //qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount()); + //VAbstractApplication::VApp()->getUndoStack()->setUndoLimit(settings->GetUndoCount()); } else { @@ -3488,7 +3501,7 @@ void TMainWindow::ReadSettings() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::WriteSettings() { - VTapeSettings *settings = qApp->TapeSettings(); + VTapeSettings *settings = MApplication::VApp()->TapeSettings(); settings->SetGeometry(saveGeometry()); settings->SetWindowState(saveState()); settings->SetToolbarsState(saveState(APP_VERSION)); @@ -3531,7 +3544,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path) if (not QFileInfo::exists(path)) { qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path))); - if (qApp->IsTestMode()) + if (MApplication::VApp()->IsTestMode()) { qApp->exit(V_EX_NOINPUT); } @@ -3539,7 +3552,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path) } // Check if file already opened - const QList list = qApp->MainWindows(); + const QList list = MApplication::VApp()->MainWindows(); for (auto w : list) { if (w->CurrentFile() == path) @@ -3562,7 +3575,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path) try { - data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace()); + data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); m = new VMeasurements(data); m->setXMLContent(path); @@ -3628,7 +3641,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path) data = nullptr; lock.reset(); - if (qApp->IsTestMode()) + if (MApplication::VApp()->IsTestMode()) { qApp->exit(V_EX_NOINPUT); } @@ -3637,7 +3650,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path) } else { - return qApp->NewMainWindow()->LoadFile(path); + return MApplication::VApp()->NewMainWindow()->LoadFile(path); } return true; @@ -3651,12 +3664,12 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) QAction *action = menu->addAction(tr("&New Window")); connect(action, &QAction::triggered, this, []() { - qApp->NewMainWindow()->activateWindow(); + MApplication::VApp()->NewMainWindow()->activateWindow(); }); action->setMenuRole(QAction::NoRole); menu->addSeparator(); - const QList windows = qApp->MainWindows(); + const QList windows = MApplication::VApp()->MainWindows(); for (int i = 0; i < windows.count(); ++i) { TMainWindow *window = windows.at(i); @@ -3683,7 +3696,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) bool TMainWindow::IgnoreLocking(int error, const QString &path) { QMessageBox::StandardButton answer = QMessageBox::Abort; - if (not qApp->IsTestMode()) + if (not MApplication::VApp()->IsTestMode()) { switch(error) { @@ -3717,7 +3730,7 @@ bool TMainWindow::IgnoreLocking(int error, const QString &path) { qCDebug(tMainWindow, "Failed to lock %s", qUtf8Printable(path)); qCDebug(tMainWindow, "Error type: %d", error); - if (qApp->IsTestMode()) + if (MApplication::VApp()->IsTestMode()) { switch(error) { @@ -3898,13 +3911,14 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe } IndividualMeasurement measurement; - const QString mName = CheckMName(qApp->TrVars()->MFromUser(name), importedNames); + const QString mName = CheckMName(VAbstractApplication::VApp()->TrVars()->MFromUser(name), importedNames); importedNames.insert(mName); measurement.name = mName; const int valueColumn = map.at(static_cast(IndividualMeasurementsColumns::Value)); - measurement.value = VTranslateVars::TryFormulaFromUser(csv.text(i, valueColumn), - qApp->Settings()->GetOsSeparator()); + measurement.value = + VTranslateVars::TryFormulaFromUser(csv.text(i, valueColumn), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); const bool custom = name.startsWith(CustomMSign); if (columns > 2 && custom) @@ -3967,7 +3981,7 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec auto ConverToDouble = [](QString text, const QString &error) { text.replace(" ", QString()); - text = VTranslateVars::TryFormulaFromUser(text, qApp->Settings()->GetOsSeparator()); + text = VTranslateVars::TryFormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); bool ok = false; const qreal value = QLocale::c().toDouble(text, &ok); @@ -4013,7 +4027,7 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec } MultisizeMeasurement measurement; - const QString mName = CheckMName(qApp->TrVars()->MFromUser(name), importedNames); + const QString mName = CheckMName(VAbstractApplication::VApp()->TrVars()->MFromUser(name), importedNames); importedNames.insert(mName); measurement.name = mName; diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index e5700e8cd..36e7c1621 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -148,7 +148,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con } QString logMsg = msg; - const bool isPatternMessage = qApp->IsWarningMessage(msg); + const bool isPatternMessage = VAbstractApplication::VApp()->IsWarningMessage(msg); if (isPatternMessage) { logMsg = logMsg.remove(VAbstractValApplication::warningMessageSignature); @@ -167,7 +167,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con case QtWarningMsg: if (isPatternMessage) { - qApp->PostWarningMessage(logMsg, type); + VAbstractValApplication::VApp()->PostWarningMessage(logMsg, type); } debugdate += QStringLiteral(":WARNING:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) .arg(context.function, context.category, logMsg); @@ -176,7 +176,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con case QtCriticalMsg: if (isPatternMessage) { - qApp->PostWarningMessage(logMsg, type); + VAbstractValApplication::VApp()->PostWarningMessage(logMsg, type); } debugdate += QStringLiteral(":CRITICAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) .arg(context.function, context.category, logMsg); @@ -191,7 +191,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con case QtInfoMsg: if (isPatternMessage) { - qApp->PostWarningMessage(logMsg, type); + VAbstractValApplication::VApp()->PostWarningMessage(logMsg, type); } debugdate += QStringLiteral(":INFO:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line) .arg(context.function, context.category, logMsg); @@ -205,9 +205,9 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con vStdErr().flush(); #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - (*qApp->LogFile()) << debugdate << endl; + (*VApplication::VApp()->LogFile()) << debugdate << endl; #else - (*qApp->LogFile()) << debugdate << Qt::endl; + (*VApplication::VApp()->LogFile()) << debugdate << Qt::endl; #endif } @@ -436,7 +436,7 @@ bool VApplication::notify(QObject *receiver, QEvent *event) void VApplication::ActivateDarkMode() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); if (settings->GetDarkMode()) { QFile f(QStringLiteral(":qdarkstyle/style.qss")); @@ -769,6 +769,12 @@ bool VApplication::IsPedantic() const return (VCommandLine::instance != nullptr) && VCommandLine::instance->IsPedantic(); } +//--------------------------------------------------------------------------------------------------------------------- +auto VApplication::VApp() -> VApplication * +{ + return qobject_cast(QCoreApplication::instance()); +} + //--------------------------------------------------------------------------------------------------------------------- const VCommandLinePtr VApplication::CommandLine() const { diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index 70c4bbfe7..a0b10b4e8 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -37,11 +37,6 @@ class VApplication;// use in define -#if defined(qApp) -#undef qApp -#endif -#define qApp (qobject_cast(VAbstractApplication::instance())) - /** * @brief The VApplication class reimplamentation QApplication class. */ @@ -74,6 +69,8 @@ public: virtual bool IsAppInGUIMode() const override; virtual bool IsPedantic() const override; + static VApplication *VApp(); + protected: virtual void InitTrVars() override; virtual bool event(QEvent *e) override; diff --git a/src/app/valentina/core/vformulaproperty.cpp b/src/app/valentina/core/vformulaproperty.cpp index e6aa5ce6c..0aba4d03e 100644 --- a/src/app/valentina/core/vformulaproperty.cpp +++ b/src/app/valentina/core/vformulaproperty.cpp @@ -45,7 +45,7 @@ VFormulaProperty::VFormulaProperty(const QString &name) addChild(tmpFormula); tmpFormula->setClearButtonEnable(true); tmpFormula->setUpdateBehaviour(true, false); - tmpFormula->setOsSeparator(qApp->Settings()->GetOsSeparator()); + tmpFormula->setOsSeparator(VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // Cannot use virtual function setValue in constructor SetFormula(QVariant(0).value()); diff --git a/src/app/valentina/core/vformulapropertyeditor.cpp b/src/app/valentina/core/vformulapropertyeditor.cpp index a52a56771..b0535b502 100644 --- a/src/app/valentina/core/vformulapropertyeditor.cpp +++ b/src/app/valentina/core/vformulapropertyeditor.cpp @@ -39,6 +39,7 @@ #include "../vpropertyexplorer/vproperty.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" +#include "vapplication.h" // VFormulaPropertyEditor //--------------------------------------------------------------------------------------------------------------------- @@ -87,8 +88,9 @@ void VFormulaPropertyEditor::SetFormula(const VFormula& formula) //--------------------------------------------------------------------------------------------------------------------- void VFormulaPropertyEditor::onToolButtonClicked() { - QScopedPointer tmpWidget(new DialogEditWrongFormula(formula.getData(), formula.getToolId(), - qApp->getMainWindow())); + QScopedPointer tmpWidget( + new DialogEditWrongFormula(formula.getData(), formula.getToolId(), + VAbstractValApplication::VApp()->getMainWindow())); tmpWidget->setCheckZero(formula.getCheckZero()); tmpWidget->setPostfix(formula.getPostfix()); tmpWidget->SetFormula(formula.GetFormula(FormulaType::FromUser)); diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index bf71188c2..2bd34452e 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -460,7 +460,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VPE::VProperty *property) default: break; } - qApp->getSceneView()->update(); + VAbstractValApplication::VApp()->getSceneView()->update(); } //--------------------------------------------------------------------------------------------------------------------- @@ -540,7 +540,7 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias(Tool *i, const QString &prope { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); - itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix())); + itemName->setValue(VAbstractApplication::VApp()->TrVars()->VarToUser(i->GetAliasSuffix())); AddProperty(itemName, AttrAlias); } @@ -550,7 +550,7 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias1(Tool *i, const QString &prop { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); - itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix1())); + itemName->setValue(VAbstractApplication::VApp()->TrVars()->VarToUser(i->GetAliasSuffix1())); AddProperty(itemName, AttrAlias1); } @@ -560,7 +560,7 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias2(Tool *i, const QString &prop { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); - itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix2())); + itemName->setValue(VAbstractApplication::VApp()->TrVars()->VarToUser(i->GetAliasSuffix2())); AddProperty(itemName, AttrAlias2); } @@ -2066,14 +2066,16 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSpline(VPE::VProperty *property) case 36: // AttrLength1 if (not f.error() && f.getDoubleValue() >= 0) { - spl.SetC1Length(qApp->toPixel(f.getDoubleValue()), f.GetFormula(FormulaType::FromUser)); + spl.SetC1Length(VAbstractValApplication::VApp()->toPixel(f.getDoubleValue()), + f.GetFormula(FormulaType::FromUser)); i->setSpline(spl); } break; case 37: // AttrLength2 if (not f.error() && f.getDoubleValue() >= 0) { - spl.SetC2Length(qApp->toPixel(f.getDoubleValue()), f.GetFormula(FormulaType::FromUser)); + spl.SetC2Length(VAbstractValApplication::VApp()->toPixel(f.getDoubleValue()), + f.GetFormula(FormulaType::FromUser)); i->setSpline(spl); } break; @@ -2887,7 +2889,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) VFormula length1(spl.GetC1LengthFormula(), i->getData()); length1.setCheckZero(false); length1.setToolId(i->getId()); - length1.setPostfix(UnitsToStr(qApp->patternUnits())); + length1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length1.Eval(); AddPropertyFormula(tr("C1: length:"), length1, AttrLength1); @@ -2901,7 +2903,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) VFormula length2(spl.GetC2LengthFormula(), i->getData()); length2.setCheckZero(false); length2.setToolId(i->getId()); - length2.setPostfix(UnitsToStr(qApp->patternUnits())); + length2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length2.Eval(); AddPropertyFormula(tr("C2: length:"), length2, AttrLength2); @@ -3693,7 +3695,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() VFormula length1F(spl.GetC1LengthFormula(), i->getData()); length1F.setCheckZero(false); length1F.setToolId(i->getId()); - length1F.setPostfix(UnitsToStr(qApp->patternUnits())); + length1F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length1F.Eval(); QVariant length1; length1.setValue(length1F); @@ -3711,7 +3713,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() VFormula length2F(spl.GetC2LengthFormula(), i->getData()); length2F.setCheckZero(false); length2F.setToolId(i->getId()); - length2F.setPostfix(UnitsToStr(qApp->patternUnits())); + length2F.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); length2F.Eval(); QVariant length2; length2.setValue(length2F); diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index f3e88df3a..e2f5320f4 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -51,7 +51,7 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) ui->tabWidget->setCurrentIndex(0); // Tab General - ui->autoSaveCheck->setChecked(qApp->ValentinaSettings()->GetAutosaveState()); + ui->autoSaveCheck->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveState()); InitLanguages(ui->langCombo); connect(ui->langCombo, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() @@ -60,11 +60,11 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) }); //-------------------- Decimal separator setup - ui->osOptionCheck->setChecked(qApp->ValentinaSettings()->GetOsSeparator()); + ui->osOptionCheck->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator()); //----------------------- Unit setup // set default unit - const qint32 indexUnit = ui->unitCombo->findData(qApp->ValentinaSettings()->GetUnit()); + const qint32 indexUnit = ui->unitCombo->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) { ui->unitCombo->setCurrentIndex(indexUnit); @@ -78,7 +78,7 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) //----------------------- Label language SetLabelComboBox(VApplication::LabelLanguages()); - int index = ui->labelCombo->findData(qApp->ValentinaSettings()->GetLabelLanguage()); + int index = ui->labelCombo->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetLabelLanguage()); if (index != -1) { ui->labelCombo->setCurrentIndex(index); @@ -93,16 +93,17 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) connect(ui->systemCombo, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() { m_systemChanged = true; - QString text = qApp->TrVars()->PMSystemAuthor(ui->systemCombo->currentData().toString()); + QString text = VAbstractApplication::VApp()->TrVars() + ->PMSystemAuthor(ui->systemCombo->currentData().toString()); ui->systemAuthorValueLabel->setText(text); ui->systemAuthorValueLabel->setToolTip(text); - text = qApp->TrVars()->PMSystemBook(ui->systemCombo->currentData().toString()); + text = VAbstractApplication::VApp()->TrVars()->PMSystemBook(ui->systemCombo->currentData().toString()); ui->systemBookValueLabel->setPlainText(text); }); // set default pattern making system - index = ui->systemCombo->findData(qApp->ValentinaSettings()->GetPMSystemCode()); + index = ui->systemCombo->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetPMSystemCode()); if (index != -1) { ui->systemCombo->setCurrentIndex(index); @@ -111,13 +112,13 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) //----------------------------- Pattern Editing connect(ui->resetWarningsButton, &QPushButton::released, this, []() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetConfirmItemDelete(true); settings->SetConfirmFormatRewriting(true); }); - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); ui->checkBoxFreeCurve->setChecked(settings->IsFreeCurveMode()); ui->checkBoxZoomFitBestCurrentPP->setChecked(settings->IsDoubleClickZoomFitBestCurrentPP()); @@ -167,11 +168,11 @@ QStringList PreferencesConfigurationPage::Apply() { // Tab General QStringList preferences; - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetAutosaveState(ui->autoSaveCheck->isChecked()); settings->SetAutosaveTime(ui->autoTime->value()); - QTimer *autoSaveTimer = qApp->getAutoSaveTimer(); + QTimer *autoSaveTimer = VApplication::VApp()->getAutoSaveTimer(); SCASSERT(autoSaveTimer) ui->autoSaveCheck->isChecked() ? autoSaveTimer->start(ui->autoTime->value()*60000) : autoSaveTimer->stop(); @@ -208,7 +209,7 @@ QStringList PreferencesConfigurationPage::Apply() settings->SetPMSystemCode(code); m_systemChanged = false; - qApp->LoadTranslation(locale); + VAbstractApplication::VApp()->LoadTranslation(locale); } if (m_unitChanged) { diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index c700941e3..6ffe3b2df 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -65,7 +65,7 @@ PreferencesPathPage::~PreferencesPathPage() //--------------------------------------------------------------------------------------------------------------------- QStringList PreferencesPathPage::Apply() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text()); settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text()); settings->SetPathPattern(ui->pathTable->item(2, 1)->text()); @@ -137,23 +137,23 @@ void PreferencesPathPage::EditPath() switch (row) { case 0: // individual measurements - path = qApp->ValentinaSettings()->GetPathIndividualMeasurements(); + path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathIndividualMeasurements(); break; case 1: // multisize measurements - path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements(); + path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathMultisizeMeasurements(); path = VCommonSettings::PrepareMultisizeTables(path); break; case 2: // pattern path - path = qApp->ValentinaSettings()->GetPathPattern(); + path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathPattern(); break; case 3: // layout path - path = qApp->ValentinaSettings()->GetPathLayout(); + path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLayout(); break; case 4: // templates - path = qApp->ValentinaSettings()->GetPathTemplate(); + path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathTemplate(); break; case 5: // label templates - path = qApp->ValentinaSettings()->GetPathLabelTemplate(); + path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLabelTemplate(); break; default: break; @@ -168,7 +168,7 @@ void PreferencesPathPage::EditPath() const QString dir = QFileDialog::getExistingDirectory( this, tr("Open Directory"), path, - qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); + VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); if (dir.isEmpty()) { if (usedNotExistedDir) @@ -195,7 +195,7 @@ void PreferencesPathPage::InitTable() ui->pathTable->setRowCount(6); ui->pathTable->setColumnCount(2); - const VSettings *settings = qApp->ValentinaSettings(); + const VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); { ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index be9dde58c..193a48960 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -64,7 +64,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) ui->setupUi(this); RetranslateUi(); - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender()); @@ -126,12 +126,12 @@ QStringList PreferencesPatternPage::Apply() { QStringList preferences; - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); // Scene antialiasing if (settings->GetGraphicalOutput() != ui->graphOutputCheck->isChecked()) { - if (qApp->getSceneView()->IsOpenGLRender()) + if (VAbstractValApplication::VApp()->getSceneView()->IsOpenGLRender()) { preferences.append(tr("antialiasing")); } @@ -147,7 +147,7 @@ QStringList PreferencesPatternPage::Apply() settings->SetCurveApproximationScale(ui->doubleSpinBoxCurveApproximation->value()); settings->SetLineWidth(UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, Unit::Mm)); - qApp->getSceneView()->SetAntialiasing(ui->graphOutputCheck->isChecked()); + VAbstractValApplication::VApp()->getSceneView()->SetAntialiasing(ui->graphOutputCheck->isChecked()); /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a * non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack @@ -163,7 +163,7 @@ QStringList PreferencesPatternPage::Apply() if (settings->IsDoublePassmark() != ui->doublePassmarkCheck->isChecked()) { settings->SetDoublePassmark(ui->doublePassmarkCheck->isChecked()); - qApp->getCurrentDocument()->LiteParseTree(Document::LiteParse); + VAbstractValApplication::VApp()->getCurrentDocument()->LiteParseTree(Document::LiteParse); } settings->SetLabelDateFormat(ui->comboBoxDateFormats->currentText()); @@ -181,8 +181,9 @@ QStringList PreferencesPatternPage::Apply() //--------------------------------------------------------------------------------------------------------------------- void PreferencesPatternPage::InitDefaultSeamAllowance() { - ui->defaultSeamAllowance->setValue(qApp->ValentinaSettings()->GetDefaultSeamAllowance()); - ui->defaultSeamAllowance->setSuffix(UnitsToStr(StrToUnits(qApp->ValentinaSettings()->GetUnit()), true)); + ui->defaultSeamAllowance->setValue(VAbstractValApplication::VApp()->ValentinaSettings()->GetDefaultSeamAllowance()); + ui->defaultSeamAllowance->setSuffix( + UnitsToStr(StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()), true)); } //--------------------------------------------------------------------------------------------------------------------- @@ -201,7 +202,7 @@ void PreferencesPatternPage::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void PreferencesPatternPage::EditDateTimeFormats() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); QPushButton *button = qobject_cast(sender()); if (button == ui->pushButtonEditDateFormats) @@ -231,7 +232,7 @@ void PreferencesPatternPage::ManageKnownMaterials() //--------------------------------------------------------------------------------------------------------------------- void PreferencesPatternPage::InitLabelDateTimeFormats() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); InitComboBoxFormats(ui->comboBoxDateFormats, VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(), diff --git a/src/app/valentina/dialogs/dialogaboutapp.cpp b/src/app/valentina/dialogs/dialogaboutapp.cpp index e57b10a67..d4efe750c 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.cpp +++ b/src/app/valentina/dialogs/dialogaboutapp.cpp @@ -45,7 +45,8 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : { ui->setupUi(this); - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) + : setLocale(QLocale::c()); ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION_STR)); ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION)); diff --git a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp index 923e22a69..f6b2e8845 100644 --- a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp +++ b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp @@ -35,6 +35,7 @@ #include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/calculator.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" +#include "../core/vapplication.h" #include #define DIALOG_MAX_FORMULA_HEIGHT 64 @@ -66,9 +67,8 @@ DialogFinalMeasurements::DialogFinalMeasurements(VPattern *doc, QWidget *parent) formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - qCDebug(vDialog, "Showing variables."); ShowUnits(); const bool freshCall = true; @@ -151,7 +151,7 @@ bool DialogFinalMeasurements::eventFilter(QObject *object, QEvent *event) QKeyEvent *keyEvent = static_cast(event); if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier)) { - if (qApp->Settings()->GetOsSeparator()) + if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) { textEdit->insert(QLocale().decimalPoint()); } @@ -186,7 +186,7 @@ void DialogFinalMeasurements::showEvent(QShowEvent *event) } // do your init stuff here - const QSize sz = qApp->Settings()->GetFinalMeasurementsDialogSize(); + const QSize sz = VAbstractApplication::VApp()->Settings()->GetFinalMeasurementsDialogSize(); if (not sz.isEmpty()) { resize(sz); @@ -203,7 +203,7 @@ void DialogFinalMeasurements::resizeEvent(QResizeEvent *event) // dialog creating, which would if (m_isInitialized) { - qApp->Settings()->SetFinalMeasurementsDialogSize(size()); + VAbstractApplication::VApp()->Settings()->SetFinalMeasurementsDialogSize(size()); } QDialog::resizeEvent(event); } @@ -228,7 +228,8 @@ void DialogFinalMeasurements::ShowFinalMeasurementDetails() EvalUserFormula(m.formula, false); ui->plainTextEditFormula->blockSignals(true); - const QString formula = VTranslateVars::TryFormulaToUser(m.formula, qApp->Settings()->GetOsSeparator()); + const QString formula = + VTranslateVars::TryFormulaToUser(m.formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormula->setPlainText(formula); ui->plainTextEditFormula->blockSignals(false); @@ -373,7 +374,7 @@ void DialogFinalMeasurements::SaveFormula() { QTableWidgetItem *result = ui->tableWidget->item(row, 1); //Show unit in dialog lable (cm, mm or inch) - const QString postfix = UnitsToStr(qApp->patternUnits()); + const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); ui->labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix); return; } @@ -381,7 +382,7 @@ void DialogFinalMeasurements::SaveFormula() if (text.isEmpty()) { //Show unit in dialog lable (cm, mm or inch) - const QString postfix = UnitsToStr(qApp->patternUnits()); + const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); return; } @@ -393,7 +394,8 @@ void DialogFinalMeasurements::SaveFormula() try { - m_measurements[row].formula = qApp->TrVars()->FormulaFromUser(text, qApp->Settings()->GetOsSeparator()); + m_measurements[row].formula = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } catch (qmu::QmuParserError &e) // Just in case something bad will happen { @@ -453,9 +455,10 @@ void DialogFinalMeasurements::Fx() QScopedPointer dialog(new DialogEditWrongFormula(&m_data, NULL_ID, this)); dialog->setWindowTitle(tr("Edit measurement")); - dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), - qApp->Settings()->GetOsSeparator())); - const QString postfix = UnitsToStr(qApp->patternUnits(), true); + dialog->SetFormula(VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); dialog->setPostfix(postfix);//Show unit in dialog lable (cm, mm or inch) if (dialog->exec() == QDialog::Accepted) @@ -494,9 +497,12 @@ void DialogFinalMeasurements::FillFinalMeasurements(bool freshCall) bool ok = true; const qreal result = EvalFormula(m.formula, ok); - AddCell(qApp->LocaleToString(result), i, 1, Qt::AlignHCenter | Qt::AlignVCenter, ok); // calculated value + AddCell(VAbstractApplication::VApp() + ->LocaleToString(result), i, 1, Qt::AlignHCenter | Qt::AlignVCenter, ok); // calculated value - const QString formula = VTranslateVars::TryFormulaFromUser(m.formula, qApp->Settings()->GetOsSeparator()); + const QString formula = + VTranslateVars::TryFormulaFromUser(m.formula, + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); AddCell(formula, i, 2, Qt::AlignVCenter); // formula } @@ -513,7 +519,7 @@ void DialogFinalMeasurements::FillFinalMeasurements(bool freshCall) //--------------------------------------------------------------------------------------------------------------------- void DialogFinalMeasurements::ShowUnits() { - const QString unit = UnitsToStr(qApp->patternUnits()); + const QString unit = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); { // calculated value @@ -554,7 +560,8 @@ void DialogFinalMeasurements::AddCell(const QString &text, int row, int column, //--------------------------------------------------------------------------------------------------------------------- bool DialogFinalMeasurements::EvalUserFormula(const QString &formula, bool fromUser) { - const QString postfix = UnitsToStr(qApp->patternUnits());//Show unit in dialog lable (cm, mm or inch) + const QString postfix = + UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch) if (formula.isEmpty()) { ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); @@ -569,7 +576,8 @@ bool DialogFinalMeasurements::EvalUserFormula(const QString &formula, bool fromU // Replace line return character with spaces for calc if exist if (fromUser) { - f = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + f = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } else { @@ -586,7 +594,8 @@ bool DialogFinalMeasurements::EvalUserFormula(const QString &formula, bool fromU return false; } - ui->labelCalculatedValue->setText(qApp->LocaleToString(result) + QChar(QChar::Space) + postfix); + ui->labelCalculatedValue->setText( + VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix); ui->labelCalculatedValue->setToolTip(tr("Value")); return true; } diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index ec6c1ce22..dd38d51c9 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -58,7 +58,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) { ui->setupUi(this); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); bOk = ui->buttonBox->button(QDialogButtonBox::Ok); connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index da7c69478..c50fdd14e 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -90,7 +90,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par formulaBaseHeightPC = ui->plainTextEditFormulaPC->height(); ui->plainTextEditFormulaPC->installEventFilter(this); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); qCDebug(vDialog, "Showing variables."); ShowUnits(); @@ -214,7 +214,7 @@ void DialogIncrements::FillTable(const QMap &varTable, QTableWidget item->setFont(font); table->setItem(currentRow, 0, item); - item = new QTableWidgetItem(qApp->LocaleToString(length)); + item = new QTableWidgetItem(VAbstractApplication::VApp()->LocaleToString(length)); item->setTextAlignment(Qt::AlignHCenter); table->setItem(currentRow, 1, item); } @@ -268,7 +268,7 @@ void DialogIncrements::FillAnglesCurves() //--------------------------------------------------------------------------------------------------------------------- void DialogIncrements::ShowUnits() { - const QString unit = UnitsToStr(qApp->patternUnits()); + const QString unit = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); ShowHeaderUnits(ui->tableWidgetIncrement, 1, unit);// calculated value ShowHeaderUnits(ui->tableWidgetIncrement, 2, unit);// formula @@ -340,7 +340,8 @@ QString DialogIncrements::GetCustomName() const QString name; do { - name = CustomIncrSign + qApp->TrVars()->InternalVarToUser(increment_) + QString().number(num); + name = CustomIncrSign + VAbstractApplication::VApp()->TrVars()->InternalVarToUser(increment_) + + QString().number(num); num++; } while (not data->IsUnique(name)); return name; @@ -361,7 +362,8 @@ QString DialogIncrements::ClearIncrementName(const QString &name) const //--------------------------------------------------------------------------------------------------------------------- bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label) { - const QString postfix = UnitsToStr(qApp->patternUnits());//Show unit in dialog lable (cm, mm or inch) + const QString postfix = + UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch) if (formula.isEmpty()) { label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); @@ -376,7 +378,8 @@ bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUse // Replace line return character with spaces for calc if exist if (fromUser) { - f = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + f = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } else { @@ -392,7 +395,7 @@ bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUse return false; } - label->setText(qApp->LocaleToString(result) + QChar(QChar::Space) + postfix); + label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix); label->setToolTip(tr("Value")); return true; } @@ -729,7 +732,9 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table) EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue); plainTextEditFormula->blockSignals(true); - QString formula = VTranslateVars::TryFormulaToUser(incr->GetFormula(), qApp->Settings()->GetOsSeparator()); + QString formula = + VTranslateVars::TryFormulaToUser(incr->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); plainTextEditFormula->setPlainText(formula); plainTextEditFormula->blockSignals(false); @@ -906,10 +911,13 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table, if (incr->GetType() == VarType::Increment) { AddCell(table, incr->GetName(), currentRow, 0, Qt::AlignVCenter); // name - AddCell(table, qApp->LocaleToString(*incr->GetValue()), currentRow, 1, Qt::AlignCenter, + AddCell(table, VAbstractApplication::VApp()-> + LocaleToString(*incr->GetValue()), currentRow, 1, Qt::AlignCenter, incr->IsFormulaOk()); // calculated value - QString formula = VTranslateVars::TryFormulaToUser(incr->GetFormula(), qApp->Settings()->GetOsSeparator()); + QString formula = + VTranslateVars::TryFormulaToUser(incr->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); AddCell(table, formula, currentRow, 2, Qt::AlignVCenter); // formula @@ -1228,7 +1236,7 @@ void DialogIncrements::SaveIncrFormula() { QTableWidgetItem *result = table->item(row, 1); //Show unit in dialog lable (cm, mm or inch) - const QString postfix = UnitsToStr(qApp->patternUnits()); + const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix); return; } @@ -1236,7 +1244,7 @@ void DialogIncrements::SaveIncrFormula() if (text.isEmpty()) { //Show unit in dialog lable (cm, mm or inch) - const QString postfix = UnitsToStr(qApp->patternUnits()); + const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); return; } @@ -1254,7 +1262,8 @@ void DialogIncrements::SaveIncrFormula() try { - const QString formula = qApp->TrVars()->FormulaFromUser(text, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); doc->SetIncrementFormula(nameField->text(), formula); } catch (qmu::QmuParserError &e) // Just in case something bad will happen @@ -1372,9 +1381,10 @@ void DialogIncrements::Fx() dialog->setWindowTitle(tr("Edit increment")); incrementMode ? dialog->SetIncrementsMode() : dialog->SetPreviewCalculationsMode(); - dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(plainTextEditFormula->toPlainText(), - qApp->Settings()->GetOsSeparator())); - const QString postfix = UnitsToStr(qApp->patternUnits(), true); + dialog->SetFormula(VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(plainTextEditFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); dialog->setPostfix(postfix);//Show unit in dialog lable (cm, mm or inch) if (dialog->exec() == QDialog::Accepted) @@ -1434,7 +1444,7 @@ bool DialogIncrements::eventFilter(QObject *object, QEvent *event) QKeyEvent *keyEvent = static_cast(event); if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier)) { - if (qApp->Settings()->GetOsSeparator()) + if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) { textEdit->insert(QLocale().decimalPoint()); } @@ -1467,7 +1477,7 @@ void DialogIncrements::showEvent(QShowEvent *event) } // do your init stuff here - const QSize sz = qApp->Settings()->GetIncrementsDialogSize(); + const QSize sz = VAbstractApplication::VApp()->Settings()->GetIncrementsDialogSize(); if (not sz.isEmpty()) { resize(sz); @@ -1484,7 +1494,7 @@ void DialogIncrements::resizeEvent(QResizeEvent *event) // dialog creating, which would if (isInitialized) { - qApp->Settings()->SetIncrementsDialogSize(size()); + VAbstractApplication::VApp()->Settings()->SetIncrementsDialogSize(size()); } DialogTool::resizeEvent(event); } diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.cpp b/src/app/valentina/dialogs/dialoglayoutprogress.cpp index f8b2dd4db..c760b0b54 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.cpp +++ b/src/app/valentina/dialogs/dialoglayoutprogress.cpp @@ -48,7 +48,8 @@ DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, { ui->setupUi(this); - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) + : setLocale(QLocale::c()); ui->progressBar->setMaximum(static_cast(timeout/1000)); ui->progressBar->setValue(0); diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 9087e3c2c..87a573f6a 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -50,7 +50,8 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget { ui->setupUi(this); - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) + : setLocale(QLocale::c()); //moved from ReadSettings - well...it seems it can be done once only (i.e. constructor) because Init funcs dont //even cleanse lists before adding @@ -764,8 +765,9 @@ void DialogLayoutSettings::InitPaperUnits() ui->comboBoxPaperSizeUnit->addItem(tr("Pixels"), QVariant(UnitsToStr(Unit::Px))); // set default unit - oldPaperUnit = StrToUnits(qApp->ValentinaSettings()->GetUnit()); - const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(qApp->ValentinaSettings()->GetUnit()); + oldPaperUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); + const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData( + VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) { ui->comboBoxPaperSizeUnit->setCurrentIndex(indexUnit); @@ -780,8 +782,9 @@ void DialogLayoutSettings::InitLayoutUnits() ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch))); // set default unit - oldLayoutUnit = StrToUnits(qApp->ValentinaSettings()->GetUnit()); - const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(qApp->ValentinaSettings()->GetUnit()); + oldLayoutUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); + const qint32 indexUnit = ui->comboBoxLayoutUnit->findData( + VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) { ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); @@ -1016,7 +1019,7 @@ void DialogLayoutSettings::MinimumLayoutSize() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::ReadSettings() { - const VSettings *settings = qApp->ValentinaSettings(); + const VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); SetLayoutWidth(settings->GetLayoutWidth()); SetNestingTime(settings->GetNestingTime()); SetEfficiencyCoefficient(settings->GetEfficiencyCoefficient()); @@ -1048,7 +1051,7 @@ void DialogLayoutSettings::ReadSettings() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::WriteSettings() const { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetLayoutWidth(GetLayoutWidth()); settings->SetLayoutGroup(GetGroup()); settings->SetLayoutPaperHeight(GetPaperHeight()); diff --git a/src/app/valentina/dialogs/dialognewpattern.cpp b/src/app/valentina/dialogs/dialognewpattern.cpp index d3277640f..a84bd292f 100644 --- a/src/app/valentina/dialogs/dialognewpattern.cpp +++ b/src/app/valentina/dialogs/dialognewpattern.cpp @@ -46,7 +46,8 @@ DialogNewPattern::DialogNewPattern(VContainer *data, const QString &patternPiece ui->lineEditName->setClearButtonEnabled(true); - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) + : setLocale(QLocale::c()); QRect position = this->frameGeometry(); position.moveCenter(QGuiApplication::primaryScreen()->availableGeometry().center()); @@ -115,7 +116,8 @@ void DialogNewPattern::InitUnits() ui->comboBoxUnits->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch))); // set default unit - const qint32 indexUnit = ui->comboBoxUnits->findData(qApp->ValentinaSettings()->GetUnit()); + const qint32 indexUnit = ui->comboBoxUnits->findData( + VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) { ui->comboBoxUnits->setCurrentIndex(indexUnit); diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 142a50d64..30e261af4 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -67,10 +67,10 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat SCASSERT(doc != nullptr) - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - if (qApp->GetPatternPath().isEmpty()) + if (VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { ui->lineEditPathToFile->setText(tr("")); ui->lineEditPathToFile->setToolTip(tr("File was not saved yet.")); @@ -78,15 +78,15 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat } else { - ui->lineEditPathToFile->setText(QDir::toNativeSeparators(qApp->GetPatternPath())); - ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(qApp->GetPatternPath())); + ui->lineEditPathToFile->setText(QDir::toNativeSeparators(VAbstractValApplication::VApp()->GetPatternPath())); + ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(VAbstractValApplication::VApp()->GetPatternPath())); ui->pushButtonShowInExplorer->setEnabled(true); } ui->lineEditPathToFile->setCursorPosition(0); connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, []() { - ShowInGraphicalShell(qApp->GetPatternPath()); + ShowInGraphicalShell(VAbstractValApplication::VApp()->GetPatternPath()); }); #if defined(Q_OS_MAC) ui->pushButtonShowInExplorer->setText(tr("Show in Finder")); @@ -98,7 +98,8 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat ui->comboBoxLabelLanguage->addItem(QLocale(name).nativeLanguageName(), name); } - int index = ui->comboBoxLabelLanguage->findData(qApp->ValentinaSettings()->GetLabelLanguage()); + int index = ui->comboBoxLabelLanguage->findData( + VAbstractValApplication::VApp()->ValentinaSettings()->GetLabelLanguage()); if (index != -1) { ui->comboBoxLabelLanguage->setCurrentIndex(index); @@ -277,7 +278,7 @@ void DialogPatternProperties::ChangeImage() { const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)"); const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (not fileName.isEmpty()) { QImage image; @@ -319,7 +320,7 @@ void DialogPatternProperties::SaveImage() const QString extension = doc->GetImageExtension().prepend(QChar('.')); QString filter = tr("Images") + QStringLiteral(" (*") + extension + QChar(')'); QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (not filename.isEmpty()) { if (not filename.endsWith(extension.toUpper())) diff --git a/src/app/valentina/dialogs/dialogpreferences.cpp b/src/app/valentina/dialogs/dialogpreferences.cpp index 93543160a..83ae97e77 100644 --- a/src/app/valentina/dialogs/dialogpreferences.cpp +++ b/src/app/valentina/dialogs/dialogpreferences.cpp @@ -52,7 +52,7 @@ DialogPreferences::DialogPreferences(QWidget *parent) setWindowFlags(Qt::Window); #endif - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); SCASSERT(bOk != nullptr) @@ -91,7 +91,7 @@ void DialogPreferences::showEvent(QShowEvent *event) } // do your init stuff here - QSize sz = qApp->Settings()->GetPreferenceDialogSize(); + QSize sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize(); if (sz.isEmpty() == false) { resize(sz); @@ -109,7 +109,7 @@ void DialogPreferences::resizeEvent(QResizeEvent *event) // dialog creating, which would if (m_isInitialized) { - qApp->Settings()->SetPreferenceDialogSize(size()); + VAbstractApplication::VApp()->Settings()->SetPreferenceDialogSize(size()); } } @@ -155,7 +155,8 @@ void DialogPreferences::Apply() m_patternPage->InitDefaultSeamAllowance(); - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) + : setLocale(QLocale::c()); emit UpdateProperties(); setResult(QDialog::Accepted); } diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 295e6b48b..be039617f 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -69,7 +69,8 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName ui->lineEditPath->setClearButtonEnabled(true); ui->lineEditFileName->setClearButtonEnabled(true); - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) + : setLocale(QLocale::c()); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); SCASSERT(bOk != nullptr) @@ -120,7 +121,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName this, &DialogSaveLayout::ShowExample); connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]() { - const QString dirPath = qApp->ValentinaSettings()->GetPathLayout(); + const QString dirPath = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLayout(); bool usedNotExistedDir = false; QDir directory(dirPath); if (not directory.exists()) @@ -130,7 +131,8 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName const QString dir = QFileDialog::getExistingDirectory( this, tr("Select folder"), dirPath, - qApp->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); + VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly | + QFileDialog::DontResolveSymlinks)); if (not dir.isEmpty()) {// If paths equal the signal will not be called, we will do this manually dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir); @@ -144,7 +146,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName }); connect(ui->lineEditPath, &QLineEdit::textChanged, this, &DialogSaveLayout::PathChanged); - ui->lineEditPath->setText(qApp->ValentinaSettings()->GetPathLayout()); + ui->lineEditPath->setText(VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLayout()); InitTemplates(ui->comboBoxTemplates); @@ -680,7 +682,7 @@ void DialogSaveLayout::SetTiledExportMode(bool tiledExportMode) void DialogSaveLayout::SetTiledMargins(QMarginsF margins) { // read Margins top, right, bottom, left - margins = UnitConvertor(margins, Unit::Mm, qApp->patternUnits()); + margins = UnitConvertor(margins, Unit::Mm, VAbstractValApplication::VApp()->patternUnits()); ui->doubleSpinBoxLeftField->setValue(margins.left()); ui->doubleSpinBoxTopField->setValue(margins.top()); @@ -698,7 +700,7 @@ QMarginsF DialogSaveLayout::GetTiledMargins() const ui->doubleSpinBoxBottomField->value() ); - return UnitConvertor(margins, qApp->patternUnits(), Unit::Mm); + return UnitConvertor(margins, VAbstractValApplication::VApp()->patternUnits(), Unit::Mm); } //--------------------------------------------------------------------------------------------------------------------- @@ -873,8 +875,8 @@ void DialogSaveLayout::RemoveFormatFromList(LayoutExportFormats format) */ void DialogSaveLayout::ReadSettings() { - VSettings *settings = qApp->ValentinaSettings(); - const Unit unit = qApp->patternUnits(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + const Unit unit = VAbstractValApplication::VApp()->patternUnits(); // read Margins top, right, bottom, left const QMarginsF margins = settings->GetTiledPDFMargins(unit); @@ -927,8 +929,8 @@ void DialogSaveLayout::WriteSettings() const return; } - VSettings *settings = qApp->ValentinaSettings(); - const Unit unit = qApp->patternUnits(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + const Unit unit = VAbstractValApplication::VApp()->patternUnits(); // write Margins top, right, bottom, left QMarginsF margins = QMarginsF( diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index 73ab8b76c..9a5d04239 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -140,7 +140,7 @@ void VWidgetDetails::InLayoutStateChanged(int row, int column) TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, inLayout, m_data, m_doc); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); - qApp->getUndoStack()->push(togglePrint); + VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } //--------------------------------------------------------------------------------------------------------------------- @@ -189,7 +189,7 @@ void VWidgetDetails::ToggleSectionDetails(bool select) { TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); - qApp->getUndoStack()->push(togglePrint); + VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } } } @@ -334,20 +334,20 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos) if (selectedAction == actionSelectAll) { select = true; - qApp->getUndoStack()->beginMacro(tr("select all details")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("select all details")); ToggleSectionDetails(select); - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } else if (selectedAction == actionSelectNone) { select = false; - qApp->getUndoStack()->beginMacro(tr("select none details")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("select none details")); ToggleSectionDetails(select); - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } else if (selectedAction == actionInvertSelection) { - qApp->getUndoStack()->beginMacro(tr("invert selection")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("invert selection")); for (int i = 0; itableWidget->rowCount(); ++i) { @@ -359,11 +359,11 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos) TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); - qApp->getUndoStack()->push(togglePrint); + VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } } - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } else if (pieceMode && selectedAction == actionPieceOptions) { diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp index af6bb0c5a..33b9f1874 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.cpp +++ b/src/app/valentina/dialogs/vwidgetgroups.cpp @@ -80,7 +80,7 @@ void VWidgetGroups::SetGroupVisibility(vidtype id, bool visible) const : item->setIcon(QIcon(QStringLiteral("://icon/16x16/closed_eye.png"))); } }); - qApp->getUndoStack()->push(changeGroup); + VAbstractApplication::VApp()->getUndoStack()->push(changeGroup); } //--------------------------------------------------------------------------------------------------------------------- @@ -110,7 +110,7 @@ void VWidgetGroups::SetMultipleGroupsVisibility(const QVector &groups, } }); - qApp->getUndoStack()->push(changeGroups); + VAbstractApplication::VApp()->getUndoStack()->push(changeGroups); } //--------------------------------------------------------------------------------------------------------------------- @@ -179,7 +179,7 @@ void VWidgetGroups::RenameGroup(int row, int column) const quint32 id = ui->tableWidget->item(row, 0)->data(Qt::UserRole).toUInt(); ::RenameGroup *renameGroup = new ::RenameGroup(doc, id, ui->tableWidget->item(row, column)->text()); connect(renameGroup, &RenameGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups); - qApp->getUndoStack()->push(renameGroup); + VAbstractApplication::VApp()->getUndoStack()->push(renameGroup); } //--------------------------------------------------------------------------------------------------------------------- @@ -230,7 +230,8 @@ void VWidgetGroups::CtxMenu(const QPoint &pos) } else if (selectedAction == actionPreferences) { - QScopedPointer fackeContainer(new VContainer(qApp->TrVars(), qApp->patternUnitsP(), + QScopedPointer fackeContainer(new VContainer(VAbstractApplication::VApp()->TrVars(), + VAbstractValApplication::VApp()->patternUnitsP(), VContainer::UniqueNamespace())); QScopedPointer dialog(new DialogGroup(fackeContainer.data(), NULL_ID, this)); dialog->SetName(doc->GetGroupName(id)); @@ -243,14 +244,14 @@ void VWidgetGroups::CtxMenu(const QPoint &pos) ChangeGroupOptions *changeGroupOptions = new ChangeGroupOptions(doc, id, dialog->GetName(), dialog->GetTags()); connect(changeGroupOptions, &ChangeGroupOptions::UpdateGroups, this, &VWidgetGroups::UpdateGroups); - qApp->getUndoStack()->push(changeGroupOptions); + VAbstractApplication::VApp()->getUndoStack()->push(changeGroupOptions); } } else if (selectedAction == actionDelete) { DelGroup *delGroup = new DelGroup(doc, id); connect(delGroup, &DelGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups); - qApp->getUndoStack()->push(delGroup); + VAbstractApplication::VApp()->getUndoStack()->push(delGroup); } else if (selectedAction == actionHideAll) {//all groups in "group" make unvisible diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 1be52ee8a..ebbced7ab 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -173,8 +173,8 @@ void WarningNotUniquePieceName(const QHash *allDetails) else { const QString errorMsg = QObject::tr("Piece name '%1' is not unique.").arg(pieceName); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } ++i; @@ -236,7 +236,7 @@ MainWindow::MainWindow(QWidget *parent) }); connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP); connect(doc, &VPattern::MadeProgress, this, &MainWindow::ShowProgress); - qApp->setCurrentDocument(doc); + VAbstractValApplication::VApp()->setCurrentDocument(doc); InitDocksContain(); CreateMenus(); @@ -254,7 +254,8 @@ MainWindow::MainWindow(QWidget *parent) ToolBarTools(); - connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternChangesWereSaved); + connect(VAbstractApplication::VApp()->getUndoStack(), &QUndoStack::cleanChanged, this, + &MainWindow::PatternChangesWereSaved); InitAutoSave(); @@ -327,7 +328,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); QFont f = ui->plainTextEditPatternMessages->font(); if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize()) { @@ -339,7 +340,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); QFont f = ui->plainTextEditPatternMessages->font(); if (f.pointSize() > settings->GetDefMinPatternMessageFontSize()) { @@ -356,10 +357,11 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->toolButtonClearMessages, &QToolButton::clicked, this, &MainWindow::ClearPatternMessages); - ui->toolButtonAutoRefresh->setChecked(qApp->ValentinaSettings()->GetAutoRefreshPatternMessage()); + ui->toolButtonAutoRefresh->setChecked( + VAbstractValApplication::VApp()->ValentinaSettings()->GetAutoRefreshPatternMessage()); connect(ui->toolButtonAutoRefresh, &QToolButton::clicked, this, [](bool checked) { - qApp->ValentinaSettings()->SetAutoRefreshPatternMessage(checked); + VAbstractValApplication::VApp()->ValentinaSettings()->SetAutoRefreshPatternMessage(checked); }); connect(doc, &VPattern::PreParseState, this, [this]() @@ -461,7 +463,7 @@ void MainWindow::InitScenes() { sceneDraw = new VMainGraphicsScene(this); currentScene = sceneDraw; - qApp->setCurrentScene(¤tScene); + VAbstractValApplication::VApp()->setCurrentScene(¤tScene); connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove); connect(this, &MainWindow::ItemsSelection, sceneDraw, &VMainGraphicsScene::ItemsSelection); @@ -507,7 +509,7 @@ void MainWindow::InitScenes() QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); policy.setHorizontalStretch(12); ui->view->setSizePolicy(policy); - qApp->setSceneView(ui->view); + VAbstractValApplication::VApp()->setSceneView(ui->view); } //--------------------------------------------------------------------------------------------------------------------- @@ -522,12 +524,12 @@ bool MainWindow::LoadMeasurements(const QString &path) try { - qApp->SetMeasurementsType(m->Type()); + VAbstractValApplication::VApp()->SetMeasurementsType(m->Type()); if (m->Type() == MeasurementsType::Individual) { - qApp->SetCustomerName(m->Customer()); - qApp->SetCustomerBirthDate(m->BirthDate()); - qApp->SetCustomerEmail(m->Email()); + VAbstractValApplication::VApp()->SetCustomerName(m->Customer()); + VAbstractValApplication::VApp()->SetCustomerBirthDate(m->BirthDate()); + VAbstractValApplication::VApp()->SetCustomerEmail(m->Email()); } else if (m->Type() == MeasurementsType::Multisize) { @@ -580,7 +582,7 @@ bool MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal base return false; } - if (qApp->GetMeasurementsType() != m->Type()) + if (VAbstractValApplication::VApp()->GetMeasurementsType() != m->Type()) { qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Measurement files types have not match."))); if (not VApplication::IsGUIMode()) @@ -604,9 +606,9 @@ bool MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal base m->ReadMeasurements(baseA, baseB, baseC); if (m->Type() == MeasurementsType::Individual) { - qApp->SetCustomerName(m->Customer()); - qApp->SetCustomerBirthDate(m->BirthDate()); - qApp->SetCustomerEmail(m->Email()); + VAbstractValApplication::VApp()->SetCustomerName(m->Customer()); + VAbstractValApplication::VApp()->SetCustomerBirthDate(m->BirthDate()); + VAbstractValApplication::VApp()->SetCustomerEmail(m->Email()); } } catch (VExceptionEmptyParameter &e) @@ -1297,7 +1299,7 @@ void MainWindow::ClosedDialogGroup(int result) { AddGroup *addGroup = new AddGroup(group, doc); connect(addGroup, &AddGroup::UpdateGroups, groupsWidget, &VWidgetGroups::UpdateGroups); - qApp->getUndoStack()->push(addGroup); + VAbstractApplication::VApp()->getUndoStack()->push(addGroup); } } ArrowTool(true); @@ -1581,7 +1583,7 @@ void MainWindow::changeEvent(QEvent *event) statusBar()->showMessage(tr("Changes applied."), 5000); patternPieceLabel->setText(tr("Pattern Piece:")); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VApplication::VApp()->GetDrawMode() == Draw::Calculation) { ui->dockWidgetGroups->setWindowTitle(tr("Groups of visibility")); ui->dockWidgetGroups->setToolTip(tr("Contains all visibility groups")); @@ -1637,7 +1639,7 @@ void MainWindow::customEvent(QEvent *event) { if (event->type() == UNDO_EVENT) { - qApp->getUndoStack()->undo(); + VAbstractApplication::VApp()->getUndoStack()->undo(); } else if (event->type() == FIT_BEST_CURRENT_EVENT) { @@ -1719,10 +1721,12 @@ void MainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int m csv.insertRow(currentRow); csv.setText(currentRow, 0, incr->GetName()); // name - csv.setText(currentRow, 1, qApp->LocaleToString(*incr->GetValue())); // calculated value + csv.setText(currentRow, 1, + VAbstractApplication::VApp()->LocaleToString(*incr->GetValue())); // calculated value - QString formula = VTranslateVars::TryFormulaToUser(incr->GetFormula(), - qApp->Settings()->GetOsSeparator()); + QString formula = + VTranslateVars::TryFormulaToUser(incr->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); csv.setText(currentRow, 2, formula); // formula } }; @@ -1741,7 +1745,8 @@ void MainWindow::ToolBarStyle(QToolBar *bar) const #if defined(Q_OS_MAC) // Temporary fix issue with toolbar black background on mac with OpenGL render - if (qApp->getSceneView() && qApp->getSceneView()->IsOpenGLRender()) + if (VAbstractValApplication::VApp()->getSceneView() && + VAbstractValApplication::VApp()->getSceneView()->IsOpenGLRender()) { bar->setStyle(QStyleFactory::create("fusion")); } @@ -1768,7 +1773,7 @@ void MainWindow::LoadIndividual() const QString filter = tr("Individual measurements") + QLatin1String(" (*.vit);;") + tr("Multisize measurements") + QLatin1String(" (*.vst)"); //Use standard path to individual measurements - const QString path = qApp->ValentinaSettings()->GetPathIndividualMeasurements(); + const QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathIndividualMeasurements(); bool usedNotExistedDir = false; QDir directory(path); @@ -1778,7 +1783,7 @@ void MainWindow::LoadIndividual() } const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (not mPath.isEmpty()) { @@ -1786,10 +1791,10 @@ void MainWindow::LoadIndividual() { if (not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath())); + watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); } ui->actionUnloadMeasurements->setEnabled(true); - doc->SetMPath(RelativeMPath(qApp->GetPatternPath(), mPath)); + doc->SetMPath(RelativeMPath(VAbstractValApplication::VApp()->GetPatternPath(), mPath)); watcher->addPath(mPath); PatternChangesWereSaved(false); ui->actionEditCurrent->setEnabled(true); @@ -1813,10 +1818,10 @@ void MainWindow::LoadMultisize() const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst);;") + tr("Individual measurements") + QLatin1String("(*.vit)"); //Use standard path to multisize measurements - QString path = qApp->ValentinaSettings()->GetPathMultisizeMeasurements(); + QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathMultisizeMeasurements(); path = VCommonSettings::PrepareMultisizeTables(path); const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (not mPath.isEmpty()) { @@ -1824,10 +1829,10 @@ void MainWindow::LoadMultisize() { if (not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath())); + watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); } ui->actionUnloadMeasurements->setEnabled(true); - doc->SetMPath(RelativeMPath(qApp->GetPatternPath(), mPath)); + doc->SetMPath(RelativeMPath(VAbstractValApplication::VApp()->GetPatternPath(), mPath)); watcher->addPath(mPath); PatternChangesWereSaved(false); ui->actionEditCurrent->setEnabled(true); @@ -1850,17 +1855,17 @@ void MainWindow::UnloadMeasurements() if (doc->ListMeasurements().isEmpty()) { - watcher->removePath(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath())); + watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); - const MeasurementsType oldType = qApp->GetMeasurementsType(); - qApp->SetMeasurementsType(MeasurementsType::Unknown); + const MeasurementsType oldType = VAbstractValApplication::VApp()->GetMeasurementsType(); + VAbstractValApplication::VApp()->SetMeasurementsType(MeasurementsType::Unknown); m.clear(); - qApp->SetDimensionHeight(0); - qApp->SetDimensionSize(0); - qApp->SetDimensionHip(0); - qApp->SetDimensionWaist(0); + VAbstractValApplication::VApp()->SetDimensionHeight(0); + VAbstractValApplication::VApp()->SetDimensionSize(0); + VAbstractValApplication::VApp()->SetDimensionHip(0); + VAbstractValApplication::VApp()->SetDimensionWaist(0); if (oldType == MeasurementsType::Multisize) { @@ -1872,11 +1877,11 @@ void MainWindow::UnloadMeasurements() } else if (oldType == MeasurementsType::Individual) { - qApp->SetCustomerBirthDate(QDate()); - qApp->SetCustomerEmail(QString()); - qApp->SetCustomerName(QString()); - qApp->SetMeasurementsUnits(Unit::LAST_UNIT_DO_NOT_USE); - qApp->SetDimensionSizeUnits(Unit::LAST_UNIT_DO_NOT_USE); + VAbstractValApplication::VApp()->SetCustomerBirthDate(QDate()); + VAbstractValApplication::VApp()->SetCustomerEmail(QString()); + VAbstractValApplication::VApp()->SetCustomerName(QString()); + VAbstractValApplication::VApp()->SetMeasurementsUnits(Unit::LAST_UNIT_DO_NOT_USE); + VAbstractValApplication::VApp()->SetDimensionSizeUnits(Unit::LAST_UNIT_DO_NOT_USE); } doc->SetMPath(QString()); @@ -1900,14 +1905,14 @@ void MainWindow::ShowMeasurements() { if (not doc->MPath().isEmpty()) { - const QString absoluteMPath = AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()); + const QString absoluteMPath = AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath()); QStringList arguments; arguments.append(absoluteMPath); arguments.append("-u"); - arguments.append(UnitsToStr(qApp->patternUnits())); + arguments.append(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { if (m_currentDimensionA > 0) { @@ -1933,7 +1938,7 @@ void MainWindow::ShowMeasurements() arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); } - const QString tape = qApp->TapeFilePath(); + const QString tape = VApplication::VApp()->TapeFilePath(); const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); QProcess::startDetached(tape, arguments, workingDirectory); } @@ -1981,7 +1986,7 @@ void MainWindow::SyncMeasurements() { if (mChanges) { - const QString path = AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()); + const QString path = AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath()); // Temporarily remove the path to prevent infinite synchronization after a format conversion. watcher->removePath(path); @@ -2037,7 +2042,7 @@ void MainWindow::LoadWatermark() QString dir = QDir::homePath(); qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (filePath.isEmpty()) { return; @@ -2078,7 +2083,7 @@ void MainWindow::CleanWaterkmarkEditors() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::StoreMultisizeMDimensions() { - qApp->SetMeasurementsUnits(m->MUnit()); + VAbstractValApplication::VApp()->SetMeasurementsUnits(m->MUnit()); QList dimensions = m->Dimensions().values(); @@ -2091,26 +2096,27 @@ void MainWindow::StoreMultisizeMDimensions() switch(dimension->Type()) { case MeasurementDimension::X: - qApp->SetDimensionHeight(currentBase); + VAbstractValApplication::VApp()->SetDimensionHeight(currentBase); break; case MeasurementDimension::Y: { const bool fc = m->IsFullCircumference(); - qApp->SetDimensionSize(fc ? currentBase*2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionSize(fc ? currentBase*2 : currentBase); const bool circumference = dimension->IsCircumference(); - qApp->SetDimensionSizeUnits(circumference ? m->MUnit() : Unit::LAST_UNIT_DO_NOT_USE); + VAbstractValApplication::VApp() + ->SetDimensionSizeUnits(circumference ? m->MUnit() : Unit::LAST_UNIT_DO_NOT_USE); break; } case MeasurementDimension::W: { const bool fc = m->IsFullCircumference(); - qApp->SetDimensionWaist(fc ? currentBase*2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionWaist(fc ? currentBase*2 : currentBase); break; } case MeasurementDimension::Z: { const bool fc = m->IsFullCircumference(); - qApp->SetDimensionHip(fc ? currentBase*2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionHip(fc ? currentBase*2 : currentBase); break; } default: @@ -2131,21 +2137,21 @@ void MainWindow::StoreIndividualMDimensions() auto StoreDimension = [this, measurements](IMD type) { - const QString name = qApp->TrVars()->VarToUser(m->MeasurementForDimension(type)); + const QString name = VAbstractApplication::VApp()->TrVars()->VarToUser(m->MeasurementForDimension(type)); const bool valid = not name.isEmpty() && measurements.contains(name); switch(type) { case IMD::X: - qApp->SetDimensionHeight(valid ? *measurements.value(name)->GetValue() : 0); + VAbstractValApplication::VApp()->SetDimensionHeight(valid ? *measurements.value(name)->GetValue() : 0); break; case IMD::Y: - qApp->SetDimensionSize(valid ? *measurements.value(name)->GetValue() : 0); + VAbstractValApplication::VApp()->SetDimensionSize(valid ? *measurements.value(name)->GetValue() : 0); break; case IMD::W: - qApp->SetDimensionWaist(valid ? *measurements.value(name)->GetValue() : 0); + VAbstractValApplication::VApp()->SetDimensionWaist(valid ? *measurements.value(name)->GetValue() : 0); break; case IMD::Z: - qApp->SetDimensionHip(valid ? *measurements.value(name)->GetValue() : 0); + VAbstractValApplication::VApp()->SetDimensionHip(valid ? *measurements.value(name)->GetValue() : 0); break; case IMD::N: default: @@ -2228,8 +2234,9 @@ void MainWindow::SetDimensionBases() #if defined(Q_OS_MAC) void MainWindow::OpenAt(QAction *where) { - const QString path = qApp->GetPatternPath().left(qApp->GetPatternPath().indexOf(where->text())) + where->text(); - if (path == qApp->GetPatternPath()) + const QString path = VAbstractValApplication::VApp()->GetPatternPath() + .left(VAbstractValApplication::VApp()->GetPatternPath().indexOf(where->text())) + where->text(); + if (path == VAbstractValApplication::VApp()->GetPatternPath()) { return; } @@ -2281,7 +2288,8 @@ void MainWindow::ToolBarOption() ui->toolBarOption->addSeparator(); - m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnits(), true))); + m_mouseCoordinate = new QLabel(QString("0, 0 (%1)") + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); ui->toolBarOption->addWidget(m_mouseCoordinate); ui->toolBarOption->addSeparator(); @@ -2326,7 +2334,7 @@ void MainWindow::ToolBarDraws() { return; } - qApp->getUndoStack()->push(new RenamePP(doc, draw, comboBoxDraws)); + VAbstractApplication::VApp()->getUndoStack()->push(new RenamePP(doc, draw, comboBoxDraws)); }); } @@ -2372,7 +2380,7 @@ void MainWindow::ToolBarTools() ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus)); connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetLabelFontSize(settings->GetLabelFontSize() + 1); if (sceneDraw) { @@ -2388,7 +2396,7 @@ void MainWindow::ToolBarTools() ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus)); connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetLabelFontSize(settings->GetLabelFontSize() - 1); if (sceneDraw) { @@ -2404,7 +2412,7 @@ void MainWindow::ToolBarTools() ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0)); connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetLabelFontSize(settings->GetDefLabelFontSize()); if (sceneDraw) { @@ -2420,7 +2428,7 @@ void MainWindow::ToolBarTools() ui->actionHideLabels->setShortcut(QKeySequence(Qt::AltModifier + Qt::Key_L)); connect(ui->actionHideLabels, &QAction::triggered, this, [this](bool checked) { - qApp->ValentinaSettings()->SetHideLabels(checked); + VAbstractValApplication::VApp()->ValentinaSettings()->SetHideLabels(checked); if (sceneDraw) { sceneDraw->update(); @@ -2513,9 +2521,9 @@ void MainWindow::MouseMove(const QPointF &scenePos) if (not m_mouseCoordinate.isNull()) { m_mouseCoordinate->setText(QStringLiteral("%1, %2 (%3)") - .arg(static_cast(qApp->fromPixel(scenePos.x()))) - .arg(static_cast(qApp->fromPixel(scenePos.y()))) - .arg(UnitsToStr(qApp->patternUnits(), true))); + .arg(static_cast(VAbstractValApplication::VApp()->fromPixel(scenePos.x()))) + .arg(static_cast(VAbstractValApplication::VApp()->fromPixel(scenePos.y()))) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); } } @@ -2707,8 +2715,8 @@ void MainWindow::CancelTool() // Crash: using CRTL+Z while using line tool. // related bug report: // https://bitbucket.org/dismine/valentina/issues/454/crash-using-crtl-z-while-using-line-tool - undoAction->setEnabled(qApp->getUndoStack()->canUndo()); - redoAction->setEnabled(qApp->getUndoStack()->canRedo()); + undoAction->setEnabled(VAbstractApplication::VApp()->getUndoStack()->canUndo()); + redoAction->setEnabled(VAbstractApplication::VApp()->getUndoStack()->canRedo()); } QT_WARNING_POP @@ -2801,7 +2809,8 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ) */ void MainWindow::SaveCurrentScene() { - if (qApp->GetDrawMode() == Draw::Calculation || qApp->GetDrawMode() == Draw::Modeling) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation || + VAbstractValApplication::VApp()->GetDrawMode() == Draw::Modeling) { VMainGraphicsScene *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) @@ -2858,7 +2867,7 @@ void MainWindow::ActionDraw(bool checked) ui->view->setScene(currentScene); RestoreCurrentScene(); - qApp->SetDrawMode(Draw::Calculation); + VAbstractValApplication::VApp()->SetDrawMode(Draw::Calculation); comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace drawMode = true; @@ -2866,7 +2875,7 @@ void MainWindow::ActionDraw(bool checked) SetEnableWidgets(true); ui->toolBox->setCurrentIndex(currentToolBoxIndex); - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { ui->toolBarOption->setVisible(true); } @@ -2910,7 +2919,7 @@ void MainWindow::ActionDetails(bool checked) ui->actionDetails->setChecked(true); ui->actionLayout->setChecked(false); - if(not qApp->getOpeningPattern()) + if(not VAbstractValApplication::VApp()->getOpeningPattern()) { if (pattern->DataPieces()->count() == 0) { @@ -2932,16 +2941,16 @@ void MainWindow::ActionDetails(bool checked) ui->view->setScene(currentScene); RestoreCurrentScene(); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { currentToolBoxIndex = ui->toolBox->currentIndex(); } - qApp->SetDrawMode(Draw::Modeling); + VAbstractValApplication::VApp()->SetDrawMode(Draw::Modeling); SetEnableTool(true); SetEnableWidgets(true); ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->detailPage)); - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { ui->toolBarOption->setVisible(true); } @@ -2991,7 +3000,7 @@ void MainWindow::ActionLayout(bool checked) ui->actionLayout->setChecked(true); QVector details; - if(not qApp->getOpeningPattern()) + if(not VAbstractValApplication::VApp()->getOpeningPattern()) { const QHash *allDetails = pattern->DataPieces(); if (allDetails->count() == 0) @@ -3012,7 +3021,8 @@ void MainWindow::ActionLayout(bool checked) QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. Please, " "include at least one detail in layout."), QMessageBox::Ok, QMessageBox::Ok); - qApp->GetDrawMode() == Draw::Calculation ? ActionDraw(true) : ActionDetails(true); + VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) + : ActionDetails(true); return; } } @@ -3034,7 +3044,8 @@ void MainWindow::ActionLayout(bool checked) QMessageBox::warning(this, tr("Layout mode"), tr("You can't use Layout mode yet.") + QLatin1String(" \n") + e.ErrorMessage(), QMessageBox::Ok, QMessageBox::Ok); - qApp->GetDrawMode() == Draw::Calculation ? ActionDraw(true) : ActionDetails(true); + VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) + : ActionDetails(true); return; } @@ -3042,11 +3053,11 @@ void MainWindow::ActionLayout(bool checked) emit ui->view->itemClicked(nullptr); ui->view->setScene(currentScene); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { currentToolBoxIndex = ui->toolBox->currentIndex(); } - qApp->SetDrawMode(Draw::Layout); + VAbstractValApplication::VApp()->SetDrawMode(Draw::Layout); SetEnableTool(true); SetEnableWidgets(true); ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->layoutPage)); @@ -3056,7 +3067,7 @@ void MainWindow::ActionLayout(bool checked) m_mouseCoordinate->setText(QString()); } - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { ui->toolBarOption->setVisible(false); } @@ -3093,16 +3104,16 @@ void MainWindow::ActionLayout(bool checked) */ bool MainWindow::on_actionSaveAs_triggered() { - const QString oldFilePath = qApp->GetPatternPath(); + const QString oldFilePath = VAbstractValApplication::VApp()->GetPatternPath(); QString filters(tr("Pattern files") + QLatin1String("(*.val)")); QString dir; - if (qApp->GetPatternPath().isEmpty()) + if (VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { - dir = qApp->ValentinaSettings()->GetPathPattern(); + dir = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathPattern(); } else { - dir = QFileInfo(qApp->GetPatternPath()).absolutePath(); + dir = QFileInfo(VAbstractValApplication::VApp()->GetPatternPath()).absolutePath(); } bool usedNotExistedDir = false; @@ -3114,7 +3125,7 @@ bool MainWindow::on_actionSaveAs_triggered() QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QLatin1String("/") + tr("pattern") + QLatin1String(".val"), - filters, nullptr, qApp->NativeFileDialog()); + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() { @@ -3136,7 +3147,7 @@ bool MainWindow::on_actionSaveAs_triggered() fileName += QLatin1String(".val"); } - if (f.exists() && qApp->GetPatternPath() != fileName) + if (f.exists() && VAbstractValApplication::VApp()->GetPatternPath() != fileName) { // Temporary try to lock the file before saving // Also help to rewite current read-only pattern @@ -3175,9 +3186,9 @@ bool MainWindow::on_actionSaveAs_triggered() else if (not oldFilePath.isEmpty()) { qCDebug(vMainWindow, "Updating restore file list."); - QStringList restoreFiles = qApp->ValentinaSettings()->GetRestoreFileList(); + QStringList restoreFiles = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); restoreFiles.removeAll(oldFilePath); - qApp->ValentinaSettings()->SetRestoreFileList(restoreFiles); + VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(restoreFiles); QFile::remove(oldFilePath + *autosavePrefix); } @@ -3186,7 +3197,7 @@ bool MainWindow::on_actionSaveAs_triggered() patternReadOnly = false; qCDebug(vMainWindow, "Locking file"); - if (qApp->GetPatternPath() == fileName && not lock.isNull()) + if (VAbstractValApplication::VApp()->GetPatternPath() == fileName && not lock.isNull()) { lock->Unlock(); } @@ -3215,7 +3226,7 @@ bool MainWindow::on_actionSaveAs_triggered() */ bool MainWindow::on_actionSave_triggered() { - if (qApp->GetPatternPath().isEmpty() || patternReadOnly) + if (VAbstractValApplication::VApp()->GetPatternPath().isEmpty() || patternReadOnly) { return on_actionSaveAs_triggered(); } @@ -3230,7 +3241,7 @@ bool MainWindow::on_actionSave_triggered() #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup++; // turn checking on #endif /*Q_OS_WIN32*/ - const bool isFileWritable = QFileInfo(qApp->GetPatternPath()).isWritable(); + const bool isFileWritable = QFileInfo(VAbstractValApplication::VApp()->GetPatternPath()).isWritable(); #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again #endif /*Q_OS_WIN32*/ @@ -3248,8 +3259,10 @@ bool MainWindow::on_actionSave_triggered() #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup++; // turn checking on #endif /*Q_OS_WIN32*/ - bool changed = QFile::setPermissions(qApp->GetPatternPath(), - QFileInfo(qApp->GetPatternPath()).permissions() | QFileDevice::WriteUser); + bool changed = + QFile::setPermissions(VAbstractValApplication::VApp()->GetPatternPath(), + QFileInfo(VAbstractValApplication::VApp() + ->GetPatternPath()).permissions() | QFileDevice::WriteUser); #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again #endif /*Q_OS_WIN32*/ @@ -3258,7 +3271,8 @@ bool MainWindow::on_actionSave_triggered() { QMessageBox messageBox(this); messageBox.setIcon(QMessageBox::Warning); - messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(qApp->GetPatternPath())); + messageBox.setText(tr("Cannot set permissions for %1 to writable.") + .arg(VAbstractValApplication::VApp()->GetPatternPath())); messageBox.setInformativeText(tr("Could not save the file.")); messageBox.setDefaultButton(QMessageBox::Ok); messageBox.setStandardButtons(QMessageBox::Ok); @@ -3273,10 +3287,10 @@ bool MainWindow::on_actionSave_triggered() } QString error; - bool result = SavePattern(qApp->GetPatternPath(), error); + bool result = SavePattern(VAbstractValApplication::VApp()->GetPatternPath(), error); if (result) { - QFile::remove(qApp->GetPatternPath() + *autosavePrefix); + QFile::remove(VAbstractValApplication::VApp()->GetPatternPath() + *autosavePrefix); m_curFileFormatVersion = VPatternConverter::PatternMaxVer; m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr; } @@ -3303,7 +3317,7 @@ void MainWindow::on_actionOpen_triggered() qCDebug(vMainWindow, "Openning new file."); const QString filter(tr("Pattern files") + QLatin1String(" (*.val)")); //Get list last open files - const QStringList files = qApp->ValentinaSettings()->GetRecentFileList(); + const QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRecentFileList(); QString dir; if (files.isEmpty()) { @@ -3316,7 +3330,7 @@ void MainWindow::on_actionOpen_triggered() } qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (filePath.isEmpty()) { return; @@ -3338,9 +3352,9 @@ void MainWindow::Clear() setCurrentFile(QString());// Keep before cleaning a pattern data to prevent a crash pattern->Clear(); qCDebug(vMainWindow, "Clearing pattern."); - if (not qApp->GetPatternPath().isEmpty() && not doc->MPath().isEmpty()) + if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() && not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath())); + watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); } doc->Clear(); UpdateWindowTitle(); @@ -3380,15 +3394,15 @@ void MainWindow::Clear() ui->actionPreviousPatternPiece->setEnabled(false); ui->actionNextPatternPiece->setEnabled(false); SetEnableTool(false); - qApp->SetPatternUnits(Unit::Cm); - qApp->SetMeasurementsType(MeasurementsType::Unknown); + VAbstractValApplication::VApp()->SetPatternUnits(Unit::Cm); + VAbstractValApplication::VApp()->SetMeasurementsType(MeasurementsType::Unknown); ui->toolBarOption->clear(); #ifndef QT_NO_CURSOR QGuiApplication::restoreOverrideCursor(); #endif CleanLayout(); listDetails.clear(); // don't move to CleanLayout() - qApp->getUndoStack()->clear(); + VAbstractApplication::VApp()->getUndoStack()->clear(); toolOptions->ClearPropertyBrowser(); toolOptions->itemClicked(nullptr); m_progressBar->setVisible(false); @@ -3412,17 +3426,17 @@ void MainWindow::FileClosedCorrect() WriteSettings(); //File was closed correct. - QStringList restoreFiles = qApp->ValentinaSettings()->GetRestoreFileList(); - restoreFiles.removeAll(qApp->GetPatternPath()); - qApp->ValentinaSettings()->SetRestoreFileList(restoreFiles); + QStringList restoreFiles = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); + restoreFiles.removeAll(VAbstractValApplication::VApp()->GetPatternPath()); + VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(restoreFiles); // Remove autosave file - QFile autofile(qApp->GetPatternPath() + *autosavePrefix); + QFile autofile(VAbstractValApplication::VApp()->GetPatternPath() + *autosavePrefix); if (autofile.exists()) { autofile.remove(); } - qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(qApp->GetPatternPath())); + qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(VAbstractValApplication::VApp()->GetPatternPath())); } //--------------------------------------------------------------------------------------------------------------------- @@ -3447,7 +3461,7 @@ void MainWindow::FullParseFile() try { - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { futureTestUniqueId = QtConcurrent::run(static_cast(doc), &VDomDocument::TestUniqueId); } @@ -3455,7 +3469,7 @@ void MainWindow::FullParseFile() SetEnabledGUI(true); doc->Parse(Document::FullParse); - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { futureTestUniqueId.waitForFinished(); } @@ -3464,7 +3478,7 @@ void MainWindow::FullParseFile() { /* If user want undo last operation before undo we need finish broken redo operation. For those we post event * myself. Later in method customEvent call undo.*/ - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { try { @@ -3490,7 +3504,7 @@ void MainWindow::FullParseFile() qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807 qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); SetEnabledGUI(false); - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { WaitForFutureFinish(futureTestUniqueId); } @@ -3505,7 +3519,7 @@ void MainWindow::FullParseFile() qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); SetEnabledGUI(false); - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { WaitForFutureFinish(futureTestUniqueId); } @@ -3520,7 +3534,7 @@ void MainWindow::FullParseFile() qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); SetEnabledGUI(false); - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { WaitForFutureFinish(futureTestUniqueId); } @@ -3535,7 +3549,7 @@ void MainWindow::FullParseFile() qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); SetEnabledGUI(false); - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { WaitForFutureFinish(futureTestUniqueId); } @@ -3550,7 +3564,7 @@ void MainWindow::FullParseFile() qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); SetEnabledGUI(false); - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { WaitForFutureFinish(futureTestUniqueId); } @@ -3564,7 +3578,7 @@ void MainWindow::FullParseFile() { qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc)."))); SetEnabledGUI(false); - if (qApp->getOpeningPattern()) + if (VAbstractValApplication::VApp()->getOpeningPattern()) { WaitForFutureFinish(futureTestUniqueId); } @@ -3607,8 +3621,8 @@ void MainWindow::FullParseFile() SetEnableTool(comboBoxDraws->count() > 0); detailsWidget->UpdateList(); - VMainGraphicsView::NewSceneRect(sceneDraw, qApp->getSceneView()); - VMainGraphicsView::NewSceneRect(sceneDetails, qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(sceneDraw, VAbstractValApplication::VApp()->getSceneView()); + VMainGraphicsView::NewSceneRect(sceneDetails, VAbstractValApplication::VApp()->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- @@ -3705,7 +3719,7 @@ void MainWindow::SetEnabledGUI(bool enabled) if (enabled == false) { ArrowTool(true); - qApp->getUndoStack()->clear(); + VAbstractApplication::VApp()->getUndoStack()->clear(); } SetEnableWidgets(enabled); @@ -3726,8 +3740,8 @@ void MainWindow::SetEnabledGUI(bool enabled) */ void MainWindow::SetEnableWidgets(bool enable) { - const bool drawStage = (qApp->GetDrawMode() == Draw::Calculation); - const bool detailsStage = (qApp->GetDrawMode() == Draw::Modeling); + const bool drawStage = (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation); + const bool detailsStage = (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Modeling); const bool designStage = (drawStage || detailsStage); comboBoxDraws->setEnabled(enable && drawStage); @@ -3770,8 +3784,8 @@ void MainWindow::SetEnableWidgets(bool enable) actionDockWidgetToolOptions->setEnabled(enable && designStage); actionDockWidgetGroups->setEnabled(enable && designStage); - undoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canUndo()); - redoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canRedo()); + undoAction->setEnabled(enable && designStage && VAbstractApplication::VApp()->getUndoStack()->canUndo()); + redoAction->setEnabled(enable && designStage && VAbstractApplication::VApp()->getUndoStack()->canRedo()); //Now we don't want allow user call context menu sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP()); @@ -3795,7 +3809,7 @@ void MainWindow::on_actionNew_triggered() if (newPattern.exec() == QDialog::Accepted) { patternPieceName = newPattern.name(); - qApp->SetPatternUnits(newPattern.PatternUnit()); + VAbstractValApplication::VApp()->SetPatternUnits(newPattern.PatternUnit()); qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName)); } else @@ -3810,7 +3824,8 @@ void MainWindow::on_actionNew_triggered() AddPP(patternPieceName); - m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnits(), true))); + m_mouseCoordinate = new QLabel(QString("0, 0 (%1)") + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); ui->toolBarOption->addWidget(m_mouseCoordinate); m_curFileFormatVersion = VPatternConverter::PatternMaxVer; @@ -3901,8 +3916,8 @@ void MainWindow::DimensionCBaseChanged() void MainWindow::GradationChanged() { m_gradation->stop(); - if (UpdateMeasurements(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()), m_currentDimensionA, - m_currentDimensionB, m_currentDimensionC)) + if (UpdateMeasurements(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath()), + m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)) { doc->LiteParseTree(Document::FullLiteParse); emit sceneDetails->DimensionsChanged(); @@ -3967,10 +3982,10 @@ void MainWindow::InitDimensionControls() delete dimensionCLabel; } - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { const QList dimensions = m->Dimensions().values(); - const QString unit = UnitsToStr(qApp->MeasurementsUnits(), true); + const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); auto InitControl = [this, dimensions, unit](int index, QPointer &name, QPointer &control) { @@ -4035,7 +4050,7 @@ void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p SCASSERT(control != nullptr) const bool fc = m->IsFullCircumference(); - const QString unit = UnitsToStr(qApp->MeasurementsUnits(), true); + const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); qreal current = -1; if (control->currentIndex() != -1) @@ -4129,7 +4144,7 @@ void MainWindow::SetEnableTool(bool enable) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") - switch (qApp->GetDrawMode()) + switch (VAbstractValApplication::VApp()->GetDrawMode()) { case Draw::Calculation: drawTools = enable; @@ -4242,8 +4257,8 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) qCDebug(vMainWindow, "Saving pattern file %s.", qUtf8Printable(fileName)); QFileInfo tempInfo(fileName); - const QString mPath = AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()); - if (not mPath.isEmpty() && qApp->GetPatternPath() != fileName) + const QString mPath = AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath()); + if (not mPath.isEmpty() && VAbstractValApplication::VApp()->GetPatternPath() != fileName) { doc->SetMPath(RelativeMPath(fileName, mPath)); } @@ -4274,11 +4289,11 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) */ void MainWindow::AutoSavePattern() { - if (not qApp->GetPatternPath().isEmpty() && isWindowModified() && isNeedAutosave) + if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() && isWindowModified() && isNeedAutosave) { qCDebug(vMainWindow, "Autosaving pattern."); QString error; - if (SavePattern(qApp->GetPatternPath() + *autosavePrefix, error)) + if (SavePattern(VAbstractValApplication::VApp()->GetPatternPath() + *autosavePrefix, error)) { isNeedAutosave = false; } @@ -4294,15 +4309,15 @@ void MainWindow::AutoSavePattern() void MainWindow::setCurrentFile(const QString &fileName) { qCDebug(vMainWindow, "Set current name to \"%s\"", qUtf8Printable(fileName)); - qApp->SetPatternPath(fileName); + VAbstractValApplication::VApp()->SetPatternPath(fileName); doc->SetPatternWasChanged(true); emit doc->UpdatePatternLabel(); - qApp->getUndoStack()->setClean(); + VAbstractApplication::VApp()->getUndoStack()->setClean(); - if (not qApp->GetPatternPath().isEmpty() && VApplication::IsGUIMode()) + if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() && VApplication::IsGUIMode()) { qCDebug(vMainWindow, "Updating recent file list."); - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); QStringList files = settings->GetRecentFileList(); files.removeAll(fileName); files.prepend(fileName); @@ -4331,7 +4346,7 @@ void MainWindow::setCurrentFile(const QString &fileName) void MainWindow::ReadSettings() { qCDebug(vMainWindow, "Reading settings."); - const VSettings *settings = qApp->ValentinaSettings(); + const VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); if (settings->status() == QSettings::NoError) { @@ -4347,7 +4362,7 @@ void MainWindow::ReadSettings() ui->view->SetAntialiasing(settings->GetGraphicalOutput()); // Stack limit - qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount()); + VAbstractApplication::VApp()->getUndoStack()->setUndoLimit(settings->GetUndoCount()); // Text under tool buton icon ToolBarStyles(); @@ -4376,7 +4391,7 @@ void MainWindow::WriteSettings() { ActionDraw(true); - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetGeometry(saveGeometry()); settings->SetWindowState(saveState()); settings->SetToolbarsState(saveState(APP_VERSION)); @@ -4411,7 +4426,8 @@ bool MainWindow::MaybeSave() messageBox->setEscapeButton(QMessageBox::Cancel); messageBox->setButtonText(QMessageBox::Yes, - qApp->GetPatternPath().isEmpty() || patternReadOnly ? tr("Save…") : tr("Save")); + VAbstractValApplication::VApp() + ->GetPatternPath().isEmpty() || patternReadOnly ? tr("Save…") : tr("Save")); messageBox->setButtonText(QMessageBox::No, tr("Don't Save")); messageBox->setWindowModality(Qt::ApplicationModal); @@ -4452,14 +4468,14 @@ void MainWindow::CreateMenus() UpdateRecentFileActions(); //Add Undo/Redo actions. - undoAction = qApp->getUndoStack()->createUndoAction(this, tr("&Undo")); + undoAction = VAbstractApplication::VApp()->getUndoStack()->createUndoAction(this, tr("&Undo")); connect(undoAction, &QAction::triggered, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); undoAction->setShortcuts(QKeySequence::Undo); undoAction->setIcon(QIcon::fromTheme("edit-undo")); ui->menuPatternPiece->insertAction(ui->actionLast_tool, undoAction); ui->toolBarTools->addAction(undoAction); - redoAction = qApp->getUndoStack()->createRedoAction(this, tr("&Redo")); + redoAction = VAbstractApplication::VApp()->getUndoStack()->createRedoAction(this, tr("&Redo")); connect(redoAction, &QAction::triggered, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); redoAction->setShortcuts(QKeySequence::Redo); redoAction->setIcon(QIcon::fromTheme("edit-redo")); @@ -4735,7 +4751,7 @@ void MainWindow::InitDocksContain() //--------------------------------------------------------------------------------------------------------------------- bool MainWindow::OpenNewValentina(const QString &fileName) const { - if (this->isWindowModified() || qApp->GetPatternPath().isEmpty() == false) + if (this->isWindowModified() || VAbstractValApplication::VApp()->GetPatternPath().isEmpty() == false) { VApplication::NewValentina(fileName); return true; @@ -4782,7 +4798,7 @@ void MainWindow::CreateActions() QString fileName = QFileDialog::getSaveFileName(this, tr("Export recipe"), QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), - filters, nullptr, qApp->NativeFileDialog()); + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { return; @@ -4897,18 +4913,18 @@ void MainWindow::CreateActions() } }); - ui->actionShowCurveDetails->setChecked(qApp->ValentinaSettings()->IsShowCurveDetails()); + ui->actionShowCurveDetails->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->IsShowCurveDetails()); connect(ui->actionShowCurveDetails, &QAction::triggered, this, [this](bool checked) { emit ui->view->itemClicked(nullptr); sceneDraw->EnableDetailsMode(checked); - qApp->ValentinaSettings()->SetShowCurveDetails(checked); + VAbstractValApplication::VApp()->ValentinaSettings()->SetShowCurveDetails(checked); }); - ui->actionShowMainPath->setChecked(qApp->ValentinaSettings()->IsPieceShowMainPath()); + ui->actionShowMainPath->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->IsPieceShowMainPath()); connect(ui->actionShowMainPath, &QAction::triggered, this, [this](bool checked) { - qApp->ValentinaSettings()->SetPieceShowMainPath(checked); + VAbstractValApplication::VApp()->ValentinaSettings()->SetPieceShowMainPath(checked); const QList ids = pattern->DataPieces()->keys(); const bool updateChildren = false; QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -4932,7 +4948,7 @@ void MainWindow::CreateActions() connect(ui->actionOpenTape, &QAction::triggered, this, [this]() { - const QString tape = qApp->TapeFilePath(); + const QString tape = VApplication::VApp()->TapeFilePath(); const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); QStringList arguments; @@ -4997,13 +5013,13 @@ void MainWindow::InitAutoSave() connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); autoSaveTimer->stop(); - if (qApp->ValentinaSettings()->GetAutosaveState()) + if (VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveState()) { - const qint32 autoTime = qApp->ValentinaSettings()->GetAutosaveTime(); + const qint32 autoTime = VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveTime(); autoSaveTimer->start(autoTime*60000); qCDebug(vMainWindow, "Autosaving each %d minutes.", autoTime); } - qApp->setAutoSaveTimer(autoSaveTimer); + VApplication::VApp()->setAutoSaveTimer(autoSaveTimer); } //--------------------------------------------------------------------------------------------------------------------- @@ -5094,7 +5110,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual) { - const QString tape = qApp->TapeFilePath(); + const QString tape = VApplication::VApp()->TapeFilePath(); const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); QStringList arguments = QStringList() << fileName; @@ -5139,7 +5155,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) VMainGraphicsView::NewSceneRect(sceneDraw, ui->view); VMainGraphicsView::NewSceneRect(sceneDetails, ui->view); - qApp->setOpeningPattern();//Begin opening file + VAbstractValApplication::VApp()->setOpeningPattern();//Begin opening file try { // Quick reading measurements @@ -5158,7 +5174,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) { doc->SetMPath(RelativeMPath(fileName, customMeasureFile)); } - qApp->SetPatternUnits(doc->MUnit()); + VAbstractValApplication::VApp()->SetPatternUnits(doc->MUnit()); QString path = AbsoluteMPath(fileName, doc->MPath()); QString fixedMPath; @@ -5171,7 +5187,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) fixedMPath = CheckPathToMeasurements(fileName, fakeName); if (fixedMPath.isEmpty()) { - qApp->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern();// End opening file Clear(); qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.") .arg(fakeName))); @@ -5193,7 +5209,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) fixedMPath = CheckPathToMeasurements(fileName, path); if (fixedMPath.isEmpty()) { - qApp->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern();// End opening file Clear(); qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.") .arg(path))); @@ -5209,7 +5225,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found or " "provides not enough information.") .arg(fixedMPath))); - qApp->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern();// End opening file Clear(); if (not VApplication::IsGUIMode()) { @@ -5225,7 +5241,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) } } - if (qApp->GetMeasurementsType() == MeasurementsType::Unknown) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Unknown) {// Show toolbar only if was not uploaded any measurements. ToolBarOption(); } @@ -5245,14 +5261,14 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) { doc->SetMPath(RelativeMPath(fileName, fixedMPath)); } - qApp->SetPatternUnits(doc->MUnit()); + VAbstractValApplication::VApp()->SetPatternUnits(doc->MUnit()); } } catch (VException &e) { qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - qApp->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern();// End opening file Clear(); if (not VApplication::IsGUIMode()) { @@ -5281,7 +5297,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) if (guiEnabled) { // No errors occurred - if (qApp->IsGUIMode()) + if (VApplication::VApp()->IsGUIMode()) { /* Collect garbage only after successfully parse. This way wrongly accused items have one more time to restore * a reference. */ @@ -5298,13 +5314,13 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) ActionDraw(true); - qApp->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern();// End opening file m_statusLabel->setText(QString()); return true; } else { - qApp->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern();// End opening file return false; } } @@ -5314,7 +5330,7 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const { QStringList restoreFiles; //Take all files that need to be restored - QStringList files = qApp->ValentinaSettings()->GetRestoreFileList(); + QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); if (files.size() > 0) { for (auto &file : files) @@ -5343,7 +5359,7 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const } } - qApp->ValentinaSettings()->SetRestoreFileList(filtered); + VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(filtered); } return restoreFiles; } @@ -5362,8 +5378,8 @@ void MainWindow::ToolBarStyles() void MainWindow::ToolBoxSizePolicy() { ui->toolBox->setSizePolicy(ui->toolBox->sizePolicy().horizontalPolicy(), - qApp->ValentinaSettings()->GetToolPanelScaling() ? QSizePolicy::Fixed - : QSizePolicy::Preferred); + VAbstractValApplication::VApp()->ValentinaSettings()->GetToolPanelScaling() + ? QSizePolicy::Fixed : QSizePolicy::Preferred); } //--------------------------------------------------------------------------------------------------------------------- @@ -5414,7 +5430,7 @@ void MainWindow::Preferences() #if defined(Q_OS_MAC) void MainWindow::CreateMeasurements() { - const QString tape = qApp->TapeFilePath(); + const QString tape = VApplication::VApp()->TapeFilePath(); const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); QStringList arguments; @@ -5589,7 +5605,8 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS QFileDialog dialog(this, tr("Open file"), dirPath, filter); dialog.selectFile(selectedName); dialog.setFileMode(QFileDialog::ExistingFile); - dialog.setOption(QFileDialog::DontUseNativeDialog, qApp->Settings()->IsDontUseNativeDialog()); + dialog.setOption(QFileDialog::DontUseNativeDialog, + VAbstractApplication::VApp()->Settings()->IsDontUseNativeDialog()); if (dialog.exec() == QDialog::Accepted) { mPath = dialog.selectedFiles().value(0); @@ -5663,7 +5680,8 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS tr("Individual measurements") + QLatin1String(" (*.vit)"); //Use standard path to multisize measurements QString selectedName; - const QString dirPath = DirPath(qApp->ValentinaSettings()->GetPathMultisizeMeasurements(), + const QString dirPath = DirPath(VAbstractValApplication::VApp() + ->ValentinaSettings()->GetPathMultisizeMeasurements(), selectedName); mPath = FindLocation(filter, dirPath, selectedName); } @@ -5673,7 +5691,8 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS tr("Multisize measurements") + QLatin1String(" (*.vst)"); //Use standard path to individual measurements QString selectedName; - const QString dirPath = DirPath(qApp->ValentinaSettings()->GetPathIndividualMeasurements(), + const QString dirPath = DirPath(VAbstractValApplication::VApp() + ->ValentinaSettings()->GetPathIndividualMeasurements(), selectedName); mPath = FindLocation(filter, dirPath, selectedName); } @@ -5714,7 +5733,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS CheckRequiredMeasurements(m.data()); - qApp->SetMeasurementsType(patternType); + VAbstractValApplication::VApp()->SetMeasurementsType(patternType); doc->SetMPath(RelativeMPath(patternPath, mPath)); return mPath; } @@ -5795,7 +5814,7 @@ void MainWindow::ZoomFirstShow() bool MainWindow::DoExport(const VCommandLinePtr &expParams) { QVector details; - if(not qApp->getOpeningPattern()) + if(not VAbstractValApplication::VApp()->getOpeningPattern()) { const QHash *allDetails = pattern->DataPieces(); if (allDetails->count() == 0) @@ -5949,9 +5968,9 @@ bool MainWindow::SetDimensionA(int value) { if (not VApplication::IsGUIMode()) { - if (this->isWindowModified() || not qApp->GetPatternPath().isEmpty()) + if (this->isWindowModified() || not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { const qint32 index = dimensionA->findData(value); if (index != -1) @@ -5992,9 +6011,9 @@ bool MainWindow::SetDimensionB(int value) { if (not VApplication::IsGUIMode()) { - if (this->isWindowModified() || not qApp->GetPatternPath().isEmpty()) + if (this->isWindowModified() || not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { const qint32 index = dimensionB->findData(value); if (index != -1) @@ -6035,9 +6054,9 @@ bool MainWindow::SetDimensionC(int value) { if (not VApplication::IsGUIMode()) { - if (this->isWindowModified() || not qApp->GetPatternPath().isEmpty()) + if (this->isWindowModified() || not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { - if (qApp->GetMeasurementsType() == MeasurementsType::Multisize) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { const qint32 index = dimensionC->findData(value); if (index != -1) @@ -6076,7 +6095,7 @@ bool MainWindow::SetDimensionC(int value) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ProcessCMD() { - const VCommandLinePtr cmd = qApp->CommandLine(); + const VCommandLinePtr cmd = VApplication::VApp()->CommandLine(); auto args = cmd->OptInputFileNames(); isNoScaling = cmd->IsNoScalingEnabled(); @@ -6099,7 +6118,7 @@ void MainWindow::ProcessCMD() return; } - qApp->SetUserMaterials(cmd->OptUserMaterials()); + VAbstractValApplication::VApp()->SetUserMaterials(cmd->OptUserMaterials()); const bool loaded = LoadPattern(args.first(), cmd->OptMeasurePath()); @@ -6153,9 +6172,9 @@ void MainWindow::ProcessCMD() QString MainWindow::GetPatternFileName() { QString shownName = tr("untitled.val"); - if(not qApp->GetPatternPath().isEmpty()) + if(not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { - shownName = StrippedName(qApp->GetPatternPath()); + shownName = StrippedName(VAbstractValApplication::VApp()->GetPatternPath()); } shownName += QLatin1String("[*]"); return shownName; @@ -6171,7 +6190,7 @@ QString MainWindow::GetMeasurementFileName() else { QString shownName(" ["); - shownName += StrippedName(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath())); + shownName += StrippedName(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); if(mChanges) { @@ -6187,12 +6206,12 @@ QString MainWindow::GetMeasurementFileName() void MainWindow::UpdateWindowTitle() { bool isFileWritable = true; - if (not qApp->GetPatternPath().isEmpty()) + if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup++; // turn checking on #endif /*Q_OS_WIN32*/ - isFileWritable = QFileInfo(qApp->GetPatternPath()).isWritable(); + isFileWritable = QFileInfo(VAbstractValApplication::VApp()->GetPatternPath()).isWritable(); #ifdef Q_OS_WIN32 qt_ntfs_permission_lookup--; // turn it off again #endif /*Q_OS_WIN32*/ @@ -6207,13 +6226,13 @@ void MainWindow::UpdateWindowTitle() setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + QLatin1String(" (") + tr("read only") + QLatin1String(")")); } - setWindowFilePath(qApp->GetPatternPath()); + setWindowFilePath(VAbstractValApplication::VApp()->GetPatternPath()); #if defined(Q_OS_MAC) static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/Valentina.icns")); QIcon icon; - if (not qApp->GetPatternPath().isEmpty()) + if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { if (not isWindowModified()) { @@ -6597,14 +6616,14 @@ void MainWindow::OpenWatermark(const QString &path) for (i = m_watermarkEditors.begin(); i != m_watermarkEditors.end(); ++i) { if (not (*i).isNull() && not (*i)->CurrentFile().isEmpty() - && (*i)->CurrentFile() == AbsoluteMPath(qApp->GetPatternPath(), path)) + && (*i)->CurrentFile() == AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), path)) { (*i)->show(); return; } } - auto *watermark = new WatermarkWindow(qApp->GetPatternPath(), this); + auto *watermark = new WatermarkWindow(VAbstractValApplication::VApp()->GetPatternPath(), this); connect(watermark, &WatermarkWindow::New, this, [this](){OpenWatermark();}); connect(watermark, &WatermarkWindow::OpenAnother, this, [this](const QString &path){OpenWatermark(path);}); m_watermarkEditors.append(watermark); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 0bca2967a..a61dfea90 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -128,7 +128,8 @@ void InsertGlobalContours(const QList &scenes, const QListTrVars(), qApp->patternUnitsP(), valentinaNamespace)) + pattern(new VContainer(VAbstractApplication::VApp()->TrVars(), VAbstractValApplication::VApp()->patternUnitsP(), + valentinaNamespace)) #if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) ,m_taskbarButton(new QWinTaskbarButton(this)) #endif @@ -468,17 +469,17 @@ void MainWindowsNoGUI::ExportFMeasurementsToCSV() } DialogExportToCSV dialog(this); - dialog.SetWithHeader(qApp->Settings()->GetCSVWithHeader()); - dialog.SetSelectedMib(qApp->Settings()->GetCSVCodec()); - dialog.SetSeparator(qApp->Settings()->GetCSVSeparator()); + dialog.SetWithHeader(VAbstractApplication::VApp()->Settings()->GetCSVWithHeader()); + dialog.SetSelectedMib(VAbstractApplication::VApp()->Settings()->GetCSVCodec()); + dialog.SetSeparator(VAbstractApplication::VApp()->Settings()->GetCSVSeparator()); if (dialog.exec() == QDialog::Accepted) { ExportFMeasurementsToCSVData(fileName, dialog.IsWithHeader(), dialog.GetSelectedMib(), dialog.GetSeparator()); - qApp->Settings()->SetCSVSeparator(dialog.GetSeparator()); - qApp->Settings()->SetCSVCodec(dialog.GetSelectedMib()); - qApp->Settings()->SetCSVWithHeader(dialog.IsWithHeader()); + VAbstractApplication::VApp()->Settings()->SetCSVSeparator(dialog.GetSeparator()); + VAbstractApplication::VApp()->Settings()->SetCSVCodec(dialog.GetSelectedMib()); + VAbstractApplication::VApp()->Settings()->SetCSVWithHeader(dialog.IsWithHeader()); } } @@ -554,7 +555,7 @@ void MainWindowsNoGUI::ExportFlatLayout(const QList &scenes, return; } - qApp->ValentinaSettings()->SetPathLayout(path); + VAbstractValApplication::VApp()->ValentinaSettings()->SetPathLayout(path); const LayoutExportFormats format = m_dialogSaveLayout->Format(); if (format == LayoutExportFormats::PDFTiled && m_dialogSaveLayout->Mode() == Draw::Layout) @@ -655,7 +656,7 @@ void MainWindowsNoGUI::ExportApparelLayout(const QVector &details, return; } - qApp->ValentinaSettings()->SetPathLayout(path); + VAbstractValApplication::VApp()->ValentinaSettings()->SetPathLayout(path); const LayoutExportFormats format = m_dialogSaveLayout->Format(); VLayoutExporter exporter; @@ -848,14 +849,15 @@ void MainWindowsNoGUI::PrintPreviewTiled() } else { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); m_layoutSettings->SetTiledMargins(QMarginsF(settings->GetTiledPDFMargins(Unit::Mm))); m_layoutSettings->SetTiledPDFOrientation(settings->GetTiledPDFOrientation()); m_layoutSettings->SetTiledPDFPaperSize(QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm))); } - m_layoutSettings->SetWatermarkPath(AbsoluteMPath(qApp->GetPatternPath(), doc->GetWatermarkPath())); + m_layoutSettings->SetWatermarkPath( + AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->GetWatermarkPath())); m_layoutSettings->PrintPreviewTiled(); } @@ -881,14 +883,15 @@ void MainWindowsNoGUI::PrintTiled() } else { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); m_layoutSettings->SetTiledMargins(QMarginsF(settings->GetTiledPDFMargins(Unit::Mm))); m_layoutSettings->SetTiledPDFOrientation(settings->GetTiledPDFOrientation()); m_layoutSettings->SetTiledPDFPaperSize(QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm))); } - m_layoutSettings->SetWatermarkPath(AbsoluteMPath(qApp->GetPatternPath(), doc->GetWatermarkPath())); + m_layoutSettings->SetWatermarkPath( + AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->GetWatermarkPath())); m_layoutSettings->PrintTiled(); } @@ -919,7 +922,7 @@ QVector MainWindowsNoGUI::PrepareDetailsForLayout(const QVectorIsGUIMode()) + if (VApplication::VApp()->IsGUIMode()) { progress.exec(); } @@ -949,7 +952,7 @@ void MainWindowsNoGUI::InitTempLayoutScene() //--------------------------------------------------------------------------------------------------------------------- QStringList MainWindowsNoGUI::RecentFileList() const { - return qApp->ValentinaSettings()->GetRecentFileList(); + return VAbstractValApplication::VApp()->ValentinaSettings()->GetRecentFileList(); } //--------------------------------------------------------------------------------------------------------------------- @@ -977,8 +980,8 @@ QIcon MainWindowsNoGUI::ScenePreview(int i, QSize iconSize, PreviewQuatilty qual QPainter painter(&image); painter.setFont( QFont( QStringLiteral("Arial"), 8, QFont::Normal ) ); painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine, + Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); m_layoutSettings->LayoutScenes().at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio); painter.end(); @@ -1067,7 +1070,7 @@ void MainWindowsNoGUI::PdfTiledFile(const QString &name) } else { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); m_layoutSettings->SetTiledMargins(QMarginsF(settings->GetTiledPDFMargins(Unit::Mm))); m_layoutSettings->SetTiledPDFOrientation(settings->GetTiledPDFOrientation()); m_layoutSettings->SetTiledPDFPaperSize(QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), @@ -1076,7 +1079,8 @@ void MainWindowsNoGUI::PdfTiledFile(const QString &name) m_layoutSettings->SetYScale(1); } - m_layoutSettings->SetWatermarkPath(AbsoluteMPath(qApp->GetPatternPath(), doc->GetWatermarkPath())); + m_layoutSettings->SetWatermarkPath( + AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->GetWatermarkPath())); m_layoutSettings->PdfTiledFile(name); } @@ -1117,19 +1121,19 @@ void MainWindowsNoGUI::ExportScene(const QList &scenes, { case LayoutExportFormats::SVG: paper->setVisible(false); - exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); + exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); exporter.ExportToSVG(scene); paper->setVisible(true); break; case LayoutExportFormats::PDF: - exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); + exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); exporter.ExportToPDF(scene); break; case LayoutExportFormats::PNG: - exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); + exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); exporter.ExportToPNG(scene); break; case LayoutExportFormats::OBJ: @@ -1138,13 +1142,13 @@ void MainWindowsNoGUI::ExportScene(const QList &scenes, paper->setVisible(true); break; case LayoutExportFormats::PS: - exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); + exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); exporter.ExportToPS(scene); break; case LayoutExportFormats::EPS: - exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); + exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); exporter.ExportToEPS(scene); break; case LayoutExportFormats::DXF_AC1006_Flat: @@ -1202,8 +1206,8 @@ void MainWindowsNoGUI::ExportScene(const QList &scenes, paper->setVisible(true); break; case LayoutExportFormats::TIF: - exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, - Qt::RoundJoin)); + exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); exporter.ExportToTIF(scene); break; default: @@ -1224,7 +1228,8 @@ void MainWindowsNoGUI::ExportScene(const QList &scenes, QString MainWindowsNoGUI::FileName() const { QString fileName; - qApp->GetPatternPath().isEmpty() ? fileName = tr("unnamed") : fileName = qApp->GetPatternPath(); + VAbstractValApplication::VApp()->GetPatternPath().isEmpty() + ? fileName = tr("unnamed") : fileName = VAbstractValApplication::VApp()->GetPatternPath(); return QFileInfo(fileName).baseName(); } @@ -1262,7 +1267,7 @@ bool MainWindowsNoGUI::ExportFMeasurementsToCSVData(const QString &fileName, boo QScopedPointer cal(new Calculator()); const qreal result = cal->EvalFormula(completeData.DataVariables(), m.formula); - csv.setText(i, 1, qApp->LocaleToString(result)); // value + csv.setText(i, 1, VAbstractApplication::VApp()->LocaleToString(result)); // value if (qIsInf(result) || qIsNaN(result)) { @@ -1371,7 +1376,7 @@ void MainWindowsNoGUI::CheckRequiredMeasurements(const VMeasurements *m) const QList list = ConvertToList(match); for (int i = 0; i < list.size(); ++i) { - list[i] = qApp->TrVars()->MToUser(list.at(i)); + list[i] = VAbstractApplication::VApp()->TrVars()->MToUser(list.at(i)); } VException e(tr("Measurement file doesn't include all required measurements.")); diff --git a/src/app/valentina/valentina.pro b/src/app/valentina/valentina.pro index 953b236d1..f726878b6 100644 --- a/src/app/valentina/valentina.pro +++ b/src/app/valentina/valentina.pro @@ -584,16 +584,7 @@ DEPENDPATH += $$PWD/../../libs/vformat win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a -# VLayout static library (depend on IFC, VGeometry, VPatternDB) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout - -INCLUDEPATH += $$PWD/../../libs/vlayout -DEPENDPATH += $$PWD/../../libs/vlayout - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a - -#VPatternDB static library (depend on vgeometry, vmisc) +#VPatternDB static library (depend on vgeometry, vmisc, VLayout) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb INCLUDEPATH += $$PWD/../../libs/vpatterndb @@ -602,6 +593,15 @@ DEPENDPATH += $$PWD/../../libs/vpatterndb win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a +# VLayout static library (depend on IFC, VGeometry) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout + +INCLUDEPATH += $$PWD/../../libs/vlayout +DEPENDPATH += $$PWD/../../libs/vlayout + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + # VGeometry static library (depend on ifc) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/ -lvgeometry diff --git a/src/app/valentina/watermarkwindow.cpp b/src/app/valentina/watermarkwindow.cpp index f85de0f6f..6c62258d3 100644 --- a/src/app/valentina/watermarkwindow.cpp +++ b/src/app/valentina/watermarkwindow.cpp @@ -53,7 +53,7 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) : ui->setupUi(this); m_okPathColor = ui->lineEditPath->palette().color(ui->lineEditPath->foregroundRole()); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); UpdateWindowTitle(); m_curFileFormatVersion = VWatermarkConverter::WatermarkMaxVer; @@ -94,7 +94,8 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) : { const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)"); const QString fileName = QFileDialog::getOpenFileName(this, tr("Watermark image"), QString(), filter, - nullptr, qApp->NativeFileDialog()); + nullptr, + VAbstractApplication::VApp()->NativeFileDialog()); if (not fileName.isEmpty()) { ui->lineEditPath->setText(fileName); @@ -241,7 +242,7 @@ void WatermarkWindow::showEvent(QShowEvent *event) } // do your init stuff here - QSize sz = qApp->ValentinaSettings()->GetWatermarkEditorSize(); + QSize sz = VAbstractValApplication::VApp()->ValentinaSettings()->GetWatermarkEditorSize(); if (sz.isEmpty() == false) { resize(sz); @@ -258,7 +259,7 @@ void WatermarkWindow::resizeEvent(QResizeEvent *event) // window creating, which would if (m_isInitialized) { - qApp->ValentinaSettings()->SetWatermarkEditorSize(size()); + VAbstractValApplication::VApp()->ValentinaSettings()->SetWatermarkEditorSize(size()); } QMainWindow::resizeEvent(event); } @@ -285,7 +286,7 @@ bool WatermarkWindow::on_actionSaveAs_triggered() QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QLatin1String("/") + tr("watermark") + QLatin1String(".vwm"), - filters, nullptr, qApp->NativeFileDialog()); + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { @@ -434,7 +435,7 @@ void WatermarkWindow::on_actionOpen_triggered() QString dir = QDir::homePath(); qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (filePath.isEmpty()) { return; @@ -555,7 +556,7 @@ QString WatermarkWindow::GetWatermarkFileName() //--------------------------------------------------------------------------------------------------------------------- bool WatermarkWindow::ContinueFormatRewrite(const QString ¤tFormatVersion, const QString &maxFormatVersion) { - if (qApp->Settings()->GetConfirmFormatRewriting()) + if (VAbstractApplication::VApp()->Settings()->GetConfirmFormatRewriting()) { Utils::CheckableMessageBox msgBox(this); msgBox.setWindowTitle(tr("Confirm format rewriting")); @@ -571,7 +572,7 @@ bool WatermarkWindow::ContinueFormatRewrite(const QString ¤tFormatVersion, if (dialogResult == QDialog::Accepted) { - qApp->Settings()->SetConfirmFormatRewriting(not msgBox.isChecked()); + VAbstractApplication::VApp()->Settings()->SetConfirmFormatRewriting(not msgBox.isChecked()); return true; } else @@ -732,7 +733,7 @@ void WatermarkWindow::ValidatePath() void WatermarkWindow::ToolBarStyle(QToolBar *bar) { SCASSERT(bar != nullptr) - if (qApp->Settings()->GetToolBarStyle()) + if (VAbstractApplication::VApp()->Settings()->GetToolBarStyle()) { bar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index ac8a880db..4484edc22 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -98,7 +98,7 @@ void GatherCount(int &count, const int nodes) //--------------------------------------------------------------------------------------------------------------------- QString DefLabelLanguage() { - QString def = qApp->ValentinaSettings()->GetLabelLanguage(); + QString def = VAbstractValApplication::VApp()->ValentinaSettings()->GetLabelLanguage(); if (not ConvertToSet(VApplication::LabelLanguages()).contains(def)) { def = QStringLiteral("en"); @@ -127,7 +127,8 @@ void VPattern::CreateEmptyFile() patternElement.appendChild(createComment(FileComment())); patternElement.appendChild(CreateElementWithText(TagVersion, VPatternConverter::PatternMaxVerStr)); - patternElement.appendChild(CreateElementWithText(TagUnit, UnitsToStr(qApp->patternUnits()))); + patternElement.appendChild(CreateElementWithText(TagUnit, + UnitsToStr(VAbstractValApplication::VApp()->patternUnits()))); patternElement.appendChild(createElement(TagDescription)); patternElement.appendChild(createElement(TagNotes)); @@ -227,11 +228,11 @@ void VPattern::Parse(const Document &parse) } domNode = domNode.nextSibling(); } - if (qApp->IsGUIMode()) + if (VApplication::VApp()->IsGUIMode()) { QTimer::singleShot(1000, Qt::VeryCoarseTimer, this, SLOT(RefreshPieceGeometry())); } - else if (qApp->CommandLine()->IsTestModeEnabled()) + else if (VApplication::VApp()->CommandLine()->IsTestModeEnabled()) { RefreshPieceGeometry(); } @@ -249,7 +250,7 @@ void VPattern::Parse(const Document &parse) */ void VPattern::setCurrentData() { - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { const int countPP = CountPP(); if (countPP > 1)//don't need upadate data if we have only one pattern piece @@ -670,8 +671,8 @@ void VPattern::LiteParseTree(const Document &parse) setCurrentData(); emit FullUpdateFromFile(); // Recalculate scene rect - VMainGraphicsView::NewSceneRect(sceneDraw, qApp->getSceneView()); - VMainGraphicsView::NewSceneRect(sceneDetail, qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(sceneDraw, VAbstractValApplication::VApp()->getSceneView()); + VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView()); qCDebug(vXML, "Scene size updated."); } @@ -681,7 +682,7 @@ void VPattern::customEvent(QEvent *event) { if (event->type() == UNDO_EVENT) { - qApp->getUndoStack()->undo(); + VAbstractApplication::VApp()->getUndoStack()->undo(); } else if (event->type() == LITE_PARSE_EVENT) { @@ -864,18 +865,23 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse VToolSeamAllowanceInitData initData; initData.id = GetParametrId(domElement); initData.detail.SetName(GetParametrString(domElement, AttrName, tr("Detail"))); - initData.detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("0.0")))); - initData.detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("0.0")))); + initData.detail.SetMx(VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("0.0")))); + initData.detail.SetMy(VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("0.0")))); initData.detail.SetSeamAllowance(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowance, falseStr)); initData.detail.SetHideMainPath(GetParametrBool(domElement, VToolSeamAllowance::AttrHideMainPath, - QString().setNum(qApp->ValentinaSettings()->IsHideMainPath()))); + QString().setNum(VAbstractValApplication::VApp() + ->ValentinaSettings()->IsHideMainPath()))); initData.detail.SetSeamAllowanceBuiltIn(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowanceBuiltIn, falseStr)); initData.detail.SetForbidFlipping(GetParametrBool(domElement, AttrForbidFlipping, - QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()))); + QString().setNum(VAbstractValApplication::VApp() + ->ValentinaSettings()->GetForbidWorkpieceFlipping()))); initData.detail.SetForceFlipping(GetParametrBool(domElement, AttrForceFlipping, - QString().setNum(qApp->ValentinaSettings()->GetForceWorkpieceFlipping()))); + QString().setNum(VAbstractValApplication::VApp() + ->ValentinaSettings()->GetForceWorkpieceFlipping()))); initData.detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); initData.detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr)); initData.detail.SetPriority(GetParametrUInt(domElement, VToolSeamAllowance::AttrPiecePriority, QChar('0'))); @@ -1210,8 +1216,8 @@ void VPattern::PointsCommonAttributes(const QDomElement &domElement, VToolSingle void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my) { ToolsCommonAttributes(domElement, id); - mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX))); - my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QString::number(labelMY))); + mx = VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX))); + my = VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMy, QString::number(labelMY))); } //--------------------------------------------------------------------------------------------------------------------- @@ -1219,8 +1225,8 @@ void VPattern::DrawPointsCommonAttributes(const QDomElement &domElement, quint32 QString ¬es) { DrawToolsCommonAttributes(domElement, id, notes); - mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX))); - my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, QString::number(labelMY))); + mx = VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMx, QString::number(labelMX))); + my = VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMy, QString::number(labelMY))); } //--------------------------------------------------------------------------------------------------------------------- @@ -1489,8 +1495,10 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement & initData.typeCreation = Source::FromFile; PointsCommonAttributes(domElement, initData); - initData.x = qApp->toPixel(GetParametrDouble(domElement, AttrX, QStringLiteral("10.0"))); - initData.y = qApp->toPixel(GetParametrDouble(domElement, AttrY, QStringLiteral("10.0"))); + initData.x = VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrX, QStringLiteral("10.0"))); + initData.y = VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrY, QStringLiteral("10.0"))); spoint = VToolBasePoint::Create(initData); } @@ -2494,13 +2502,17 @@ void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement & initData.dartP3Id = GetParametrUInt(domElement, AttrDartP3, NULL_ID_STR); initData.name1 = GetParametrString(domElement, AttrName1, QChar('A')); - initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, QString::number(labelMX))); - initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, QString::number(labelMY))); + initData.mx1 = VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrMx1, QString::number(labelMX))); + initData.my1 = VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrMy1, QString::number(labelMY))); initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr); initData.name2 = GetParametrString(domElement, AttrName2, QChar('A')); - initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, QString::number(labelMX))); - initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, QString::number(labelMY))); + initData.mx2 = VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrMx2, QString::number(labelMX))); + initData.my2 = VAbstractValApplication::VApp() + ->toPixel(GetParametrDouble(domElement, AttrMy2, QString::number(labelMY))); initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr); VToolTrueDarts::Create(initData); @@ -2604,7 +2616,8 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen if (spl != nullptr) { - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(spl, &VToolSpline::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } @@ -2813,7 +2826,8 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement if (spl != nullptr) { - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(spl, &VToolSplinePath::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } @@ -3667,17 +3681,17 @@ void VPattern::RefreshPieceGeometry() auto CleanRefreshList = qScopeGuard([this]() { updatePieces.clear(); - VMainGraphicsView::NewSceneRect(sceneDetail, qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView()); }); - if (qApp->IsGUIMode() && m_parsing) + if (VApplication::VApp()->IsGUIMode() && m_parsing) { return; } for(auto pieceId : qAsConst(updatePieces)) { - if (qApp->IsGUIMode() && m_parsing) + if (VApplication::VApp()->IsGUIMode() && m_parsing) { return; } @@ -3696,7 +3710,7 @@ void VPattern::RefreshPieceGeometry() QApplication::processEvents(); - if (qApp->IsGUIMode() && m_parsing) + if (VApplication::VApp()->IsGUIMode() && m_parsing) { return; } diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 542b881e2..3921938ce 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -128,7 +128,7 @@ void FvUpdater::showUpdaterWindowUpdatedWithCurrentUpdateProposal() hideUpdaterWindow(); // Create a new window - m_updaterWindow = new FvUpdateWindow(qApp->getMainWindow()); + m_updaterWindow = new FvUpdateWindow(VAbstractValApplication::VApp()->getMainWindow()); m_updaterWindow->UpdateWindowWithCurrentProposedUpdate(); m_updaterWindow->exec(); } @@ -209,7 +209,7 @@ void FvUpdater::RemindMeLater() { qDebug() << "Remind me later"; - qApp->Settings()->SetDateOfLastRemind(QDate::currentDate()); + VAbstractApplication::VApp()->Settings()->SetDateOfLastRemind(QDate::currentDate()); hideUpdaterWindow(); } @@ -283,7 +283,7 @@ bool FvUpdater::CheckForUpdates(bool silentAsMuchAsItCouldGet) //--------------------------------------------------------------------------------------------------------------------- bool FvUpdater::CheckForUpdatesSilent() { - if (qApp->Settings()->GetDateOfLastRemind().daysTo(QDate::currentDate()) >= 1) + if (VAbstractApplication::VApp()->Settings()->GetDateOfLastRemind().daysTo(QDate::currentDate()) >= 1) { const bool success = CheckForUpdates(true); if (m_dropOnFinnish && not success) @@ -548,7 +548,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version) return true; } - const int lastSkippedVersion = qApp->Settings()->GetLatestSkippedVersion(); + const int lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion(); if (lastSkippedVersion != 0x0) { if (decVersion == lastSkippedVersion) @@ -588,7 +588,7 @@ void FvUpdater::IgnoreVersion(const QString &version) return; } - qApp->Settings()->SetLatestSkippedVersion(decVersion); + VAbstractApplication::VApp()->Settings()->SetLatestSkippedVersion(decVersion); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 0ec819e8a..a9fc274db 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -215,7 +215,7 @@ void GatherTokens(QSet &tokens, const QList &tokenList) */ QMap AdjustMaterials(QMap materials) { - const QMap cliMaterials = qApp->GetUserMaterials(); + const QMap cliMaterials = VAbstractValApplication::VApp()->GetUserMaterials(); QMap::const_iterator i = cliMaterials.constBegin(); while (i != cliMaterials.constEnd()) { @@ -1045,7 +1045,7 @@ QString VAbstractPattern::GetLabelDateFormat() const { if (*labelDateFormatCached == unknownCharacter) { - const QString globalLabelDateFormat = qApp->Settings()->GetLabelDateFormat(); + const QString globalLabelDateFormat = VAbstractApplication::VApp()->Settings()->GetLabelDateFormat(); const QDomNodeList list = elementsByTagName(TagPatternLabel); if (list.isEmpty()) @@ -1079,7 +1079,7 @@ void VAbstractPattern::SetLabelDateFormat(const QString &format) //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetLabelTimeFormat() const { - QString globalLabelTimeFormat = qApp->Settings()->GetLabelTimeFormat(); + QString globalLabelTimeFormat = VAbstractApplication::VApp()->Settings()->GetLabelTimeFormat(); const QDomNodeList list = elementsByTagName(TagPatternLabel); if (list.isEmpty()) diff --git a/src/libs/vdxf/dxiface.cpp b/src/libs/vdxf/dxiface.cpp index 88372d63f..868713ab6 100644 --- a/src/libs/vdxf/dxiface.cpp +++ b/src/libs/vdxf/dxiface.cpp @@ -467,5 +467,6 @@ void dx_iface::AddBlock(dx_ifaceBlock *block) std::string dx_iface::LocaleToISO() { QMap locMap = LocaleMap(); - return locMap.value(QLocale(qApp->Settings()->GetLocale()).name(), "ISO8859-1").toStdString(); + return locMap.value(QLocale(VAbstractApplication::VApp()->Settings()->GetLocale()).name(), + "ISO8859-1").toStdString(); } diff --git a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp index 307e4e81e..c381f58c5 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp +++ b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp @@ -112,8 +112,8 @@ void DRW_TextCodec::setCodePage(const std::string *c, bool dxfFormat){ { const QString errorMsg = QCoreApplication::translate("DRW_TextCodec", "No available codec for code page '%1'.") .arg(cp.c_str()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; if (version < DRW::AC1021 && cp == "UTF-8") { diff --git a/src/libs/vformat/vpatternrecipe.cpp b/src/libs/vformat/vpatternrecipe.cpp index 368f7b578..bfd036b68 100644 --- a/src/libs/vformat/vpatternrecipe.cpp +++ b/src/libs/vformat/vpatternrecipe.cpp @@ -116,7 +116,8 @@ QDomElement VPatternRecipe::Prerequisite() QDomElement prerequisiteElement = createElement(QStringLiteral("prerequisite")); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("valentina"), APP_VERSION_STR)); - prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("unit"), UnitsToStr(qApp->patternUnits()))); + prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("unit"), + UnitsToStr(VAbstractValApplication::VApp()->patternUnits()))); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("author"), m_pattern->GetCompanyName())); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("pattenName"), m_pattern->GetPatternName())); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("description"), m_pattern->GetDescription())); @@ -440,8 +441,8 @@ QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm, const const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."), tr("Value for final measurtement '%1' is infinite or NaN. " "Please, check your calculations.").arg(fm.name)); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } SetAttribute(recipeFinalMeasurement, QStringLiteral("value"), result); @@ -595,10 +596,10 @@ QDomElement VPatternRecipe::Spline(const VToolRecord &record) SetAttribute(step, AttrAngle2Value, spl.GetEndAngle()); SetAttribute(step, AttrLength1, spl.GetC1LengthFormula()); - SetAttribute(step, AttrLength1Value, qApp->fromPixel(spl.GetC1Length())); + SetAttribute(step, AttrLength1Value, VAbstractValApplication::VApp()->fromPixel(spl.GetC1Length())); SetAttribute(step, AttrLength2, spl.GetC2LengthFormula()); - SetAttribute(step, AttrLength2Value, qApp->fromPixel(spl.GetC2Length())); + SetAttribute(step, AttrLength2Value, VAbstractValApplication::VApp()->fromPixel(spl.GetC2Length())); CurveAttributes(step, tool); @@ -693,10 +694,10 @@ QDomElement VPatternRecipe::SplinePath(const VToolRecord &record) SetAttribute(node, AttrAngle2Value, pathNode.Angle2()); SetAttribute(node, AttrLength1, pathNode.Length1Formula()); - SetAttribute(node, AttrLength1Value, qApp->fromPixel(pathNode.Length1())); + SetAttribute(node, AttrLength1Value, VAbstractValApplication::VApp()->fromPixel(pathNode.Length1())); SetAttribute(node, AttrLength2, pathNode.Length2Formula()); - SetAttribute(node, AttrLength2Value, qApp->fromPixel(pathNode.Length2())); + SetAttribute(node, AttrLength2Value, VAbstractValApplication::VApp()->fromPixel(pathNode.Length2())); nodes.appendChild(node); } diff --git a/src/libs/vgeometry/vabstractcubicbezier.cpp b/src/libs/vgeometry/vabstractcubicbezier.cpp index 3f2831de7..396826f85 100644 --- a/src/libs/vgeometry/vabstractcubicbezier.cpp +++ b/src/libs/vgeometry/vabstractcubicbezier.cpp @@ -96,7 +96,7 @@ QVector PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, double m_approximation_scale = approximationScale; if(m_approximation_scale < minCurveApproximationScale || m_approximation_scale > maxCurveApproximationScale) { - m_approximation_scale = qApp->Settings()->GetCurveApproximationScale(); + m_approximation_scale = VAbstractApplication::VApp()->Settings()->GetCurveApproximationScale(); } double m_distance_tolerance_square; diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index e8bde1cd6..17ae5019e 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -145,8 +145,8 @@ QVector VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QP errorMsg = QObject::tr("Error in path '%1'. Calculating segment for curve '%2' has failed. %3") .arg(piece, name(), error); } - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } return segment; @@ -600,7 +600,7 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector &arrows //--------------------------------------------------------------------------------------------------------------------- qreal VAbstractCurve::LengthCurveDirectionArrow() { - return qApp->Settings()->GetLineWidth() * 8.0; + return VAbstractApplication::VApp()->Settings()->GetLineWidth() * 8.0; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/varc_p.h b/src/libs/vgeometry/varc_p.h index 4530b02a2..16feb40ea 100644 --- a/src/libs/vgeometry/varc_p.h +++ b/src/libs/vgeometry/varc_p.h @@ -72,7 +72,7 @@ VArcData::VArcData(qreal radius, const QString &formulaRadius) //--------------------------------------------------------------------------------------------------------------------- VArcData::VArcData(qreal radius) : radius(radius), - formulaRadius(QString().number(qApp->fromPixel(radius))) + formulaRadius(QString().number(VAbstractValApplication::VApp()->fromPixel(radius))) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 68b878de3..5db2a4b95 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -479,7 +479,7 @@ void VEllipticalArc::FindF2(qreal length) SetFormulaF2(QString::number(endAngle), endAngle); lenBez = GetLength(); } - SetFormulaLength(QString::number(qApp->fromPixel(lenBez))); + SetFormulaLength(QString::number(VAbstractValApplication::VApp()->fromPixel(lenBez))); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vellipticalarc_p.h b/src/libs/vgeometry/vellipticalarc_p.h index ee00d533d..6d9bf57ae 100644 --- a/src/libs/vgeometry/vellipticalarc_p.h +++ b/src/libs/vgeometry/vellipticalarc_p.h @@ -67,10 +67,10 @@ VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, const QStri VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, qreal rotationAngle) : radius1(radius1), radius2(radius2), - formulaRadius1(QString().number(qApp->fromPixel(radius1))), - formulaRadius2(QString().number(qApp->fromPixel(radius2))), + formulaRadius1(QString().number(VAbstractValApplication::VApp()->fromPixel(radius1))), + formulaRadius2(QString().number(VAbstractValApplication::VApp()->fromPixel(radius2))), rotationAngle(rotationAngle), - formulaRotationAngle(QString().number(qApp->fromPixel(rotationAngle))), + formulaRotationAngle(QString().number(VAbstractValApplication::VApp()->fromPixel(rotationAngle))), m_transform() {} diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index fd8c3d196..ac9388c47 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -271,8 +271,8 @@ QString VGObject::GetAliasSuffix() const //--------------------------------------------------------------------------------------------------------------------- QString VGObject::ObjectName() const { - const QString alias = qApp->TrVars()->VarToUser(d->m_alias); - const QString name = qApp->TrVars()->VarToUser(d->_name); + const QString alias = VAbstractApplication::VApp()->TrVars()->VarToUser(d->m_alias); + const QString name = VAbstractApplication::VApp()->TrVars()->VarToUser(d->_name); return not d->m_alias.isEmpty() ? QString("%1 (%2)").arg(alias, name) : name; } diff --git a/src/libs/vgeometry/vspline_p.h b/src/libs/vgeometry/vspline_p.h index 1b71ca5a6..63ca2e9b0 100644 --- a/src/libs/vgeometry/vspline_p.h +++ b/src/libs/vgeometry/vspline_p.h @@ -140,12 +140,12 @@ VSplineData::VSplineData(VPointF p1, VPointF p4, qreal angle1, qreal angle2, qre QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y()); p1p2.setAngle(angle1); c1Length = p1p2.length(); - c1LengthF = QString().number(qApp->fromPixel(c1Length)); + c1LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c1Length)); QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y()); p4p3.setAngle(angle2); c2Length = p4p3.length(); - c2LengthF = QString().number(qApp->fromPixel(c2Length)); + c2LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c2Length)); } //--------------------------------------------------------------------------------------------------------------------- @@ -168,7 +168,7 @@ VSplineData::VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4) angle1F = QString().number(angle1); c1Length = p1p2.length(); - c1LengthF = QString().number(qApp->fromPixel(c1Length)); + c1LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c1Length)); QLineF p4p3(static_cast(p4), static_cast(p3)); @@ -176,7 +176,7 @@ VSplineData::VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4) angle2F = QString().number(angle2); c2Length = p4p3.length(); - c2LengthF = QString().number(qApp->fromPixel(c2Length)); + c2LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c2Length)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/dialogs/dialoglayoutscale.cpp b/src/libs/vlayout/dialogs/dialoglayoutscale.cpp index a5d566c0d..5166e7a1d 100644 --- a/src/libs/vlayout/dialogs/dialoglayoutscale.cpp +++ b/src/libs/vlayout/dialogs/dialoglayoutscale.cpp @@ -41,7 +41,7 @@ DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent) { ui->setupUi(this); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); SCASSERT(bOk != nullptr) @@ -72,7 +72,7 @@ DialogLayoutScale::~DialogLayoutScale() void DialogLayoutScale::SetTiledMargins(QMarginsF margins) { // read Margins top, right, bottom, left - margins = UnitConvertor(margins, Unit::Mm, qApp->patternUnits()); + margins = UnitConvertor(margins, Unit::Mm, VAbstractValApplication::VApp()->patternUnits()); ui->doubleSpinBoxLeftField->setValue(margins.left()); ui->doubleSpinBoxTopField->setValue(margins.top()); @@ -90,7 +90,7 @@ QMarginsF DialogLayoutScale::GetTiledMargins() const ui->doubleSpinBoxBottomField->value() ); - return UnitConvertor(margins, qApp->patternUnits(), Unit::Mm); + return UnitConvertor(margins, VAbstractValApplication::VApp()->patternUnits(), Unit::Mm); } //--------------------------------------------------------------------------------------------------------------------- @@ -181,8 +181,8 @@ void DialogLayoutScale::VerticalScaleChanged(double d) //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutScale::ReadSettings() { - VCommonSettings *settings = qApp->Settings(); - const Unit unit = qApp->patternUnits(); + VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); + const Unit unit = VAbstractValApplication::VApp()->patternUnits(); // read Margins top, right, bottom, left const QMarginsF margins = settings->GetTiledPDFMargins(unit); @@ -201,8 +201,8 @@ void DialogLayoutScale::ReadSettings() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutScale::WriteSettings() const { - VCommonSettings *settings = qApp->Settings(); - const Unit unit = qApp->patternUnits(); + VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); + const Unit unit = VAbstractValApplication::VApp()->patternUnits(); // write Margins top, right, bottom, left QMarginsF margins = QMarginsF( diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 186967b2b..11633a379 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1071,8 +1071,8 @@ QVector VAbstractPiece::Equidistant(QVector points, qreal wid if ( points.size() < 3 ) { const QString errorMsg = tr("Piece '%1'. Not enough points to build seam allowance.").arg(name); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); } diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index 23c70c9f6..c6b666825 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -390,8 +390,8 @@ bool VBank::PrepareDetails() { const QString errorMsg = QObject::tr("Piece '%1' has invalid layout allowance. Please, check seam allowance" " to check how seam allowance behave.").arg(details.at(i).GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } const qreal d = details.at(i).Diagonal(); diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 26b742983..d650cf0b1 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -274,8 +274,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const QString errorMsg = QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return; } @@ -288,8 +288,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is " "empty.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return; } layoutPassmark.baseLine = ConstFirst (baseLines); @@ -305,8 +305,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const QString errorMsg = QObject::tr("Passmark '%1' is not part of piece '%2'.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } }; @@ -331,8 +331,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const QString errorMsg = QObject::tr("Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return; } @@ -351,8 +351,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const QString errorMsg = QObject::tr("Cannot prepare passmark '%1' for piece '%2'. Passmark is empty.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return; } @@ -367,8 +367,8 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer const QString errorMsg = QObject::tr("Passmark '%1' is not part of piece '%2'.") .arg(pData.nodeName, piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } }; @@ -404,8 +404,9 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer } } - if (qApp->Settings()->IsDoublePassmark() - && (qApp->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) + if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() + && (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || + not piece.IsHideMainPath()) && pData.isMainPathNode && pData.passmarkAngleType != PassmarkAngleType::Intersection && pData.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft @@ -504,7 +505,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai det.SetName(piece.GetName()); - det.SetSAWidth(qApp->toPixel(piece.GetSAWidth())); + det.SetSAWidth(VAbstractValApplication::VApp()->toPixel(piece.GetSAWidth())); det.SetForbidFlipping(piece.IsForbidFlipping()); det.SetForceFlipping(piece.IsForceFlipping()); det.SetId(id); @@ -513,12 +514,13 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai { const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.") .arg(piece.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } det.SetCountourPoints(futureMainPath.result(), - qApp->Settings()->IsPieceShowMainPath() ? false : piece.IsHideMainPath()); + VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() ? false + : piece.IsHideMainPath()); det.SetSeamAllowancePoints(futureSeamAllowance.result(), piece.IsSeamAllowance(), piece.IsSeamAllowanceBuiltIn()); det.SetInternalPaths(futureInternalPaths.result()); det.SetPassmarks(futurePassmarks.result()); @@ -535,14 +537,14 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai det.SetQuantity(data.GetQuantity()); if (data.IsVisible()) { - det.SetPieceText(piece.GetName(), data, qApp->Settings()->GetLabelFont(), pattern); + det.SetPieceText(piece.GetName(), data, VAbstractApplication::VApp()->Settings()->GetLabelFont(), pattern); } const VPatternLabelData& geom = piece.GetPatternInfo(); if (geom.IsVisible()) { - VAbstractPattern* pDoc = qApp->getCurrentDocument(); - det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), pattern); + VAbstractPattern* pDoc = VAbstractValApplication::VApp()->getCurrentDocument(); + det.SetPatternInfo(pDoc, geom, VAbstractApplication::VApp()->Settings()->GetLabelFont(), pattern); } const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry(); @@ -1158,7 +1160,7 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const QPen pen = pathItem->pen(); pen.setStyle(path.PenStyle()); - pen.setWidthF(qApp->Settings()->WidthHairLine()); + pen.setWidthF(VAbstractApplication::VApp()->Settings()->WidthHairLine()); pathItem->setPen(pen); } @@ -1166,7 +1168,7 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const { QGraphicsPathItem* pathItem = new QGraphicsPathItem(item); QPen pen = pathItem->pen(); - pen.setWidthF(qApp->Settings()->WidthHairLine()); + pen.setWidthF(VAbstractApplication::VApp()->Settings()->WidthHairLine()); pathItem->setPen(pen); pathItem->setPath(d->matrix.map(VPlaceLabelItem::LabelShapePath(label.shape))); } @@ -1333,7 +1335,7 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const return; } auto* item = new VGraphicsFillItem(parent); - item->SetWidth(qApp->Settings()->WidthHairLine()); + item->SetWidth(VAbstractApplication::VApp()->Settings()->WidthHairLine()); QPainterPath path; @@ -1364,7 +1366,7 @@ QGraphicsPathItem *VLayoutPiece::GetMainItem() const { QGraphicsPathItem *item = new QGraphicsPathItem(); QPen pen = item->pen(); - pen.setWidthF(qApp->Settings()->WidthHairLine()); + pen.setWidthF(VAbstractApplication::VApp()->Settings()->WidthHairLine()); item->setPen(pen); item->setPath(ContourPath()); return item; @@ -1375,7 +1377,7 @@ QGraphicsPathItem *VLayoutPiece::GetMainPathItem() const { QGraphicsPathItem *item = new QGraphicsPathItem(); QPen pen = item->pen(); - pen.setWidthF(qApp->Settings()->WidthHairLine()); + pen.setWidthF(VAbstractApplication::VApp()->Settings()->WidthHairLine()); item->setPen(pen); QPainterPath path; diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index 13d8fdd51..dab321692 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -309,8 +309,8 @@ QVector VPoster::ImageWatermark(QGraphicsItem *parent, const Po if (watermark.isNull()) { const QString errorMsg = tr("Cannot open the watermark image.") + QChar(' ') + error; - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return data; } @@ -319,8 +319,8 @@ QVector VPoster::ImageWatermark(QGraphicsItem *parent, const Po else { const QString errorMsg = tr("Not supported file suffix '%1'").arg(f.suffix()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return data; } @@ -456,7 +456,7 @@ void VPoster::Ruler(QVector &data, QGraphicsItem *parent, QRect const qreal notchHeight = ToPixel(3); // mm const qreal shortNotchHeight = ToPixel(1.1); // mm - Unit patternUnits = qApp->patternUnits(); + Unit patternUnits = VAbstractValApplication::VApp()->patternUnits(); const qreal step = UnitConvertor(1, patternUnits, Unit::Px); double marksCount = rec.width() / step; int i = 0; diff --git a/src/libs/vlayout/vprintlayout.cpp b/src/libs/vlayout/vprintlayout.cpp index 4ad0b0cb4..576ec0f23 100644 --- a/src/libs/vlayout/vprintlayout.cpp +++ b/src/libs/vlayout/vprintlayout.cpp @@ -320,7 +320,8 @@ void VPrintLayout::PrintPages(QPrinter *printer) } painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine, + Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); int count = 0; @@ -732,8 +733,8 @@ auto VPrintLayout::WatermarkData() const -> VWatermarkData catch (VException &e) { const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index b32648954..f131314d2 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -175,7 +175,7 @@ QMap PreparePlaceholders(const VAbstractPattern *doc, const VC QMap placeholders; // Pattern tags - QLocale locale(qApp->Settings()->GetLocale()); + QLocale locale(VAbstractApplication::VApp()->Settings()->GetLocale()); const QString date = locale.toString(QDate::currentDate(), doc->GetLabelDateFormat()); placeholders.insert(pl_date, date); @@ -187,18 +187,19 @@ QMap PreparePlaceholders(const VAbstractPattern *doc, const VC placeholders.insert(pl_patternNumber, doc->GetPatternNumber()); placeholders.insert(pl_author, doc->GetCompanyName()); - placeholders.insert(pl_mUnits, UnitsToStr(qApp->MeasurementsUnits(), true)); - placeholders.insert(pl_pUnits, UnitsToStr(qApp->patternUnits(), true)); - placeholders.insert(pl_mSizeUnits, UnitsToStr(qApp->DimensionSizeUnits(), true)); + placeholders.insert(pl_mUnits, UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true)); + placeholders.insert(pl_pUnits, UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); + placeholders.insert(pl_mSizeUnits, UnitsToStr(VAbstractValApplication::VApp()->DimensionSizeUnits(), true)); - if (qApp->GetMeasurementsType() == MeasurementsType::Individual) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Individual) { - placeholders.insert(pl_customer, qApp->GetCustomerName()); + placeholders.insert(pl_customer, VAbstractValApplication::VApp()->GetCustomerName()); - const QString birthDate = locale.toString(qApp->GetCustomerBirthDate(), doc->GetLabelDateFormat()); + const QString birthDate = locale.toString(VAbstractValApplication::VApp()->GetCustomerBirthDate(), + doc->GetLabelDateFormat()); placeholders.insert(pl_birthDate, birthDate); - placeholders.insert(pl_email, qApp->CustomerEmail()); + placeholders.insert(pl_email, VAbstractValApplication::VApp()->CustomerEmail()); } else { @@ -211,15 +212,15 @@ QMap PreparePlaceholders(const VAbstractPattern *doc, const VC } placeholders.insert(pl_pExt, QStringLiteral("val")); - placeholders.insert(pl_pFileName, QFileInfo(qApp->GetPatternPath()).baseName()); + placeholders.insert(pl_pFileName, QFileInfo(VAbstractValApplication::VApp()->GetPatternPath()).baseName()); placeholders.insert(pl_mFileName, QFileInfo(doc->MPath()).baseName()); - placeholders.insert(pl_height, QString::number(qApp->GetDimensionHeight())); - placeholders.insert(pl_size, QString::number(qApp->GetDimensionSize())); - placeholders.insert(pl_hip, QString::number(qApp->GetDimensionHip())); - placeholders.insert(pl_waist, QString::number(qApp->GetDimensionWaist())); - placeholders.insert(pl_mExt, qApp->GetMeasurementsType() == MeasurementsType::Multisize ? QString("vst") - : QString("vit")); + placeholders.insert(pl_height, QString::number(VAbstractValApplication::VApp()->GetDimensionHeight())); + placeholders.insert(pl_size, QString::number(VAbstractValApplication::VApp()->GetDimensionSize())); + placeholders.insert(pl_hip, QString::number(VAbstractValApplication::VApp()->GetDimensionHip())); + placeholders.insert(pl_waist, QString::number(VAbstractValApplication::VApp()->GetDimensionWaist())); + placeholders.insert(pl_mExt, VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize + ? QString("vst") : QString("vit")); const QMap materials = doc->GetPatternMaterials(); for (int i = 0; i < userMaterialPlaceholdersQuantity; ++i) @@ -265,8 +266,8 @@ QMap PreparePlaceholders(const VAbstractPattern *doc, const VC { const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at " "line %1: %2.").arg(i+1).arg(e.GetMsg()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } } @@ -317,8 +318,8 @@ QString ReplacePlaceholders(const QMap &placeholders, QString { if (line.contains(per+placeholder+per) && placeholders.value(placeholder) == QChar('0')) { - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } }; @@ -531,7 +532,8 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data, co { m_liLines.clear(); - QMap placeholders = PreparePlaceholders(qApp->getCurrentDocument(), pattern); + QMap placeholders = + PreparePlaceholders(VAbstractValApplication::VApp()->getCurrentDocument(), pattern); InitPiecePlaceholders(placeholders, qsName, data); QVector lines = data.GetLabelTemplate(); diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 365850573..19e4e4641 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -599,7 +599,8 @@ void InitLanguages(QComboBox *combobox) combobox->clear(); QStringList fileNames; - QDirIterator it(qApp->translationsPath(), QStringList("valentina_*.qm"), QDir::Files, QDirIterator::Subdirectories); + QDirIterator it(VAbstractApplication::VApp()->translationsPath(), QStringList("valentina_*.qm"), QDir::Files, + QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); @@ -636,7 +637,7 @@ void InitLanguages(QComboBox *combobox) } // set default translators and language checked - qint32 index = combobox->findData(qApp->Settings()->GetLocale()); + qint32 index = combobox->findData(VAbstractApplication::VApp()->Settings()->GetLocale()); if (index != -1) { combobox->setCurrentIndex(index); diff --git a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp index c6ae57e5d..9a86516ee 100644 --- a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp +++ b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp @@ -68,7 +68,7 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent) ui->checkBoxWithHeader->blockSignals(true); ui->buttonGroup->blockSignals(true); - ui->checkBoxWithHeader->setChecked(qApp->Settings()->GetDefCSVWithHeader()); + ui->checkBoxWithHeader->setChecked(VAbstractApplication::VApp()->Settings()->GetDefCSVWithHeader()); ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(VCommonSettings::GetDefCSVCodec())); SetSeparator(VCommonSettings::GetDefCSVSeparator()); diff --git a/src/libs/vmisc/testvapplication.h b/src/libs/vmisc/testvapplication.h index c1bf6d993..781307880 100644 --- a/src/libs/vmisc/testvapplication.h +++ b/src/libs/vmisc/testvapplication.h @@ -33,11 +33,6 @@ #include "projectversion.h" #include "../vmisc/vsettings.h" -#if defined(qApp) -#undef qApp -#endif -#define qApp (static_cast(QCoreApplication::instance())) - class VTestSettings; class TestVApplication : public VAbstractValApplication @@ -80,6 +75,11 @@ public: m_trVars = trVars; } + static TestVApplication *VApp() + { + return static_cast(QCoreApplication::instance()); + } + protected slots: virtual void AboutToQuit() override {} diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index 6e9359cd4..07747c91c 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -324,3 +324,9 @@ QFileDialog::Options VAbstractApplication::NativeFileDialog(QFileDialog::Options return options; } + +//--------------------------------------------------------------------------------------------------------------------- +auto VAbstractApplication::VApp() -> VAbstractApplication * +{ + return qobject_cast(QCoreApplication::instance()); +} diff --git a/src/libs/vmisc/vabstractapplication.h b/src/libs/vmisc/vabstractapplication.h index 7bc0ef3ab..12f5167c9 100644 --- a/src/libs/vmisc/vabstractapplication.h +++ b/src/libs/vmisc/vabstractapplication.h @@ -49,11 +49,6 @@ class QUndoStack; class VAbstractApplication;// use in define class VCommonSettings; -#if defined(qApp) -#undef qApp -#endif -#define qApp (qobject_cast(QCoreApplication::instance())) - class VAbstractApplication : public QApplication { Q_OBJECT @@ -89,6 +84,8 @@ public: static void WinAttachConsole(); #endif + static VAbstractApplication *VApp(); + protected: QUndoStack *undoStack; @@ -119,7 +116,7 @@ template inline QString VAbstractApplication::LocaleToString(const T &value) { QLocale loc; - qApp->Settings()->GetOsSeparator() ? loc = QLocale() : loc = QLocale::c(); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? loc = QLocale() : loc = QLocale::c(); return loc.toString(value); } diff --git a/src/libs/vmisc/vabstractvalapplication.cpp b/src/libs/vmisc/vabstractvalapplication.cpp index dc901f2b9..d45a02604 100644 --- a/src/libs/vmisc/vabstractvalapplication.cpp +++ b/src/libs/vmisc/vabstractvalapplication.cpp @@ -71,5 +71,11 @@ void VAbstractValApplication::OpenSettings() VSettings *VAbstractValApplication::ValentinaSettings() { SCASSERT(settings != nullptr) - return qobject_cast(settings); + return qobject_cast(settings); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VAbstractValApplication::VApp() -> VAbstractValApplication * +{ + return qobject_cast(QCoreApplication::instance()); } diff --git a/src/libs/vmisc/vabstractvalapplication.h b/src/libs/vmisc/vabstractvalapplication.h index eb603a50b..d6e74898c 100644 --- a/src/libs/vmisc/vabstractvalapplication.h +++ b/src/libs/vmisc/vabstractvalapplication.h @@ -38,11 +38,6 @@ class VMainGraphicsView; class QGraphicsScene; class VSettings; -#if defined(qApp) -#undef qApp -#endif -#define qApp (qobject_cast(QCoreApplication::instance())) - class VAbstractValApplication : public VAbstractApplication { Q_OBJECT @@ -116,6 +111,8 @@ public: virtual void OpenSettings() override; VSettings *ValentinaSettings(); + static VAbstractValApplication *VApp(); + protected: QString m_customerName{}; QDate m_customerBirthDate{}; diff --git a/src/libs/vpatterndb/calculator.cpp b/src/libs/vpatterndb/calculator.cpp index 105877a47..56b2cf4e3 100644 --- a/src/libs/vpatterndb/calculator.cpp +++ b/src/libs/vpatterndb/calculator.cpp @@ -48,7 +48,7 @@ * Use this constuctor for evaluation formula. All formulas must be converted to internal look. * Example: * - * const QString formula = qApp->FormulaFromUser(edit->text()); + * const QString formula = VAbstractApplication::VApp()->FormulaFromUser(edit->text()); * Calculator *cal = new Calculator(data, patternType); * const qreal result = cal->EvalFormula(data->PlainVariables(), formula); * delete cal; @@ -124,8 +124,8 @@ qreal *Calculator::VarFactory(const QString &a_szName, void *a_pUserData) //--------------------------------------------------------------------------------------------------------------------- qreal Calculator::Warning(const QString &warningMsg, qreal value) { - qApp->IsPedantic() ? throw qmu::QmuParserWarning(warningMsg) - : qWarning() << VAbstractApplication::warningMessageSignature + warningMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw qmu::QmuParserWarning(warningMsg) : + qWarning() << VAbstractApplication::warningMessageSignature + warningMsg; return value; } diff --git a/src/libs/vpatterndb/pmsystems.cpp b/src/libs/vpatterndb/pmsystems.cpp index 9aa29fb9e..b11313c67 100644 --- a/src/libs/vpatterndb/pmsystems.cpp +++ b/src/libs/vpatterndb/pmsystems.cpp @@ -161,14 +161,15 @@ void InitPMSystems(QComboBox *systemCombo) QMap systems; for (auto &sys : listSystems) { - systems.insert(qApp->TrVars()->PMSystemName(sys) + QLatin1String(" (") + sys + QLatin1String(")"), sys); + systems.insert(VAbstractApplication::VApp()->TrVars()->PMSystemName(sys) + QLatin1String(" (") + sys + + QLatin1String(")"), sys); } // * The default option (blank field or 'None') should appear at the top of the list. // * The list should be sorted alphabetically so users can find their system easily. SCASSERT(systemCombo != nullptr) - systemCombo->addItem(qApp->TrVars()->PMSystemName(listSystems.at(listSystems.size()-1)), + systemCombo->addItem(VAbstractApplication::VApp()->TrVars()->PMSystemName(listSystems.at(listSystems.size()-1)), listSystems.at(listSystems.size()-1)); QMap::const_iterator i = systems.constBegin(); diff --git a/src/libs/vpatterndb/vformula.cpp b/src/libs/vpatterndb/vformula.cpp index 1f1b98336..36e1e2a2e 100644 --- a/src/libs/vpatterndb/vformula.cpp +++ b/src/libs/vpatterndb/vformula.cpp @@ -94,7 +94,7 @@ QString VFormula::GetFormula(FormulaType type) const { if (type == FormulaType::ToUser) { - return VTranslateVars::TryFormulaToUser(d->formula, qApp->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaToUser(d->formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } else { @@ -109,7 +109,8 @@ void VFormula::SetFormula(const QString &value, FormulaType type) { if (type == FormulaType::FromUser) { - d->formula = VTranslateVars::TryFormulaFromUser(value, qApp->Settings()->GetOsSeparator()); + d->formula = VTranslateVars::TryFormulaFromUser(value, + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } else { @@ -262,7 +263,7 @@ void VFormula::Eval() } else { - d->strValue = qApp->LocaleToString(result) + QLatin1Char(' ') + d->postfix; + d->strValue = VAbstractApplication::VApp()->LocaleToString(result) + QLatin1Char(' ') + d->postfix; d->error = false; } } diff --git a/src/libs/vpatterndb/vpassmark.cpp b/src/libs/vpatterndb/vpassmark.cpp index d6eda48aa..7e552e790 100644 --- a/src/libs/vpatterndb/vpassmark.cpp +++ b/src/libs/vpatterndb/vpassmark.cpp @@ -578,8 +578,8 @@ QVector PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " "than minimal allowed.") .arg(passmarkData.nodeName, passmarkData.pieceName); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); } @@ -661,8 +661,8 @@ QVector VPassmark::FullPassmark(const VPiece &piece, const VContainer *d { QVector lines; lines += SAPassmark(piece, data, PassmarkSide::All); - if (qApp->Settings()->IsDoublePassmark() - && (qApp->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) + if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() + && (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) && m_data.isMainPathNode && m_data.passmarkAngleType != PassmarkAngleType::Intersection && m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft @@ -787,7 +787,7 @@ QVector VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " "than minimal allowed.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); } @@ -803,8 +803,8 @@ QVector VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2' with built in " "seam allowance. User must manually provide length.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); } } @@ -847,8 +847,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa { const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is " "empty.").arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); // Something wrong } @@ -859,8 +859,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find " "position for a notch.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); // Something wrong } @@ -869,8 +869,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a " "notch position.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } auto PassmarkIntersection = [this, seamAllowance] (QLineF line, qreal width) @@ -896,8 +896,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is " "less than minimal allowed.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QLineF(); } line.setLength(length); @@ -913,8 +913,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch " "collapse.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } else @@ -922,8 +922,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find " "intersection.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } return QLineF(); @@ -937,8 +937,8 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " "than minimal allowed.") .arg(m_data.nodeName, m_data.pieceName); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } else { diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 8f22261e9..3aa2e566b 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -936,8 +936,8 @@ bool VPiece::GetPassmarkPreviousSAPoints(const QVector &path, int in { const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return false; // Something wrong } @@ -975,8 +975,8 @@ bool VPiece::GetPassmarkNextSAPoints(const QVector &path, int index, { const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return false; // Something wrong } @@ -1059,8 +1059,8 @@ VPassmark VPiece::CreatePassmark(const QVector &path, int previousIn { const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); - qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return VPassmark(); } diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index 719d8f089..b2178a4d3 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -161,8 +161,8 @@ qreal VPieceNode::GetSABefore(const VContainer *data) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return -1; } return formula.getDoubleValue(); @@ -192,8 +192,8 @@ qreal VPieceNode::GetSABefore(const VContainer *data, Unit unit) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return -1; } @@ -244,8 +244,8 @@ qreal VPieceNode::GetSAAfter(const VContainer *data) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return -1; } @@ -276,8 +276,8 @@ qreal VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: ") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return -1; } @@ -342,8 +342,8 @@ qreal VPieceNode::GetPassmarkLength(const VContainer *data, Unit unit) const const QString errorMsg = QObject::tr("Cannot calculate passmark length for point '%1'. Reason: %2.") .arg(nodeName, formula.Reason()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return VSAPoint::maxPassmarkLength; } diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 0cd36482c..b5263a753 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -384,8 +384,8 @@ QVector VPiecePath::PathPoints(const VContainer *data, const QVectorIsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } @@ -401,8 +401,8 @@ QVector VPiecePath::PathPoints(const VContainer *data, const QVectorIsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } diff --git a/src/libs/vpatterndb/vtranslatemeasurements.cpp b/src/libs/vpatterndb/vtranslatemeasurements.cpp index 48e1cc4df..05e086a99 100644 --- a/src/libs/vpatterndb/vtranslatemeasurements.cpp +++ b/src/libs/vpatterndb/vtranslatemeasurements.cpp @@ -62,7 +62,7 @@ bool VTranslateMeasurements::MeasurementsFromUser(QString &newFormula, int posit QMap::const_iterator i = measurements.constBegin(); while (i != measurements.constEnd()) { - if (token == i.value().translate(qApp->Settings()->GetLocale())) + if (token == i.value().translate(VAbstractApplication::VApp()->Settings()->GetLocale())) { newFormula.replace(position, token.length(), i.key()); bias = token.length() - i.key().length(); @@ -79,7 +79,7 @@ QString VTranslateMeasurements::MFromUser(const QString &measurement) const QMap::const_iterator i = measurements.constBegin(); while (i != measurements.constEnd()) { - const QString translated = i.value().translate(qApp->Settings()->GetLocale()); + const QString translated = i.value().translate(VAbstractApplication::VApp()->Settings()->GetLocale()); if (measurement == translated) { return i.key(); @@ -94,7 +94,7 @@ QString VTranslateMeasurements::MToUser(const QString &measurement) const { if (measurements.contains(measurement)) { - return measurements.value(measurement).translate(qApp->Settings()->GetLocale()); + return measurements.value(measurement).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } else { @@ -126,7 +126,7 @@ QString VTranslateMeasurements::GuiText(const QString &measurement) const { if (guiTexts.contains(measurement)) { - return guiTexts.value(measurement).translate(qApp->Settings()->GetLocale()); + return guiTexts.value(measurement).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } else { @@ -139,7 +139,7 @@ QString VTranslateMeasurements::Description(const QString &measurement) const { if (descriptions.contains(measurement)) { - return descriptions.value(measurement).translate(qApp->Settings()->GetLocale()); + return descriptions.value(measurement).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } else { diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index d75078b84..0c42f39fd 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -547,7 +547,7 @@ void VTranslateVars::PrepareFunctionTranslations() QMap::const_iterator i = functions.constBegin(); while (i != functions.constEnd()) { - const QString translated = i.value().translate(qApp->Settings()->GetLocale()); + const QString translated = i.value().translate(VAbstractApplication::VApp()->Settings()->GetLocale()); if (i.key() != translated) { translatedFunctions.insert(translated, i.key()); @@ -628,15 +628,16 @@ void VTranslateVars::BiasTokens(int position, int bias, QMap &toke */ bool VTranslateVars::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const { - const QString currentLengthTr = variables.value(currentLength).translate(qApp->Settings()->GetLocale()); + const QString currentLengthTr = + variables.value(currentLength).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); const QString currentSeamAllowanceTr = variables.value(currentSeamAllowance) - .translate(qApp->Settings()->GetLocale()); + .translate(VAbstractApplication::VApp()->Settings()->GetLocale()); QMap::const_iterator i = variables.constBegin(); while (i != variables.constEnd()) { const qmu::QmuTranslation &var = i.value(); - const QString varTr = var.translate(qApp->Settings()->GetLocale()); + const QString varTr = var.translate(VAbstractApplication::VApp()->Settings()->GetLocale()); if (token.indexOf(varTr) == 0) { @@ -671,7 +672,7 @@ bool VTranslateVars::FunctionsFromUser(QString &newFormula, int position, const QMap::const_iterator i = functions.constBegin(); while (i != functions.constEnd()) { - if (token == i.value().translate(qApp->Settings()->GetLocale())) + if (token == i.value().translate(VAbstractApplication::VApp()->Settings()->GetLocale())) { newFormula.replace(position, token.length(), i.key()); bias = token.length() - i.key().length(); @@ -704,10 +705,12 @@ bool VTranslateVars::VariablesToUser(QString &newFormula, int position, const QS continue; } - newFormula.replace(position, i.key().length(), i.value().translate(qApp->Settings()->GetLocale())); + newFormula.replace(position, i.key().length(), + i.value().translate(VAbstractApplication::VApp()->Settings()->GetLocale())); QString newToken = token; - newToken.replace(0, i.key().length(), i.value().translate(qApp->Settings()->GetLocale())); + newToken.replace(0, i.key().length(), + i.value().translate(VAbstractApplication::VApp()->Settings()->GetLocale())); bias = token.length() - newToken.length(); return true; } @@ -734,19 +737,19 @@ QString VTranslateVars::InternalVarToUser(const QString &var) const //--------------------------------------------------------------------------------------------------------------------- QString VTranslateVars::VarToUser(const QString &var) const { - if (qApp->Settings()->GetLocale() == QStringLiteral("zh_CN")) + if (VAbstractApplication::VApp()->Settings()->GetLocale() == QStringLiteral("zh_CN")) { return var; // We do not support translation of variables for Chinese } if (measurements.contains(var)) { - return measurements.value(var).translate(qApp->Settings()->GetLocale()); + return measurements.value(var).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } if (functions.contains(var)) { - return functions.value(var).translate(qApp->Settings()->GetLocale()); + return functions.value(var).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } return InternalVarToUser(var); @@ -755,7 +758,7 @@ QString VTranslateVars::VarToUser(const QString &var) const //--------------------------------------------------------------------------------------------------------------------- QString VTranslateVars::VarFromUser(const QString &var) const { - if (qApp->Settings()->GetLocale() == QStringLiteral("zh_CN")) + if (VAbstractApplication::VApp()->Settings()->GetLocale() == QStringLiteral("zh_CN")) { return var; // We do not support translation of variables for Chinese } @@ -782,19 +785,19 @@ QString VTranslateVars::VarFromUser(const QString &var) const //--------------------------------------------------------------------------------------------------------------------- QString VTranslateVars::PMSystemName(const QString &code) const { - return PMSystemNames.value(code).translate(qApp->Settings()->GetLocale()); + return PMSystemNames.value(code).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } //--------------------------------------------------------------------------------------------------------------------- QString VTranslateVars::PMSystemAuthor(const QString &code) const { - return PMSystemAuthors.value(code).translate(qApp->Settings()->GetLocale()); + return PMSystemAuthors.value(code).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } //--------------------------------------------------------------------------------------------------------------------- QString VTranslateVars::PMSystemBook(const QString &code) const { - return PMSystemBooks.value(code).translate(qApp->Settings()->GetLocale()); + return PMSystemBooks.value(code).translate(VAbstractApplication::VApp()->Settings()->GetLocale()); } //--------------------------------------------------------------------------------------------------------------------- @@ -900,8 +903,8 @@ QString VTranslateVars::TryFormulaFromUser(const QString &formula, bool osSepara { try { - SCASSERT(qApp->TrVars() != nullptr) - return qApp->TrVars()->FormulaFromUser(formula, osSeparator); + SCASSERT(VAbstractApplication::VApp()->TrVars() != nullptr) + return VAbstractApplication::VApp()->TrVars()->FormulaFromUser(formula, osSeparator); } catch (qmu::QmuParserError &e)// In case something bad will happen { @@ -951,9 +954,10 @@ QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) if (measurements.contains(tValues.at(i))) { newFormula.replace(tKeys.at(i), tValues.at(i).length(), - measurements.value(tValues.at(i)).translate(qApp->Settings()->GetLocale())); + measurements.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); int bias = tValues.at(i).length() - measurements.value(tValues.at(i)) - .translate(qApp->Settings()->GetLocale()).length(); + .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); if (bias != 0) {// Translated token has different length than original. Position next tokens need to be corrected. CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); @@ -966,9 +970,10 @@ QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) if (functions.contains(tValues.at(i))) { newFormula.replace(tKeys.at(i), tValues.at(i).length(), - functions.value(tValues.at(i)).translate(qApp->Settings()->GetLocale())); + functions.value(tValues.at(i)) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale())); int bias = tValues.at(i).length() - functions.value(tValues.at(i)) - .translate(qApp->Settings()->GetLocale()).length(); + .translate(VAbstractApplication::VApp()->Settings()->GetLocale()).length(); if (bias != 0) {// Translated token has different length than original. Position next tokens need to be corrected. CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); @@ -1037,7 +1042,7 @@ QString VTranslateVars::TryFormulaToUser(const QString &formula, bool osSeparato { try { - return qApp->TrVars()->FormulaToUser(formula, osSeparator); + return VAbstractApplication::VApp()->TrVars()->FormulaToUser(formula, osSeparator); } catch (qmu::QmuParserError &e)// In case something bad will happen { diff --git a/src/libs/vtools/dialogs/dialogtoolbox.cpp b/src/libs/vtools/dialogs/dialogtoolbox.cpp index e77a435ba..a2ce91c1d 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.cpp +++ b/src/libs/vtools/dialogs/dialogtoolbox.cpp @@ -182,7 +182,7 @@ bool FilterObject(QObject *object, QEvent *event) QKeyEvent *keyEvent = static_cast(event); if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier)) { - if (qApp->Settings()->GetOsSeparator()) + if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) { plainTextEdit->insertPlainText(QLocale().decimalPoint()); } @@ -218,7 +218,9 @@ qreal EvalToolFormula(QDialog *dialog, const FormulaData &data, bool &flag) try { // Translate to internal look. - QString formula = qApp->TrVars()->FormulaFromUser(data.formula, qApp->Settings()->GetOsSeparator()); + QString formula = VAbstractApplication::VApp() + ->TrVars()->FormulaFromUser(data.formula, + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); QScopedPointer cal(new Calculator()); result = cal->EvalFormula(data.variables, formula); @@ -249,7 +251,8 @@ qreal EvalToolFormula(QDialog *dialog, const FormulaData &data, bool &flag) } else { - data.labelResult->setText(qApp->LocaleToString(result) + QChar(QChar::Space) + data.postfix); + data.labelResult->setText(VAbstractApplication::VApp() + ->LocaleToString(result) + QChar(QChar::Space) + data.postfix); flag = true; ChangeColor(data.labelEditFormula, OkColor(dialog)); data.labelResult->setToolTip(QObject::tr("Value")); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 55b5f2ba9..ca0ae266a 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -297,11 +297,12 @@ void DialogEditLabel::NewTemplate() void DialogEditLabel::ExportTemplate() { QString filters(tr("Label template") + QLatin1String("(*.xml)")); - const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate()); + const QString path = + VCommonSettings::PrepareLabelTemplates(VAbstractApplication::VApp()->Settings()->GetPathLabelTemplate()); QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"), path + QLatin1String("/") + tr("template") + QLatin1String(".xml"), - filters, nullptr, qApp->NativeFileDialog()); + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { @@ -349,9 +350,10 @@ void DialogEditLabel::ImportTemplate() QString filter(tr("Label template") + QLatin1String(" (*.xml)")); //Use standard path to label templates - const QString path = VCommonSettings::PrepareLabelTemplates(qApp->Settings()->GetPathLabelTemplate()); + const QString path = + VCommonSettings::PrepareLabelTemplates(VAbstractApplication::VApp()->Settings()->GetPathLabelTemplate()); const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { return; @@ -483,7 +485,7 @@ void DialogEditLabel::InitPlaceholdersMenu() void DialogEditLabel::InitPlaceholders() { // Pattern tags - QLocale locale(qApp->Settings()->GetLocale()); + QLocale locale(VAbstractApplication::VApp()->Settings()->GetLocale()); const QString date = locale.toString(QDate::currentDate(), m_doc->GetLabelDateFormat()); m_placeholders.insert(pl_date, qMakePair(tr("Date"), date)); @@ -495,18 +497,25 @@ void DialogEditLabel::InitPlaceholders() m_placeholders.insert(pl_patternNumber, qMakePair(tr("Pattern number"), m_doc->GetPatternNumber())); m_placeholders.insert(pl_author, qMakePair(tr("Company name or designer name"), m_doc->GetCompanyName())); - m_placeholders.insert(pl_mUnits, qMakePair(tr("Measurements units"), UnitsToStr(qApp->MeasurementsUnits(), true))); - m_placeholders.insert(pl_pUnits, qMakePair(tr("Pattern units"), UnitsToStr(qApp->patternUnits(), true))); - m_placeholders.insert(pl_mSizeUnits, qMakePair(tr("Size units"), UnitsToStr(qApp->DimensionSizeUnits(), true))); + m_placeholders.insert(pl_mUnits, qMakePair(tr("Measurements units"), + UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true))); + m_placeholders.insert(pl_pUnits, qMakePair(tr("Pattern units"), + UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); + m_placeholders.insert(pl_mSizeUnits, qMakePair(tr("Size units"), + UnitsToStr(VAbstractValApplication::VApp()->DimensionSizeUnits(), + true))); - if (qApp->GetMeasurementsType() == MeasurementsType::Individual) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Individual) { - m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), qApp->GetCustomerName())); + m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), + VAbstractValApplication::VApp()->GetCustomerName())); - const QString birthDate = locale.toString(qApp->GetCustomerBirthDate(), m_doc->GetLabelDateFormat()); + const QString birthDate = locale.toString(VAbstractValApplication::VApp()->GetCustomerBirthDate(), + m_doc->GetLabelDateFormat()); m_placeholders.insert(pl_birthDate, qMakePair(tr("Customer birth date"), birthDate)); - m_placeholders.insert(pl_email, qMakePair(tr("Customer email"), qApp->CustomerEmail())); + m_placeholders.insert(pl_email, qMakePair(tr("Customer email"), + VAbstractValApplication::VApp()->CustomerEmail())); } else { @@ -520,20 +529,24 @@ void DialogEditLabel::InitPlaceholders() m_placeholders.insert(pl_pExt, qMakePair(tr("Pattern extension"), QString("val"))); - const QString patternFilePath = QFileInfo(qApp->GetPatternPath()).baseName(); + const QString patternFilePath = QFileInfo(VAbstractValApplication::VApp()->GetPatternPath()).baseName(); m_placeholders.insert(pl_pFileName, qMakePair(tr("Pattern file name"), patternFilePath)); const QString measurementsFilePath = QFileInfo(m_doc->MPath()).baseName(); m_placeholders.insert(pl_mFileName, qMakePair(tr("Measurments file name"), measurementsFilePath)); - m_placeholders.insert(pl_height, qMakePair(tr("Height", "dimension"), QString::number(qApp->GetDimensionHeight()))); - m_placeholders.insert(pl_size, qMakePair(tr("Size", "dimension"), QString::number(qApp->GetDimensionSize()))); - m_placeholders.insert(pl_hip, qMakePair(tr("Hip", "dimension"), QString::number(qApp->GetDimensionHip()))); - m_placeholders.insert(pl_waist, qMakePair(tr("Waist", "dimension"), QString::number(qApp->GetDimensionWaist()))); + m_placeholders.insert(pl_height, qMakePair(tr("Height", "dimension"), + QString::number(VAbstractValApplication::VApp()->GetDimensionHeight()))); + m_placeholders.insert(pl_size, qMakePair(tr("Size", "dimension"), + QString::number(VAbstractValApplication::VApp()->GetDimensionSize()))); + m_placeholders.insert(pl_hip, qMakePair(tr("Hip", "dimension"), + QString::number(VAbstractValApplication::VApp()->GetDimensionHip()))); + m_placeholders.insert(pl_waist, qMakePair(tr("Waist", "dimension"), + QString::number(VAbstractValApplication::VApp()->GetDimensionWaist()))); m_placeholders.insert(pl_mExt, qMakePair(tr("Measurments extension"), - qApp->GetMeasurementsType() == MeasurementsType::Multisize ? QString("vst") - : QString("vit"))); + VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize + ? QString("vst") : QString("vit"))); const QString materialDescription = tr("User material"); const QMap materials = m_doc->GetPatternMaterials(); @@ -582,8 +595,8 @@ void DialogEditLabel::InitPlaceholders() { const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at " "line %1: %2.").arg(i+1).arg(e.GetMsg()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } } @@ -614,8 +627,8 @@ QString DialogEditLabel::ReplacePlaceholders(QString line) const { if (line.contains(per+placeholder+per) && m_placeholders.value(placeholder).second == QChar('0')) { - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } }; diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index 7a09bdb0e..747c0b8c2 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -75,8 +75,10 @@ enum {ColumnName = 0, ColumnFullName}; //--------------------------------------------------------------------------------------------------------------------- DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 toolId, QWidget *parent) - : DialogTool(data, toolId, parent), + : QDialog(parent), ui(new Ui::DialogEditWrongFormula), + m_data(data), + m_toolId(toolId), formula(), formulaBaseHeight(0), checkZero(false), @@ -86,6 +88,8 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 t timerFormula(new QTimer(this)), flagFormula(false) { + SCASSERT(data != nullptr) + ui->setupUi(this); timerFormula->setSingleShot(true); @@ -102,7 +106,15 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 t connect(ui->filterFormulaInputs, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FilterVariablesEdited); - InitOkCancel(ui); + QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr) + connect(bOk, &QPushButton::clicked, this, &DialogEditWrongFormula::DialogAccepted); + + QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel); + SCASSERT(bCancel != nullptr) + connect(bCancel, &QPushButton::clicked, this, &DialogEditWrongFormula::DialogRejected); + + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere); connect(ui->tableWidget, &QTableWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal); @@ -161,7 +173,7 @@ void DialogEditWrongFormula::EvalFormula() { FormulaData formulaData; formulaData.formula = ui->plainTextEditFormula->toPlainText(); - formulaData.variables = data->DataVariables(); + formulaData.variables = m_data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; formulaData.postfix = postfix; @@ -184,55 +196,55 @@ void DialogEditWrongFormula::ValChanged(int row) return; } QTableWidgetItem *item = ui->tableWidget->item( row, ColumnName ); - const QString name = qApp->TrVars()->VarFromUser(item->text()); + const QString name = VAbstractApplication::VApp()->TrVars()->VarFromUser(item->text()); try { if (ui->radioButtonStandardTable->isChecked()) { - const QSharedPointer stable = data->GetVariable(name); + const QSharedPointer stable = m_data->GetVariable(name); SetDescription(item->text(), *stable->GetValue(), stable->IsSpecialUnits(), stable->GetGuiText()); } else if (ui->radioButtonIncrements->isChecked()) { - const QSharedPointer incr = data->GetVariable(name); + const QSharedPointer incr = m_data->GetVariable(name); const bool specialUnits = false; SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription()); } else if (ui->radioButtonPC->isChecked()) { - const QSharedPointer incr = data->GetVariable(name); + const QSharedPointer incr = m_data->GetVariable(name); const bool specialUnits = false; SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription()); } else if (ui->radioButtonLengthLine->isChecked()) { const bool specialUnits = false; - SetDescription(item->text(), *data->GetVariable(name)->GetValue(), specialUnits, + SetDescription(item->text(), *m_data->GetVariable(name)->GetValue(), specialUnits, tr("Line length")); } else if (ui->radioButtonLengthSpline->isChecked()) { const bool specialUnits = false; - SetDescription(item->text(), *data->GetVariable(name)->GetValue(), specialUnits, + SetDescription(item->text(), *m_data->GetVariable(name)->GetValue(), specialUnits, tr("Curve length")); } else if (ui->radioButtonAngleLine->isChecked()) { const bool specialUnits = true; - SetDescription(item->text(), *data->GetVariable(name)->GetValue(), specialUnits, + SetDescription(item->text(), *m_data->GetVariable(name)->GetValue(), specialUnits, tr("Line Angle")); } else if (ui->radioButtonRadiusesArcs->isChecked()) { const bool specialUnits = false; - SetDescription(item->text(), *data->GetVariable(name)->GetValue(), specialUnits, + SetDescription(item->text(), *m_data->GetVariable(name)->GetValue(), specialUnits, tr("Arc radius")); } else if (ui->radioButtonAnglesCurves->isChecked()) { const bool specialUnits = true; - SetDescription(item->text(), *data->GetVariable(name)->GetValue(), specialUnits, + SetDescription(item->text(), *m_data->GetVariable(name)->GetValue(), specialUnits, tr("Curve angle")); } else if (ui->radioButtonFunctions->isChecked()) @@ -282,7 +294,7 @@ void DialogEditWrongFormula::PutVal(QTableWidgetItem *item) void DialogEditWrongFormula::Measurements() { ui->checkBoxHideEmpty->setEnabled(true); - ShowMeasurements(data->DataMeasurements()); + ShowMeasurements(m_data->DataMeasurements()); } //--------------------------------------------------------------------------------------------------------------------- @@ -292,21 +304,21 @@ void DialogEditWrongFormula::Measurements() void DialogEditWrongFormula::LengthLines() { ui->checkBoxHideEmpty->setEnabled(false); - ShowVariable(data->DataLengthLines()); + ShowVariable(m_data->DataLengthLines()); } //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::RadiusArcs() { ui->checkBoxHideEmpty->setEnabled(false); - ShowVariable(data->DataRadiusesArcs()); + ShowVariable(m_data->DataRadiusesArcs()); } //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::AnglesCurves() { ui->checkBoxHideEmpty->setEnabled(false); - ShowVariable(data->DataAnglesCurves()); + ShowVariable(m_data->DataAnglesCurves()); } //--------------------------------------------------------------------------------------------------------------------- @@ -316,21 +328,21 @@ void DialogEditWrongFormula::AnglesCurves() void DialogEditWrongFormula::LengthCurves() { ui->checkBoxHideEmpty->setEnabled(false); - ShowVariable(data->DataLengthCurves()); + ShowVariable(m_data->DataLengthCurves()); } //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::CurvesCLength() { ui->checkBoxHideEmpty->setEnabled(false); - ShowVariable(data->DataCurvesCLength()); + ShowVariable(m_data->DataCurvesCLength()); } //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::AngleLines() { ui->checkBoxHideEmpty->setEnabled(false); - ShowVariable(data->DataAngleLines()); + ShowVariable(m_data->DataAngleLines()); } //--------------------------------------------------------------------------------------------------------------------- @@ -362,7 +374,7 @@ void DialogEditWrongFormula::Functions() void DialogEditWrongFormula::closeEvent(QCloseEvent *event) { ui->plainTextEditFormula->blockSignals(true); - DialogTool::closeEvent(event); + QDialog::closeEvent(event); } //--------------------------------------------------------------------------------------------------------------------- @@ -374,13 +386,13 @@ void DialogEditWrongFormula::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } // do your init stuff here - const QSize sz = qApp->Settings()->GetFormulaWizardDialogSize(); + const QSize sz = VAbstractApplication::VApp()->Settings()->GetFormulaWizardDialogSize(); if (not sz.isEmpty()) { resize(sz); @@ -388,7 +400,7 @@ void DialogEditWrongFormula::showEvent(QShowEvent *event) CheckState(); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -397,17 +409,32 @@ void DialogEditWrongFormula::resizeEvent(QResizeEvent *event) // remember the size for the next time this dialog is opened, but only // if widget was already initialized, which rules out the resize at // dialog creating, which would - if (isInitialized) + if (m_isInitialized) { - qApp->Settings()->SetFormulaWizardDialogSize(size()); + VAbstractApplication::VApp()->Settings()->SetFormulaWizardDialogSize(size()); + } + QDialog::resizeEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::CheckState() +{ + QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr) + bOk->setEnabled(IsValid()); + // In case dialog hasn't apply button + QPushButton *bApply = ui->buttonBox->button(QDialogButtonBox::Apply); + if (bApply != nullptr) + { + bApply->setEnabled(bOk->isEnabled()); } - DialogTool::resizeEvent(event); } //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormula->setPlainText(formula); MoveCursorToEnd(ui->plainTextEditFormula); ui->plainTextEditFormula->selectAll(); @@ -459,7 +486,8 @@ void DialogEditWrongFormula::SetPreviewCalculationsMode() //--------------------------------------------------------------------------------------------------------------------- QString DialogEditWrongFormula::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -510,11 +538,20 @@ void DialogEditWrongFormula::InitVariables() void DialogEditWrongFormula::SetDescription(const QString &name, qreal value, bool specialUnits, const QString &description) { - const QString unit = specialUnits ? degreeSymbol : " " + UnitsToStr(qApp->patternUnits(), true); + const QString unit = specialUnits ? degreeSymbol + : " " + UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const QString desc = QStringLiteral("%1(%2%3) - %4").arg(name).arg(value).arg(unit, description); ui->labelDescription->setText(desc); } +//--------------------------------------------------------------------------------------------------------------------- +qreal DialogEditWrongFormula::Eval(const FormulaData &formulaData, bool &flag) +{ + const qreal result = EvalToolFormula(this, formulaData, flag); + CheckState(); // Disable Ok and Apply buttons if something wrong. + return result; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowVariable show variables in list @@ -537,7 +574,7 @@ void DialogEditWrongFormula::ShowVariable(const QMap &var) { continue; //skip this measurement } - if (iMap.value()->Filter(toolId) == false) + if (iMap.value()->Filter(m_toolId) == false) {// If we create this variable don't show ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1); QTableWidgetItem *item = new QTableWidgetItem(iMap.key()); @@ -573,7 +610,7 @@ void DialogEditWrongFormula::ShowMeasurements(const QMapFilter(toolId) == false) + if (iMap.value()->Filter(m_toolId) == false) {// If we create this variable don't show ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1); QTableWidgetItem *itemName = new QTableWidgetItem(iMap.key()); @@ -592,7 +629,7 @@ void DialogEditWrongFormula::ShowMeasurements(const QMapsetText(qApp->TrVars()->GuiText(iMap.value()->GetName())); + itemFullName->setText(VAbstractApplication::VApp()->TrVars()->GuiText(iMap.value()->GetName())); } itemFullName->setToolTip(itemFullName->text()); @@ -617,20 +654,23 @@ void DialogEditWrongFormula::ShowFunctions() ui->tableWidget->setColumnHidden(ColumnFullName, true); ui->labelDescription->setText(QString()); - const QMap functionsDescriptions = qApp->TrVars()->GetFunctionsDescriptions(); - const QMap functions = qApp->TrVars()->GetFunctions(); + const QMap functionsDescriptions = + VAbstractApplication::VApp()->TrVars()->GetFunctionsDescriptions(); + const QMap functions = VAbstractApplication::VApp()->TrVars()->GetFunctions(); QMap::const_iterator i = functions.constBegin(); while (i != functions.constEnd()) { ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1); - QTableWidgetItem *item = new QTableWidgetItem(i.value().translate(qApp->Settings()->GetLocale())); + QTableWidgetItem *item = + new QTableWidgetItem(i.value().translate(VAbstractApplication::VApp()->Settings()->GetLocale())); QFont font = item->font(); font.setBold(true); item->setFont(font); ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, item); functionsDescriptions.contains(i.key()) - ? item->setToolTip(functionsDescriptions.value(i.key()).translate(qApp->Settings()->GetLocale())) + ? item->setToolTip(functionsDescriptions.value(i.key()) + .translate(VAbstractApplication::VApp()->Settings()->GetLocale())) : item->setToolTip(i.value().getMdisambiguation()); ++i; } @@ -647,7 +687,7 @@ void DialogEditWrongFormula::ShowIncrementsInPreviewCalculation(bool show) QMap > increments; - const QMap > list = data->DataIncrements(); + const QMap > list = m_data->DataIncrements(); QMap >::const_iterator i = list.constBegin(); while (i != list.constEnd()) { diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index 677802c1e..de46cd030 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -36,10 +36,11 @@ #include #include #include - -#include "../tools/dialogtool.h" +#include class VMeasurement; +struct FormulaData; +class VContainer; namespace Ui { @@ -54,7 +55,7 @@ class DialogEditWrongFormula; * * Don't implemant button "Apply" for this dialog!! */ -class DialogEditWrongFormula : public DialogTool +class DialogEditWrongFormula : public QDialog { Q_OBJECT public: @@ -70,8 +71,8 @@ public: void SetIncrementsMode(); void SetPreviewCalculationsMode(); public slots: - virtual void DialogAccepted() override; - virtual void DialogRejected() override; + virtual void DialogAccepted(); + virtual void DialogRejected(); void EvalFormula(); void ValChanged(int row); void PutHere(); @@ -87,17 +88,32 @@ public slots: void Increments(); void PreviewCalculations(); void Functions(); +signals: + /** + * @brief DialogClosed signal dialog closed + * @param result keep result + */ + void DialogClosed(int result); + /** + * @brief DialogApplied emit signal dialog apply changes + */ + void DialogApplied(); protected: virtual bool IsValid() const final; virtual void closeEvent(QCloseEvent *event) override; virtual void showEvent( QShowEvent *event ) override; virtual void resizeEvent(QResizeEvent *event) override; + virtual void CheckState(); private slots: void FilterVariablesEdited(const QString &filter); private: Q_DISABLE_COPY(DialogEditWrongFormula) Ui::DialogEditWrongFormula *ui; + const VContainer *m_data; + + quint32 m_toolId; + /** @brief formula string with formula */ QString formula; @@ -113,6 +129,9 @@ private: bool flagFormula; + /** @brief m_isInitialized true if window is initialized */ + bool m_isInitialized{false}; + void InitVariables(); template @@ -122,6 +141,8 @@ private: void ShowIncrementsInPreviewCalculation(bool show); void SetDescription(const QString &name, qreal value, bool specialUnits, const QString &description); + + qreal Eval(const FormulaData &formulaData, bool &flag); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/support/dialogundo.cpp b/src/libs/vtools/dialogs/support/dialogundo.cpp index ba6d48eec..93ccf6848 100644 --- a/src/libs/vtools/dialogs/support/dialogundo.cpp +++ b/src/libs/vtools/dialogs/support/dialogundo.cpp @@ -43,9 +43,9 @@ DialogUndo::DialogUndo(QWidget *parent) { ui->setupUi(this); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - bool opening = qApp->getOpeningPattern(); + bool opening = VAbstractValApplication::VApp()->getOpeningPattern(); if (opening) { ui->pushButtonUndo->setDisabled(opening); diff --git a/src/libs/vtools/dialogs/tools/dialogalongline.cpp b/src/libs/vtools/dialogs/tools/dialogalongline.cpp index 0c178813f..487d8e7d9 100644 --- a/src/libs/vtools/dialogs/tools/dialogalongline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogalongline.cpp @@ -81,7 +81,8 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, quint32 toolId, QWidget ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -144,7 +145,7 @@ void DialogAlongLine::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -160,7 +161,7 @@ void DialogAlongLine::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; Eval(formulaData, flagFormula); @@ -345,7 +346,8 @@ void DialogAlongLine::SetFirstPointId(quint32 value) */ void DialogAlongLine::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -417,7 +419,8 @@ QString DialogAlongLine::GetTypeLine() const */ QString DialogAlongLine::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogarc.cpp b/src/libs/vtools/dialogs/tools/dialogarc.cpp index 83ce97da4..564aa4e17 100644 --- a/src/libs/vtools/dialogs/tools/dialogarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarc.cpp @@ -174,7 +174,8 @@ void DialogArc::SetCenter(const quint32 &value) */ void DialogArc::SetF2(const QString &value) { - f2 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + f2 = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f2.length() > 80) { @@ -262,7 +263,8 @@ QString DialogArc::GetAliasSuffix() const */ void DialogArc::SetF1(const QString &value) { - f1 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + f1 = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f1.length() > 80) { @@ -284,7 +286,8 @@ void DialogArc::SetF1(const QString &value) */ void DialogArc::SetRadius(const QString &value) { - radius = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + radius = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (radius.length() > 80) { @@ -383,7 +386,7 @@ void DialogArc::FXRadius() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit radius")); dialog->SetFormula(GetRadius()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetRadius(dialog->GetFormula()); @@ -430,7 +433,7 @@ void DialogArc::EvalRadius() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditRadius; formulaData.labelResult = ui->labelResultRadius; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const qreal radius = Eval(formulaData, flagRadius); @@ -485,7 +488,8 @@ quint32 DialogArc::GetCenter() const */ QString DialogArc::GetRadius() const { - return qApp->TrVars()->TryFormulaFromUser(radius, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(radius, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -495,7 +499,8 @@ QString DialogArc::GetRadius() const */ QString DialogArc::GetF1() const { - return qApp->TrVars()->TryFormulaFromUser(f1, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(f1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -505,5 +510,6 @@ QString DialogArc::GetF1() const */ QString DialogArc::GetF2() const { - return qApp->TrVars()->TryFormulaFromUser(f2, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(f2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } diff --git a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp index c1ec97df7..86f3b7010 100644 --- a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp @@ -147,13 +147,15 @@ void DialogArcWithLength::SetCenter(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogArcWithLength::GetRadius() const { - return qApp->TrVars()->TryFormulaFromUser(radius, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(radius, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogArcWithLength::SetRadius(const QString &value) { - radius = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + radius = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (radius.length() > 80) { @@ -171,12 +173,14 @@ void DialogArcWithLength::SetRadius(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogArcWithLength::GetF1() const { - return qApp->TrVars()->TryFormulaFromUser(f1, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(f1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } void DialogArcWithLength::SetF1(const QString &value) { - f1 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + f1 = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f1.length() > 80) { @@ -194,13 +198,15 @@ void DialogArcWithLength::SetF1(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogArcWithLength::GetLength() const { - return qApp->TrVars()->TryFormulaFromUser(length, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(length, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogArcWithLength::SetLength(const QString &value) { - length = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + length = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (length.length() > 80) { @@ -323,7 +329,7 @@ void DialogArcWithLength::FXRadius() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit radius")); dialog->SetFormula(GetRadius()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetRadius(dialog->GetFormula()); @@ -351,7 +357,7 @@ void DialogArcWithLength::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit the arc length")); dialog->SetFormula(GetLength()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetLength(dialog->GetFormula()); @@ -422,7 +428,7 @@ void DialogArcWithLength::Radius() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditRadius; formulaData.labelResult = ui->labelResultRadius; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkLessThanZero = true; Eval(formulaData, flagRadius); @@ -436,7 +442,7 @@ void DialogArcWithLength::Length() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditLength; formulaData.labelResult = ui->labelResultLength; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); Eval(formulaData, flagLength); } diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.cpp b/src/libs/vtools/dialogs/tools/dialogbisector.cpp index 64a3c8ada..ffd73e08f 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.cpp +++ b/src/libs/vtools/dialogs/tools/dialogbisector.cpp @@ -75,7 +75,8 @@ DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget * ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -142,7 +143,7 @@ void DialogBisector::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -158,7 +159,7 @@ void DialogBisector::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; Eval(formulaData, flagFormula); @@ -279,7 +280,8 @@ void DialogBisector::SetTypeLine(const QString &value) */ void DialogBisector::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -401,7 +403,8 @@ QString DialogBisector::GetTypeLine() const */ QString DialogBisector::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp index 306423f6a..4db6d3577 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp @@ -106,7 +106,7 @@ void DialogCubicBezier::SetSpline(const VCubicBezier &spline) ChangeCurrentData(ui->comboBoxPenStyle, spl.GetPenStyle()); ChangeCurrentData(ui->comboBoxColor, spl.GetColor()); - ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name())); + ui->lineEditSplineName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(spl.name())); ui->doubleSpinBoxApproximationScale->setValue(spl.GetApproximationScale()); originAliasSuffix = spl.GetAliasSuffix(); @@ -200,7 +200,7 @@ void DialogCubicBezier::PointNameChanged() getCurrentObjectId(ui->comboBoxP4) == spl.GetP4().id()) { newDuplicate = -1; - ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name())); + ui->lineEditSplineName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(spl.name())); } else { @@ -213,7 +213,7 @@ void DialogCubicBezier::PointNameChanged() newDuplicate = static_cast(DNumber(spline.name())); spline.SetDuplicate(static_cast(newDuplicate)); } - ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spline.name())); + ui->lineEditSplineName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(spline.name())); } catch (const VExceptionBadId &) { diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp index e583126a0..961a70b47 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp @@ -112,7 +112,7 @@ void DialogCubicBezierPath::SetPath(const VCubicBezierPath &value) NewItem(path.at(i)); } ui->listWidget->setFocus(Qt::OtherFocusReason); - ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name())); + ui->lineEditSplPathName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(path.name())); ui->doubleSpinBoxApproximationScale->setValue(path.GetApproximationScale()); originAliasSuffix = path.GetAliasSuffix(); @@ -157,7 +157,8 @@ void DialogCubicBezierPath::ChosenObject(quint32 id, const SceneObject &type) if (path.CountPoints() == 1) { visPath->VisualMode(NULL_ID); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(visPath, &VisToolCubicBezierPath::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } @@ -374,7 +375,7 @@ void DialogCubicBezierPath::ValidatePath() if (first.id() == path.at(0).id() && last.id() == path.at(path.CountPoints()-1).id()) { newDuplicate = -1; - ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name())); + ui->lineEditSplPathName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(path.name())); } else { @@ -386,7 +387,7 @@ void DialogCubicBezierPath::ValidatePath() newPath.SetDuplicate(static_cast(newDuplicate)); } - ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name())); + ui->lineEditSplPathName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(newPath.name())); } } diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index 2dadef0f5..c7facc36a 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -71,7 +71,8 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, quint ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); formulaBaseHeightAngle = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -136,13 +137,15 @@ void DialogCurveIntersectAxis::SetTypeLine(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogCurveIntersectAxis::GetAngle() const { - return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogCurveIntersectAxis::SetAngle(const QString &value) { - formulaAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formulaAngle.length() > 80) @@ -218,13 +221,14 @@ void DialogCurveIntersectAxis::ShowDialog(bool click) } /*We will ignore click if poinet is in point circle*/ - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(static_cast(*point), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. - if (line.length() <= ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5) + if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5) { return; } @@ -260,7 +264,8 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { number++; line->VisualMode(id); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index eea074655..ec0bbb4d9 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -72,7 +72,8 @@ DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *pare ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -109,7 +110,7 @@ void DialogCutArc::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -125,7 +126,7 @@ void DialogCutArc::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; Eval(formulaData, flagFormula); @@ -268,7 +269,8 @@ void DialogCutArc::setArcId(quint32 value) */ void DialogCutArc::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -301,7 +303,8 @@ void DialogCutArc::SetPointName(const QString &value) */ QString DialogCutArc::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index 0f41f71a9..30dd1a12e 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -72,7 +72,8 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -132,7 +133,8 @@ void DialogCutSpline::SetPointName(const QString &value) */ void DialogCutSpline::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formula.length() > 80) @@ -266,7 +268,7 @@ void DialogCutSpline::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -282,7 +284,7 @@ void DialogCutSpline::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; Eval(formulaData, flagFormula); @@ -301,7 +303,8 @@ void DialogCutSpline::ShowVisualization() */ QString DialogCutSpline::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index f49581936..44e5c6175 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -72,7 +72,8 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, quint32 toolId, ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -132,7 +133,8 @@ void DialogCutSplinePath::SetPointName(const QString &value) */ void DialogCutSplinePath::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formula.length() > 80) @@ -266,7 +268,7 @@ void DialogCutSplinePath::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -282,7 +284,7 @@ void DialogCutSplinePath::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; Eval(formulaData, flagFormula); @@ -301,7 +303,8 @@ void DialogCutSplinePath::ShowVisualization() */ QString DialogCutSplinePath::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp index 9ec1af735..db69a46d0 100644 --- a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp @@ -198,7 +198,8 @@ void DialogEllipticalArc::SetCenter(const quint32 &value) */ QString DialogEllipticalArc::GetRadius1() const { - return qApp->TrVars()->TryFormulaFromUser(radius1, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(radius1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -208,7 +209,8 @@ QString DialogEllipticalArc::GetRadius1() const */ void DialogEllipticalArc::SetRadius1(const QString &value) { - radius1 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + radius1 = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (radius1.length() > 80) { @@ -230,7 +232,8 @@ void DialogEllipticalArc::SetRadius1(const QString &value) */ QString DialogEllipticalArc::GetRadius2() const { - return qApp->TrVars()->TryFormulaFromUser(radius2, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(radius2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -240,7 +243,8 @@ QString DialogEllipticalArc::GetRadius2() const */ void DialogEllipticalArc::SetRadius2(const QString &value) { - radius2 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + radius2 = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (radius2.length() > 80) { @@ -262,7 +266,8 @@ void DialogEllipticalArc::SetRadius2(const QString &value) */ QString DialogEllipticalArc::GetF1() const { - return qApp->TrVars()->TryFormulaFromUser(f1, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(f1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -272,7 +277,8 @@ QString DialogEllipticalArc::GetF1() const */ void DialogEllipticalArc::SetF1(const QString &value) { - f1 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + f1 = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f1.length() > 80) { @@ -294,7 +300,8 @@ void DialogEllipticalArc::SetF1(const QString &value) */ QString DialogEllipticalArc::GetF2() const { - return qApp->TrVars()->TryFormulaFromUser(f2, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(f2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -304,7 +311,8 @@ QString DialogEllipticalArc::GetF2() const */ void DialogEllipticalArc::SetF2(const QString &value) { - f2 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + f2 = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f2.length() > 80) { @@ -326,7 +334,8 @@ void DialogEllipticalArc::SetF2(const QString &value) */ QString DialogEllipticalArc::GetRotationAngle() const { - return qApp->TrVars()->TryFormulaFromUser(rotationAngle, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(rotationAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -336,7 +345,8 @@ QString DialogEllipticalArc::GetRotationAngle() const */ void DialogEllipticalArc::SetRotationAngle(const QString &value) { - rotationAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + rotationAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (rotationAngle.length() > 80) { @@ -394,7 +404,7 @@ void DialogEllipticalArc::EvalRadiuses() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditRadius1; formulaData.labelResult = ui->labelResultRadius1; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkLessThanZero = true; Eval(formulaData, flagRadius1); @@ -441,7 +451,7 @@ void DialogEllipticalArc::FXRadius1() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit radius1")); dialog->SetFormula(GetRadius1()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetRadius1(dialog->GetFormula()); @@ -455,7 +465,7 @@ void DialogEllipticalArc::FXRadius2() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit radius2")); dialog->SetFormula(GetRadius2()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetRadius2(dialog->GetFormula()); diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index f500fcbb6..9e0c0aead 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -83,7 +83,8 @@ DialogEndLine::DialogEndLine(const VContainer *data, quint32 toolId, QWidget *pa ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeightAngle = ui->plainTextEditAngle->height(); @@ -153,7 +154,7 @@ void DialogEndLine::EvalLength() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkLessThanZero = false; Eval(formulaData, flagFormula); @@ -191,7 +192,7 @@ void DialogEndLine::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -214,7 +215,8 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxBasePoint, QString())) { vis->VisualMode(id); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); prepare = true; @@ -252,7 +254,8 @@ void DialogEndLine::SetTypeLine(const QString &value) */ void DialogEndLine::SetFormula(const QString &value) { - formulaLength = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaLength = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formulaLength.length() > 80) @@ -275,7 +278,8 @@ void DialogEndLine::SetFormula(const QString &value) */ void DialogEndLine::SetAngle(const QString &value) { - formulaAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formulaAngle.length() > 80) @@ -337,13 +341,14 @@ void DialogEndLine::ShowDialog(bool click) } /*We will ignore click if pointer is in point circle*/ - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(static_cast(*point), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. - if (line.length() <= ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5) + if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5) { return; } @@ -421,7 +426,8 @@ QString DialogEndLine::GetTypeLine() const */ QString DialogEndLine::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -431,7 +437,8 @@ QString DialogEndLine::GetFormula() const */ QString DialogEndLine::GetAngle() const { - return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp index 673ce7bd0..ec964f84a 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp @@ -73,7 +73,7 @@ DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolI { ui->setupUi(this); - ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix()); + ui->lineEditSuffix->setText(VAbstractValApplication::VApp()->getCurrentDocument()->GenerateSuffix()); InitOkCancelApply(ui); @@ -212,7 +212,8 @@ void DialogFlippingByAxis::ShowDialog(bool click) stage1 = false; - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->clearSelection(); @@ -231,7 +232,7 @@ void DialogFlippingByAxis::ShowDialog(bool click) scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); - qApp->getSceneView()->AllowRubberBand(false); + VAbstractValApplication::VApp()->getSceneView()->AllowRubberBand(false); FillSourceList(); diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp index 582794b4e..ded7d90ca 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp @@ -73,7 +73,7 @@ DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolI { ui->setupUi(this); - ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix()); + ui->lineEditSuffix->setText(VAbstractValApplication::VApp()->getCurrentDocument()->GenerateSuffix()); InitOkCancelApply(ui); @@ -206,7 +206,8 @@ void DialogFlippingByLine::ShowDialog(bool click) stage1 = false; - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->clearSelection(); @@ -225,7 +226,7 @@ void DialogFlippingByLine::ShowDialog(bool click) scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); - qApp->getSceneView()->AllowRubberBand(false); + VAbstractValApplication::VApp()->getSceneView()->AllowRubberBand(false); FillSourceList(); diff --git a/src/libs/vtools/dialogs/tools/dialogheight.cpp b/src/libs/vtools/dialogs/tools/dialogheight.cpp index de5fca452..6bff683ee 100644 --- a/src/libs/vtools/dialogs/tools/dialogheight.cpp +++ b/src/libs/vtools/dialogs/tools/dialogheight.cpp @@ -68,7 +68,8 @@ DialogHeight::DialogHeight(const VContainer *data, quint32 toolId, QWidget *pare ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); InitOkCancelApply(ui); FillComboBoxPoints(ui->comboBoxBasePoint); diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp index 39cfb0750..0bacd1820 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp @@ -71,7 +71,8 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, quint32 toolId, number = 0; InitOkCancelApply(ui); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); FillComboBoxPoints(ui->comboBoxP1Line1); FillComboBoxPoints(ui->comboBoxP2Line1); diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp index d5c6593e6..891f9e1d9 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp @@ -77,7 +77,8 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, quint32 ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeightAngle = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -149,13 +150,15 @@ void DialogLineIntersectAxis::SetTypeLine(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogLineIntersectAxis::GetAngle() const { - return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogLineIntersectAxis::SetAngle(const QString &value) { - formulaAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formulaAngle.length() > 80) @@ -247,13 +250,14 @@ void DialogLineIntersectAxis::ShowDialog(bool click) } /*We will ignore click if poinet is in point circle*/ - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(static_cast(*point), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. - if (line.length() <= ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5) + if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5) { return; } @@ -286,7 +290,8 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { number++; line->VisualMode(id); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(line, &VisToolLineIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index fe2f207d3..03319be48 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -100,7 +100,7 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent) this->formulaBaseHeightLength = ui->plainTextEditLength->height(); ui->plainTextEditLength->installEventFilter(this); - ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix()); + ui->lineEditSuffix->setText(VAbstractValApplication::VApp()->getCurrentDocument()->GenerateSuffix()); timerAngle->setSingleShot(true); connect(timerAngle, &QTimer::timeout, this, &DialogMove::EvalAngle); @@ -168,13 +168,15 @@ DialogMove::~DialogMove() //--------------------------------------------------------------------------------------------------------------------- QString DialogMove::GetAngle() const { - return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogMove::SetAngle(const QString &value) { - formulaAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formulaAngle.length() > 80) { @@ -192,13 +194,15 @@ void DialogMove::SetAngle(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogMove::GetLength() const { - return qApp->TrVars()->TryFormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogMove::SetLength(const QString &value) { - formulaLength = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaLength = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formulaLength.length() > 80) { @@ -216,13 +220,15 @@ void DialogMove::SetLength(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogMove::GetRotationAngle() const { - return qApp->TrVars()->TryFormulaFromUser(formulaRotationAngle, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaRotationAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogMove::SetRotationAngle(const QString &value) { - formulaRotationAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaRotationAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formulaRotationAngle.length() > 80) { @@ -321,7 +327,8 @@ void DialogMove::ShowDialog(bool click) stage1 = false; prepare = true; - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->clearSelection(); @@ -330,7 +337,8 @@ void DialogMove::ShowDialog(bool click) operation->SetObjects(SourceToObjects(sourceObjects)); operation->VisualMode(); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(operation, &VisToolMove::ToolTip, window, &VAbstractMainWindow::ShowToolTip); @@ -344,7 +352,7 @@ void DialogMove::ShowDialog(bool click) scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); - qApp->getSceneView()->AllowRubberBand(false); + VAbstractValApplication::VApp()->getSceneView()->AllowRubberBand(false); FillSourceList(); } @@ -355,8 +363,10 @@ void DialogMove::ShowDialog(bool click) if (operation->LengthValue() > 0) { - formulaAngle = qApp->TrVars()->FormulaToUser(operation->Angle(), qApp->Settings()->GetOsSeparator()); - formulaLength = qApp->TrVars()->FormulaToUser(operation->Length(), qApp->Settings()->GetOsSeparator()); + formulaAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(operation->Angle(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + formulaLength = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(operation->Length(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); operation->SetAngle(formulaAngle); operation->SetLength(formulaLength); operation->RefreshGeometry(); @@ -381,8 +391,10 @@ void DialogMove::ShowDialog(bool click) } else { - SetAngle(qApp->TrVars()->FormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator())); - SetLength(qApp->TrVars()->FormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator())); + SetAngle(VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + SetLength(VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); SetRotationAngle(operation->RotationAngle()); setModal(true); emit ToolTip(QString()); @@ -493,7 +505,7 @@ void DialogMove::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetLength()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetLength(dialog->GetFormula()); @@ -819,7 +831,7 @@ void DialogMove::EvalLength() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditLength; formulaData.labelResult = ui->labelResultLength; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); Eval(formulaData, flagLength); diff --git a/src/libs/vtools/dialogs/tools/dialognormal.cpp b/src/libs/vtools/dialogs/tools/dialognormal.cpp index 0e58b189d..6732727ed 100644 --- a/src/libs/vtools/dialogs/tools/dialognormal.cpp +++ b/src/libs/vtools/dialogs/tools/dialognormal.cpp @@ -76,7 +76,8 @@ DialogNormal::DialogNormal(const VContainer *data, quint32 toolId, QWidget *pare ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -144,7 +145,7 @@ void DialogNormal::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -160,7 +161,7 @@ void DialogNormal::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); Eval(formulaData, flagFormula); } @@ -320,7 +321,8 @@ void DialogNormal::SetAngle(qreal value) */ void DialogNormal::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -374,7 +376,8 @@ QString DialogNormal::GetTypeLine() const */ QString DialogNormal::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp index 40688c97f..b0e5dcc18 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp @@ -49,7 +49,8 @@ DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *dat ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); InitOkCancelApply(ui); diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp index ea86e1709..17ab3bd06 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp @@ -68,7 +68,8 @@ DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContaine ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeightCircleRadius = ui->plainTextEditRadius->height(); @@ -146,14 +147,16 @@ void DialogPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogPointFromCircleAndTangent::GetCircleRadius() const { - return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditRadius->toPlainText(), - qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditRadius->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPointFromCircleAndTangent::SetCircleRadius(const QString &value) { - const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -275,7 +278,7 @@ void DialogPointFromCircleAndTangent::FXCircleRadius() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit radius")); dialog->SetFormula(GetCircleRadius()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetCircleRadius(dialog->GetFormula()); @@ -291,7 +294,7 @@ void DialogPointFromCircleAndTangent::EvalCircleRadius() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditRadius; formulaData.labelResult = ui->labelResultCircleRadius; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const qreal radius = Eval(formulaData, flagCircleRadius); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp index 697708617..b9404cb86 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp @@ -75,7 +75,8 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, quint32 toolI ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -152,7 +153,7 @@ void DialogPointOfContact::FXRadius() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit radius")); dialog->SetFormula(getRadius()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { setRadius(dialog->GetFormula()); @@ -168,7 +169,7 @@ void DialogPointOfContact::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); Eval(formulaData, flagFormula); } @@ -319,7 +320,8 @@ void DialogPointOfContact::setCenter(quint32 value) */ void DialogPointOfContact::setRadius(const QString &value) { - radius = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + radius = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (radius.length() > 80) { @@ -352,7 +354,8 @@ void DialogPointOfContact::SetPointName(const QString &value) */ QString DialogPointOfContact::getRadius() const { - return qApp->TrVars()->TryFormulaFromUser(radius, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(radius, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp index 4a44fcef3..80de3dee9 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp @@ -59,7 +59,8 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, qui ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); InitOkCancelApply(ui); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp index ff52a4d5f..888e2e8ad 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp @@ -52,7 +52,8 @@ DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *d ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); InitOkCancelApply(ui); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp index 494962b78..961d847da 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp @@ -72,7 +72,8 @@ DialogPointOfIntersectionCircles::DialogPointOfIntersectionCircles(const VContai ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); this->formulaBaseHeightCircle1Radius = ui->plainTextEditCircle1Radius->height(); this->formulaBaseHeightCircle2Radius = ui->plainTextEditCircle2Radius->height(); @@ -182,14 +183,16 @@ void DialogPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &va //--------------------------------------------------------------------------------------------------------------------- QString DialogPointOfIntersectionCircles::GetFirstCircleRadius() const { - return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditCircle1Radius->toPlainText(), - qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditCircle1Radius->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionCircles::SetFirstCircleRadius(const QString &value) { - const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractValApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -207,14 +210,16 @@ void DialogPointOfIntersectionCircles::SetFirstCircleRadius(const QString &value //--------------------------------------------------------------------------------------------------------------------- QString DialogPointOfIntersectionCircles::GetSecondCircleRadius() const { - return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditCircle2Radius->toPlainText(), - qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditCircle2Radius->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionCircles::SetSecondCircleRadius(const QString &value) { - const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -326,7 +331,7 @@ void DialogPointOfIntersectionCircles::FXCircle1Radius() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit first circle radius")); dialog->SetFormula(GetFirstCircleRadius()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFirstCircleRadius(dialog->GetFormula()); @@ -340,7 +345,7 @@ void DialogPointOfIntersectionCircles::FXCircle2Radius() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit second circle radius")); dialog->SetFormula(GetSecondCircleRadius()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetSecondCircleRadius(dialog->GetFormula()); @@ -356,7 +361,7 @@ void DialogPointOfIntersectionCircles::EvalCircle1Radius() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditCircle1Radius; formulaData.labelResult = ui->labelResultCircle1Radius; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const qreal radius = Eval(formulaData, flagCircle1Radius); @@ -379,7 +384,7 @@ void DialogPointOfIntersectionCircles::EvalCircle2Radius() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditCircle2Radius; formulaData.labelResult = ui->labelResultCircle2Radius; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const qreal radius = Eval(formulaData, flagCircle2Radius); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp index c82a21d75..653aa4bd0 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp @@ -54,7 +54,7 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText(VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); InitOkCancelApply(ui); diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 283765a87..647b466e5 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -86,7 +86,7 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget * this->formulaBaseHeightAngle = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); - ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix()); + ui->lineEditSuffix->setText(VAbstractValApplication::VApp()->getCurrentDocument()->GenerateSuffix()); timerAngle->setSingleShot(true); connect(timerAngle, &QTimer::timeout, this, &DialogRotation::EvalAngle); @@ -145,13 +145,15 @@ void DialogRotation::SetOrigPointId(quint32 value) //--------------------------------------------------------------------------------------------------------------------- QString DialogRotation::GetAngle() const { - return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogRotation::SetAngle(const QString &value) { - formulaAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formulaAngle = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formulaAngle.length() > 80) { @@ -234,7 +236,8 @@ void DialogRotation::ShowDialog(bool click) stage1 = false; - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->clearSelection(); @@ -253,7 +256,7 @@ void DialogRotation::ShowDialog(bool click) scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); - qApp->getSceneView()->AllowRubberBand(false); + VAbstractValApplication::VApp()->getSceneView()->AllowRubberBand(false); FillSourceList(); @@ -270,7 +273,8 @@ void DialogRotation::ShowDialog(bool click) } /*We will ignore click if pointer is in point circle*/ - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) try { @@ -278,7 +282,7 @@ void DialogRotation::ShowDialog(bool click) const QLineF line = QLineF(static_cast(*point), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. - if (line.length() <= ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5) + if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5) { return; } @@ -347,7 +351,8 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxOriginPoint, QString())) { - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(operation, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); diff --git a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp index b57ed59e0..66a4558a3 100644 --- a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp @@ -75,7 +75,8 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, quint32 toolId, ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); @@ -142,7 +143,7 @@ void DialogShoulderPoint::FXLength() DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormula(dialog->GetFormula()); @@ -158,7 +159,7 @@ void DialogShoulderPoint::EvalFormula() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormula; formulaData.labelResult = ui->labelResultCalculation; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); Eval(formulaData, flagFormula); } @@ -334,7 +335,8 @@ void DialogShoulderPoint::SetP1Line(const quint32 &value) */ void DialogShoulderPoint::SetFormula(const QString &value) { - formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -387,7 +389,8 @@ QString DialogShoulderPoint::GetTypeLine() const */ QString DialogShoulderPoint::GetFormula() const { - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogsinglepoint.cpp b/src/libs/vtools/dialogs/tools/dialogsinglepoint.cpp index 7a6f11dd8..b9ec1ced9 100644 --- a/src/libs/vtools/dialogs/tools/dialogsinglepoint.cpp +++ b/src/libs/vtools/dialogs/tools/dialogsinglepoint.cpp @@ -53,8 +53,8 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, quint32 toolId, QWi ui->lineEditName->setClearButtonEnabled(true); - ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize)); - ui->doubleSpinBoxY->setRange(0, qApp->fromPixel(SceneSize)); + ui->doubleSpinBoxX->setRange(0, VAbstractValApplication::VApp()->fromPixel(SceneSize)); + ui->doubleSpinBoxY->setRange(0, VAbstractValApplication::VApp()->fromPixel(SceneSize)); InitOkCancel(ui); connect(ui->lineEditName, &QLineEdit::textChanged, this, [this]() @@ -76,21 +76,22 @@ void DialogSinglePoint::mousePress(const QPointF &scenePos) { if (isInitialized == false) { - ui->doubleSpinBoxX->setValue(qApp->fromPixel(scenePos.x())); - ui->doubleSpinBoxY->setValue(qApp->fromPixel(scenePos.y())); + ui->doubleSpinBoxX->setValue(VAbstractValApplication::VApp()->fromPixel(scenePos.x())); + ui->doubleSpinBoxY->setValue(VAbstractValApplication::VApp()->fromPixel(scenePos.y())); this->show(); } else { - ui->doubleSpinBoxX->setValue(qApp->fromPixel(scenePos.x())); - ui->doubleSpinBoxY->setValue(qApp->fromPixel(scenePos.y())); + ui->doubleSpinBoxX->setValue(VAbstractValApplication::VApp()->fromPixel(scenePos.x())); + ui->doubleSpinBoxY->setValue(VAbstractValApplication::VApp()->fromPixel(scenePos.y())); } } //--------------------------------------------------------------------------------------------------------------------- void DialogSinglePoint::SaveData() { - point = QPointF(qApp->toPixel(ui->doubleSpinBoxX->value()), qApp->toPixel(ui->doubleSpinBoxY->value())); + point = QPointF(VAbstractValApplication::VApp()->toPixel(ui->doubleSpinBoxX->value()), + VAbstractValApplication::VApp()->toPixel(ui->doubleSpinBoxY->value())); pointName = ui->lineEditName->text(); } @@ -106,8 +107,8 @@ void DialogSinglePoint::SetData(const QString &name, const QPointF &point) this->point = point; isInitialized = true; ui->lineEditName->setText(name); - ui->doubleSpinBoxX->setValue(qApp->fromPixel(point.x())); - ui->doubleSpinBoxY->setValue(qApp->fromPixel(point.y())); + ui->doubleSpinBoxX->setValue(VAbstractValApplication::VApp()->fromPixel(point.x())); + ui->doubleSpinBoxY->setValue(VAbstractValApplication::VApp()->fromPixel(point.y())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp index a781a2bf6..5eb7274a5 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp @@ -155,7 +155,7 @@ DialogSpline::DialogSpline(const VContainer *data, quint32 toolId, QWidget *pare auto path = qobject_cast(vis); SCASSERT(path != nullptr) - auto scene = qobject_cast(qApp->getCurrentScene()); + auto scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::MouseLeftPressed, path, &VisToolSpline::MouseLeftPressed); connect(scene, &VMainGraphicsScene::MouseLeftReleased, path, &VisToolSpline::MouseLeftReleased); @@ -278,13 +278,15 @@ void DialogSpline::FXAngle1() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit first control point angle")); - QString angle1F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditAngle1F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + QString angle1F = VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditAngle1F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(angle1F); dialog->setPostfix(degreeSymbol); if (dialog->exec() == QDialog::Accepted) { - angle1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + angle1F = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(dialog->GetFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (angle1F.length() > 80) { @@ -301,13 +303,15 @@ void DialogSpline::FXAngle2() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit second control point angle")); - QString angle2F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditAngle2F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + QString angle2F = VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditAngle2F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(angle2F); dialog->setPostfix(degreeSymbol); if (dialog->exec() == QDialog::Accepted) { - angle2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + angle2F = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(dialog->GetFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (angle2F.length() > 80) { @@ -324,13 +328,15 @@ void DialogSpline::FXLength1() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit first control point length")); - QString length1F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + QString length1F = VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(length1F); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { - length1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + length1F = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(dialog->GetFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (length1F.length() > 80) { @@ -347,13 +353,15 @@ void DialogSpline::FXLength2() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit second control point length")); - QString length2F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + QString length2F = VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(length2F); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { - length2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + length2F = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(dialog->GetFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (length2F.length() > 80) { @@ -413,7 +421,7 @@ void DialogSpline::EvalLength1() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditLength1; formulaData.labelResult = ui->labelResultLength1; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -428,7 +436,7 @@ void DialogSpline::EvalLength2() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditLength2; formulaData.labelResult = ui->labelResultLength2; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -474,12 +482,12 @@ VSpline DialogSpline::CurrentSpline() const const qreal length1 = Visualization::FindLengthFromUser(length1F, vars); const qreal length2 = Visualization::FindLengthFromUser(length2F, vars); - const bool separator = qApp->Settings()->GetOsSeparator(); + const bool separator = VAbstractApplication::VApp()->Settings()->GetOsSeparator(); - angle1F = qApp->TrVars()->TryFormulaFromUser(angle1F, separator); - angle2F = qApp->TrVars()->TryFormulaFromUser(angle2F, separator); - length1F = qApp->TrVars()->TryFormulaFromUser(length1F, separator); - length2F = qApp->TrVars()->TryFormulaFromUser(length2F, separator); + angle1F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(angle1F, separator); + angle2F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(angle2F, separator); + length1F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(length1F, separator); + length2F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(length2F, separator); VSpline spline(*GetP1(), *GetP4(), angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F); spline.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value()); @@ -514,7 +522,7 @@ void DialogSpline::PointNameChanged() getCurrentObjectId(ui->comboBoxP4) == spl.GetP4().id()) { newDuplicate = -1; - ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name())); + ui->lineEditSplineName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(spl.name())); } else { @@ -527,7 +535,7 @@ void DialogSpline::PointNameChanged() newDuplicate = static_cast(DNumber(spline.name())); spline.SetDuplicate(static_cast(newDuplicate)); } - ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spline.name())); + ui->lineEditSplineName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(spline.name())); } catch (const VExceptionBadId &) { @@ -552,24 +560,28 @@ void DialogSpline::ShowDialog(bool click) spl = VSpline(*GetP1(), path->GetP2(), path->GetP3(), *GetP4()); - const QString angle1F = qApp->TrVars()->FormulaToUser(spl.GetStartAngleFormula(), - qApp->Settings()->GetOsSeparator()); - const QString angle2F = qApp->TrVars()->FormulaToUser(spl.GetEndAngleFormula(), - qApp->Settings()->GetOsSeparator()); + const QString angle1F = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(spl.GetStartAngleFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString angle2F = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(spl.GetEndAngleFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditAngle1F->setPlainText(angle1F); ui->plainTextEditAngle2F->setPlainText(angle2F); - ui->plainTextEditLength1F->setPlainText(qApp->TrVars()->FormulaToUser(spl.GetC1LengthFormula(), - qApp->Settings()->GetOsSeparator())); - ui->plainTextEditLength2F->setPlainText(qApp->TrVars()->FormulaToUser(spl.GetC2LengthFormula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditLength1F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(spl.GetC1LengthFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + ui->plainTextEditLength2F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(spl.GetC2LengthFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); if (not data->IsUnique(spl.name())) { spl.SetDuplicate(DNumber(spl.name())); } - ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name())); + ui->lineEditSplineName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(spl.name())); DialogAccepted(); } @@ -599,22 +611,22 @@ void DialogSpline::SetSpline(const VSpline &spline) setCurrentPointId(ui->comboBoxP1, spl.GetP1().id()); setCurrentPointId(ui->comboBoxP4, spl.GetP4().id()); - const QString angle1F = qApp->TrVars()->FormulaToUser(spl.GetStartAngleFormula(), - qApp->Settings()->GetOsSeparator()); - const QString angle2F = qApp->TrVars()->FormulaToUser(spl.GetEndAngleFormula(), - qApp->Settings()->GetOsSeparator()); + const QString angle1F = VAbstractApplication::VApp()->TrVars()->FormulaToUser(spl.GetStartAngleFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString angle2F = VAbstractApplication::VApp()->TrVars()->FormulaToUser(spl.GetEndAngleFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditAngle1F->setPlainText(angle1F); ui->plainTextEditAngle2F->setPlainText(angle2F); - const QString length1F = qApp->TrVars()->FormulaToUser(spl.GetC1LengthFormula(), - qApp->Settings()->GetOsSeparator()); - const QString length2F = qApp->TrVars()->FormulaToUser(spl.GetC2LengthFormula(), - qApp->Settings()->GetOsSeparator()); + const QString length1F = VAbstractApplication::VApp()->TrVars()->FormulaToUser(spl.GetC1LengthFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString length2F = VAbstractApplication::VApp()->TrVars()->FormulaToUser(spl.GetC2LengthFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditLength1F->setPlainText(length1F); ui->plainTextEditLength2F->setPlainText(length2F); - ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name())); + ui->lineEditSplineName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(spl.name())); originAliasSuffix = spl.GetAliasSuffix(); ui->lineEditAlias->setText(originAliasSuffix); diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp index 38340b41a..e44d4a921 100644 --- a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp @@ -132,7 +132,7 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, quint32 toolId, QWidg auto path = qobject_cast(vis); SCASSERT(path != nullptr) - auto scene = qobject_cast(qApp->getCurrentScene()); + auto scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::MouseLeftPressed, path, &VisToolSplinePath::MouseLeftPressed); connect(scene, &VMainGraphicsScene::MouseLeftReleased, path, &VisToolSplinePath::MouseLeftReleased); @@ -167,7 +167,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value) NewItem(path.at(i)); } ui->listWidget->setFocus(Qt::OtherFocusReason); - ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name())); + ui->lineEditSplPathName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(path.name())); ui->doubleSpinBoxApproximationScale->setValue(path.GetApproximationScale()); originAliasSuffix = path.GetAliasSuffix(); @@ -215,7 +215,8 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type) if (path.CountPoints() == 1) { visPath->VisualMode(NULL_ID); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(visPath, &VisToolSplinePath::ToolTip, window, &VAbstractMainWindow::ShowToolTip); @@ -296,7 +297,9 @@ void DialogSplinePath::Angle1Changed() const QString angle1F = ui->plainTextEditAngle1F->toPlainText(); const qreal angle1 = Visualization::FindValFromUser(angle1F, data->DataVariables()); - p.SetAngle1(angle1, VTranslateVars::TryFormulaFromUser(angle1F, qApp->Settings()->GetOsSeparator())); + p.SetAngle1(angle1, + VTranslateVars::TryFormulaFromUser(angle1F, + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); @@ -305,8 +308,9 @@ void DialogSplinePath::Angle1Changed() if (row != ui->listWidget->count()-1) { ui->plainTextEditAngle2F->blockSignals(true); - ui->plainTextEditAngle2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle2Formula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditAngle2F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Angle2Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); EvalAngle2(); ui->plainTextEditAngle2F->blockSignals(false); } @@ -330,7 +334,9 @@ void DialogSplinePath::Angle2Changed() const QString angle2F = ui->plainTextEditAngle2F->toPlainText(); const qreal angle2 = Visualization::FindValFromUser(angle2F, data->DataVariables()); - p.SetAngle2(angle2, VTranslateVars::TryFormulaFromUser(angle2F, qApp->Settings()->GetOsSeparator())); + p.SetAngle2(angle2, + VTranslateVars::TryFormulaFromUser(angle2F, + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); @@ -339,8 +345,9 @@ void DialogSplinePath::Angle2Changed() if (row != 0) { ui->plainTextEditAngle1F->blockSignals(true); - ui->plainTextEditAngle1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle1Formula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditAngle1F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Angle1Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); EvalAngle1(); ui->plainTextEditAngle1F->blockSignals(false); } @@ -364,7 +371,9 @@ void DialogSplinePath::Length1Changed() const QString length1F = ui->plainTextEditLength1F->toPlainText(); const qreal length1 = Visualization::FindLengthFromUser(length1F, data->DataVariables()); - p.SetLength1(length1, VTranslateVars::TryFormulaFromUser(length1F, qApp->Settings()->GetOsSeparator())); + p.SetLength1(length1, + VTranslateVars::TryFormulaFromUser(length1F, + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); @@ -389,7 +398,9 @@ void DialogSplinePath::Length2Changed() const QString length2F = ui->plainTextEditLength2F->toPlainText(); const qreal length2 = Visualization::FindLengthFromUser(length2F, data->DataVariables()); - p.SetLength2(length2, VTranslateVars::TryFormulaFromUser(length2F, qApp->Settings()->GetOsSeparator())); + p.SetLength2(length2, + VTranslateVars::TryFormulaFromUser(length2F, + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); item->setData(Qt::UserRole, QVariant::fromValue(p)); @@ -404,13 +415,14 @@ void DialogSplinePath::FXAngle1() dialog->setWindowTitle(tr("Edit first control point angle")); QString angle1F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditAngle1F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(angle1F); dialog->setPostfix(degreeSymbol); if (dialog->exec() == QDialog::Accepted) { - angle1F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + angle1F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (angle1F.length() > 80) { @@ -429,13 +441,14 @@ void DialogSplinePath::FXAngle2() dialog->setWindowTitle(tr("Edit second control point angle")); QString angle2F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditAngle2F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(angle2F); dialog->setPostfix(degreeSymbol); if (dialog->exec() == QDialog::Accepted) { - angle2F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + angle2F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (angle2F.length() > 80) { @@ -454,13 +467,14 @@ void DialogSplinePath::FXLength1() dialog->setWindowTitle(tr("Edit first control point length")); QString length1F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(length1F); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { - length1F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + length1F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (length1F.length() > 80) { @@ -479,13 +493,14 @@ void DialogSplinePath::FXLength2() dialog->setWindowTitle(tr("Edit second control point length")); QString length2F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText(), - qApp->Settings()->GetOsSeparator()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(length2F); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { - length2F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); + length2F = VTranslateVars::TryFormulaToUser(dialog->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (length2F.length() > 80) { @@ -587,7 +602,7 @@ void DialogSplinePath::EvalLength1() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditLength1; formulaData.labelResult = ui->labelResultLength1; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -614,7 +629,7 @@ void DialogSplinePath::EvalLength2() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditLength2; formulaData.labelResult = ui->labelResultLength2; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -683,7 +698,7 @@ void DialogSplinePath::currentPointChanged(int index) if (first.P().id() == path.at(0).P().id() && last.P().id() == path.at(path.CountPoints()-1).P().id()) { newDuplicate = -1; - ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name())); + ui->lineEditSplPathName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(path.name())); } else { @@ -695,7 +710,7 @@ void DialogSplinePath::currentPointChanged(int index) newPath.SetDuplicate(static_cast(newDuplicate)); } - ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name())); + ui->lineEditSplPathName->setText(VAbstractApplication::VApp()->TrVars()->VarToUser(newPath.name())); } } } @@ -813,11 +828,13 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p) ui->plainTextEditAngle2F->blockSignals(true); ui->plainTextEditLength2F->blockSignals(true); - ui->plainTextEditAngle2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle2Formula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditAngle2F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Angle2Formula(),VAbstractApplication::VApp()->Settings()->GetOsSeparator())); EvalAngle2(); - ui->plainTextEditLength2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length2Formula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditLength2F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Length2Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); EvalLength2(); ui->plainTextEditAngle2F->blockSignals(false); ui->plainTextEditLength2F->blockSignals(false); @@ -850,11 +867,13 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p) ui->plainTextEditAngle1F->blockSignals(true); ui->plainTextEditLength1F->blockSignals(true); - ui->plainTextEditAngle1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle1Formula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditAngle1F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Angle1Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); EvalAngle1(); - ui->plainTextEditLength1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length1Formula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditLength1F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Length1Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); EvalLength1(); ui->plainTextEditAngle1F->blockSignals(false); ui->plainTextEditLength1F->blockSignals(false); @@ -876,14 +895,18 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p) ui->plainTextEditAngle2F->blockSignals(true); ui->plainTextEditLength2F->blockSignals(true); - ui->plainTextEditAngle1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle1Formula(), - qApp->Settings()->GetOsSeparator())); - ui->plainTextEditAngle2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle2Formula(), - qApp->Settings()->GetOsSeparator())); - ui->plainTextEditLength1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length1Formula(), - qApp->Settings()->GetOsSeparator())); - ui->plainTextEditLength2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length2Formula(), - qApp->Settings()->GetOsSeparator())); + ui->plainTextEditAngle1F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Angle1Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + ui->plainTextEditAngle2F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Angle2Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + ui->plainTextEditLength1F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Length1Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + ui->plainTextEditLength2F->setPlainText( + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(p.Length2Formula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); EvalAngle1(); EvalLength1(); diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 6912eb13c..37bff7874 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -286,7 +286,7 @@ inline void DialogTool::InitOkCancel(T *ui) SCASSERT(bCancel != nullptr) connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected); - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); } //--------------------------------------------------------------------------------------------------------------------- @@ -295,7 +295,8 @@ inline void DialogTool::AddVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) T *toolVis = qobject_cast(vis); diff --git a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp index ecbbf3dbb..ea6fbbf0b 100644 --- a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp @@ -59,7 +59,8 @@ DialogTriangle::DialogTriangle(const VContainer *data, quint32 toolId, QWidget * ui->lineEditNamePoint->setClearButtonEnabled(true); - ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + ui->lineEditNamePoint->setText( + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); InitOkCancelApply(ui); diff --git a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp index bab4f1658..4659c36dc 100644 --- a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp @@ -66,8 +66,9 @@ DialogTrueDarts::DialogTrueDarts(const VContainer *data, quint32 toolId, QWidget ui->lineEditFirstNewDartPoint->setClearButtonEnabled(true); ui->lineEditSecondNewDartPoint->setClearButtonEnabled(true); - const QString name1 = qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel); - const QString name2 = qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel, name1); + const QString name1 = VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel); + const QString name2 = + VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel, name1); ui->lineEditFirstNewDartPoint->setText(name1); ui->lineEditSecondNewDartPoint->setText(name2); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.cpp index decb39377..b336abfa9 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.cpp @@ -39,7 +39,7 @@ namespace //--------------------------------------------------------------------------------------------------------------------- QStringList PrepareKnowMaterials(const QStringList &patternMaterials, bool rememberPM) { - QStringList knownMaterials = qApp->ValentinaSettings()->GetKnownMaterials(); + QStringList knownMaterials = VAbstractValApplication::VApp()->ValentinaSettings()->GetKnownMaterials(); if (rememberPM) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index 19ec44b48..fb6124b9e 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -177,7 +177,7 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type) "%2 - finish creation") .arg(VModifierKey::Shift(), VModifierKey::EnterKey())); - if (not qApp->getCurrentScene()->items().contains(visPath)) + if (not VAbstractValApplication::VApp()->getCurrentScene()->items().contains(visPath)) { visPath->VisualMode(NULL_ID); } @@ -465,7 +465,8 @@ void DialogPiecePath::NodeChanged(int index) { this->DeployWidthBeforeFormulaTextEdit(); } - w1Formula = qApp->TrVars()->FormulaToUser(w1Formula, qApp->Settings()->GetOsSeparator()); + w1Formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(w1Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormulaWidthBefore->setPlainText(w1Formula); MoveCursorToEnd(ui->plainTextEditFormulaWidthBefore); @@ -482,7 +483,8 @@ void DialogPiecePath::NodeChanged(int index) { this->DeployWidthAfterFormulaTextEdit(); } - w2Formula = qApp->TrVars()->FormulaToUser(w2Formula, qApp->Settings()->GetOsSeparator()); + w2Formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(w2Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormulaWidthAfter->setPlainText(w2Formula); MoveCursorToEnd(ui->plainTextEditFormulaWidthAfter); @@ -537,7 +539,8 @@ void DialogPiecePath::PassmarkChanged(int index) ui->groupBoxManualLength->setChecked(true); QString passmarkLength = node.GetFormulaPassmarkLength(); - passmarkLength = qApp->TrVars()->FormulaToUser(passmarkLength, qApp->Settings()->GetOsSeparator()); + passmarkLength = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(passmarkLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); if (passmarkLength.length() > 80)// increase height if needed. { this->DeployPassmarkLength(); @@ -545,8 +548,8 @@ void DialogPiecePath::PassmarkChanged(int index) if (passmarkLength.isEmpty()) { - qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnits()); - ui->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length)); + qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits()); + ui->plainTextEditPassmarkLength->setPlainText(VAbstractApplication::VApp()->LocaleToString(length)); } else { @@ -555,8 +558,8 @@ void DialogPiecePath::PassmarkChanged(int index) } else { - qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnits()); - ui->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length)); + qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits()); + ui->plainTextEditPassmarkLength->setPlainText(VAbstractApplication::VApp()->LocaleToString(length)); } MoveCursorToEnd(ui->plainTextEditPassmarkLength); @@ -643,7 +646,8 @@ void DialogPiecePath::PassmarkChanged(int index) //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::ReturnDefBefore() { - const QString def = qApp->TrVars()->FormulaToUser(currentSeamAllowance, qApp->Settings()->GetOsSeparator()); + const QString def = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormulaWidthBefore->setPlainText(def); if (QPushButton* button = qobject_cast(sender())) { @@ -654,7 +658,8 @@ void DialogPiecePath::ReturnDefBefore() //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::ReturnDefAfter() { - const QString def = qApp->TrVars()->FormulaToUser(currentSeamAllowance, qApp->Settings()->GetOsSeparator()); + const QString def = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormulaWidthAfter->setPlainText(def); if (QPushButton* button = qobject_cast(sender())) { @@ -796,7 +801,7 @@ void DialogPiecePath::EvalWidth() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditWidth; formulaData.labelResult = ui->labelResultWidth; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -827,7 +832,7 @@ void DialogPiecePath::EvalWidthBefore() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditBefore; formulaData.labelResult = ui->labelResultBefore; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -862,7 +867,7 @@ void DialogPiecePath::EvalWidthAfter() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditAfter; formulaData.labelResult = ui->labelResultAfter; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -910,14 +915,15 @@ void DialogPiecePath::EvalPassmarkLength() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditPassmarkLength; formulaData.labelResult = ui->labelResultPassmarkLength; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = false; Eval(formulaData, m_flagFormulaPassmarkLength); - UpdateNodePassmarkLength(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditPassmarkLength->toPlainText(), - qApp->Settings()->GetOsSeparator())); + UpdateNodePassmarkLength(VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditPassmarkLength->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); } //--------------------------------------------------------------------------------------------------------------------- @@ -927,7 +933,7 @@ void DialogPiecePath::FXWidth() dialog->setWindowTitle(tr("Edit seam allowance width")); dialog->SetFormula(GetFormulaSAWidth()); dialog->setCheckLessThanZero(true); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormulaSAWidth(dialog->GetFormula()); @@ -941,7 +947,7 @@ void DialogPiecePath::FXWidthBefore() dialog->setWindowTitle(tr("Edit seam allowance width before")); dialog->SetFormula(GetFormulaSAWidthBefore()); dialog->setCheckLessThanZero(true); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetCurrentSABefore(dialog->GetFormula()); @@ -955,7 +961,7 @@ void DialogPiecePath::FXWidthAfter() dialog->setWindowTitle(tr("Edit seam allowance width after")); dialog->SetFormula(GetFormulaSAWidthAfter()); dialog->setCheckLessThanZero(true); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetCurrentSAAfter(dialog->GetFormula()); @@ -980,7 +986,7 @@ void DialogPiecePath::FXPassmarkLength() QScopedPointer dialog(new DialogEditWrongFormula(data, toolId, this)); dialog->setWindowTitle(tr("Edit passmark length")); dialog->SetFormula(GetFormulaPassmarkLength()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormulaPassmarkLength(dialog->GetFormula()); @@ -1099,8 +1105,8 @@ void DialogPiecePath::InitSeamAllowanceTab() connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogPiecePath::EvalWidthAfter); // Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough. - m_saWidth = UnitConvertor(1, Unit::Cm, qApp->patternUnits()); - ui->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth)); + m_saWidth = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits()); + ui->plainTextEditFormulaWidth->setPlainText(VAbstractApplication::VApp()->LocaleToString(m_saWidth)); InitNodesList(); connect(ui->comboBoxNodes, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -1499,7 +1505,8 @@ void DialogPiecePath::SetFormulaSAWidth(const QString &formula) return; } - const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString width = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (width.length() > 80) { @@ -1556,7 +1563,8 @@ void DialogPiecePath::SetPieceId(quint32 id) QString DialogPiecePath::GetFormulaSAWidth() const { QString width = ui->plainTextEditFormulaWidth->toPlainText(); - return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -1666,27 +1674,31 @@ void DialogPiecePath::NewItem(const VPieceNode &node) QString DialogPiecePath::GetFormulaSAWidthBefore() const { QString width = ui->plainTextEditFormulaWidthBefore->toPlainText(); - return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- QString DialogPiecePath::GetFormulaSAWidthAfter() const { QString width = ui->plainTextEditFormulaWidthAfter->toPlainText(); - return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- QString DialogPiecePath::GetFormulaVisible() const { QString formula = ui->plainTextEditFormulaVisible->toPlainText(); - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::SetFormulaVisible(const QString &formula) { - const QString f = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString f = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f.length() > 80) { @@ -1700,13 +1712,15 @@ void DialogPiecePath::SetFormulaVisible(const QString &formula) QString DialogPiecePath::GetFormulaPassmarkLength() const { QString formula = ui->plainTextEditPassmarkLength->toPlainText(); - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::SetFormulaPassmarkLength(const QString &formula) { - const QString f = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString f = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f.length() > 80) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp index b5e4e59b4..df716a621 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp @@ -126,14 +126,16 @@ void DialogPlaceLabel::SetLabelType(PlaceLabelType type) //--------------------------------------------------------------------------------------------------------------------- QString DialogPlaceLabel::GetWidth() const { - return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormulaWidth->toPlainText(), - qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditFormulaWidth->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPlaceLabel::SetWidth(const QString &value) { - const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formula.length() > 80) @@ -152,14 +154,16 @@ void DialogPlaceLabel::SetWidth(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogPlaceLabel::GetHeight() const { - return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormulaHeight->toPlainText(), - qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditFormulaHeight->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPlaceLabel::SetHeight(const QString &value) { - const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formula.length() > 80) @@ -178,14 +182,16 @@ void DialogPlaceLabel::SetHeight(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogPlaceLabel::GetAngle() const { - return qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormulaAngle->toPlainText(), - qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(ui->plainTextEditFormulaAngle->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPlaceLabel::SetAngle(const QString &value) { - const QString formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. TODO : see if I can get the max number of caracters in one line // of this PlainTextEdit to change 80 to this value if (formula.length() > 80) @@ -315,7 +321,7 @@ void DialogPlaceLabel::EvalWidth() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormulaWidth; formulaData.labelResult = ui->labelResultCalculationWidth; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkLessThanZero = true; Eval(formulaData, m_flagWidth); @@ -329,7 +335,7 @@ void DialogPlaceLabel::EvalHeight() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = ui->labelEditFormulaHeight; formulaData.labelResult = ui->labelResultCalculationHeight; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkLessThanZero = true; Eval(formulaData, m_flagHeight); @@ -370,7 +376,7 @@ void DialogPlaceLabel::FXWidth() QScopedPointer dialog(new DialogEditWrongFormula(data, toolId, this)); dialog->setWindowTitle(tr("Edit rectangle width")); dialog->SetFormula(GetWidth()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetWidth(dialog->GetFormula()); @@ -383,7 +389,7 @@ void DialogPlaceLabel::FXHeight() QScopedPointer dialog(new DialogEditWrongFormula(data, toolId, this)); dialog->setWindowTitle(tr("Edit rectangle width")); dialog->SetFormula(GetHeight()); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetHeight(dialog->GetFormula()); @@ -429,8 +435,10 @@ void DialogPlaceLabel::InitPlaceLabelTab() ui->plainTextEditFormulaHeight->installEventFilter(this); ui->plainTextEditFormulaAngle->installEventFilter(this); - ui->plainTextEditFormulaWidth->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnits()))); - ui->plainTextEditFormulaHeight->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnits()))); + ui->plainTextEditFormulaWidth->setPlainText( + QString::number(UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits()))); + ui->plainTextEditFormulaHeight->setPlainText( + QString::number(UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits()))); connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogPlaceLabel::FXWidth); connect(ui->toolButtonExprHeight, &QPushButton::clicked, this, &DialogPlaceLabel::FXHeight); @@ -542,13 +550,15 @@ void DialogPlaceLabel::CheckPoint() QString DialogPlaceLabel::GetFormulaVisible() const { QString formula = ui->plainTextEditFormulaVisible->toPlainText(); - return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- void DialogPlaceLabel::SetFormulaVisible(const QString &formula) { - const QString f = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString f = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (f.length() > 80) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 9a950c955..104fc3ed8 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -78,7 +78,8 @@ void EnableDefButton(QPushButton *defButton, const QString &formula) QString GetFormulaFromUser(QPlainTextEdit *textEdit) { SCASSERT(textEdit != nullptr) - return qApp->TrVars()->TryFormulaFromUser(textEdit->toPlainText(), qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(textEdit->toPlainText(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -346,7 +347,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->spinBoxPriority->setValue(static_cast(piece.GetPriority())); uiTabPaths->plainTextEditFormulaWidth->setPlainText( - qApp->TrVars()->FormulaToUser(piece.GetFormulaSAWidth(), qApp->Settings()->GetOsSeparator())); + VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(piece.GetFormulaSAWidth(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); m_saWidth = piece.GetSAWidth(); const VPieceLabelData &ppData = piece.GetPatternPieceData(); @@ -462,7 +464,7 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type) "%2 - finish creation") .arg(VModifierKey::Shift(), VModifierKey::EnterKey())); - if (not qApp->getCurrentScene()->items().contains(visPath)) + if (not VAbstractValApplication::VApp()->getCurrentScene()->items().contains(visPath)) { visPath->VisualMode(NULL_ID); } @@ -618,7 +620,7 @@ void DialogSeamAllowance::showEvent(QShowEvent *event) uiTabLabels->lineEditPatternNumber->setText(m_doc->GetPatternNumber()); uiTabLabels->lineEditCompanyName->setText(m_doc->GetCompanyName()); - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); m_patternMaterials = m_doc->GetPatternMaterials(); InitComboBoxFormats(uiTabLabels->comboBoxDateFormat, @@ -629,7 +631,7 @@ void DialogSeamAllowance::showEvent(QShowEvent *event) m_doc->GetLabelTimeFormat()); } - const QSize sz = qApp->Settings()->GetToolSeamAllowanceDialogSize(); + const QSize sz = VAbstractApplication::VApp()->Settings()->GetToolSeamAllowanceDialogSize(); if (not sz.isEmpty()) { resize(sz); @@ -646,7 +648,7 @@ void DialogSeamAllowance::resizeEvent(QResizeEvent *event) // dialog creating, which would if (isInitialized) { - qApp->Settings()->SetToolSeamAllowanceDialogSize(size()); + VAbstractApplication::VApp()->Settings()->SetToolSeamAllowanceDialogSize(size()); } DialogTool::resizeEvent(event); } @@ -898,7 +900,8 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) m_newPlaceLabels.insert(labelId, newLabel); QPointer saveCommand = - new SavePlaceLabelOptions(toolId, currentLabel, newLabel, qApp->getCurrentDocument(), + new SavePlaceLabelOptions(toolId, currentLabel, newLabel, + VAbstractValApplication::VApp()->getCurrentDocument(), const_cast(data), labelId); m_undoStack.append(saveCommand); UpdateCurrentPlaceLabelRecords(); @@ -1028,7 +1031,8 @@ void DialogSeamAllowance::NodeChanged(int index) QString w1Formula = node.GetFormulaSABefore(); EnableDefButton(uiTabPaths->pushButtonDefBefore, w1Formula); - w1Formula = qApp->TrVars()->FormulaToUser(w1Formula, qApp->Settings()->GetOsSeparator()); + w1Formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(w1Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); if (w1Formula.length() > 80)// increase height if needed. { this->DeployWidthBeforeFormulaTextEdit(); @@ -1042,7 +1046,8 @@ void DialogSeamAllowance::NodeChanged(int index) QString w2Formula = node.GetFormulaSAAfter(); EnableDefButton(uiTabPaths->pushButtonDefAfter, w2Formula); - w2Formula = qApp->TrVars()->FormulaToUser(w2Formula, qApp->Settings()->GetOsSeparator()); + w2Formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(w2Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); if (w2Formula.length() > 80)// increase height if needed. { this->DeployWidthAfterFormulaTextEdit(); @@ -1100,7 +1105,8 @@ void DialogSeamAllowance::PassmarkChanged(int index) uiTabPassmarks->groupBoxManualLength->setChecked(true); QString passmarkLength = node.GetFormulaPassmarkLength(); - passmarkLength = qApp->TrVars()->FormulaToUser(passmarkLength, qApp->Settings()->GetOsSeparator()); + passmarkLength = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(passmarkLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); if (passmarkLength.length() > 80)// increase height if needed. { this->DeployPassmarkLength(); @@ -1108,8 +1114,9 @@ void DialogSeamAllowance::PassmarkChanged(int index) if (passmarkLength.isEmpty()) { - qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnits()); - uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length)); + qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits()); + uiTabPassmarks->plainTextEditPassmarkLength->setPlainText( + VAbstractApplication::VApp()->LocaleToString(length)); } else { @@ -1118,8 +1125,9 @@ void DialogSeamAllowance::PassmarkChanged(int index) } else { - qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnits()); - uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length)); + qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits()); + uiTabPassmarks->plainTextEditPassmarkLength->setPlainText( + VAbstractApplication::VApp()->LocaleToString(length)); } MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkLength); @@ -1277,7 +1285,8 @@ void DialogSeamAllowance::NodeAngleChanged(int index) //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ReturnDefBefore() { - const QString def = qApp->TrVars()->FormulaToUser(currentSeamAllowance, qApp->Settings()->GetOsSeparator()); + const QString def = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); uiTabPaths->plainTextEditFormulaWidthBefore->setPlainText(def); if (QPushButton* button = qobject_cast(sender())) { @@ -1288,7 +1297,8 @@ void DialogSeamAllowance::ReturnDefBefore() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ReturnDefAfter() { - const QString def = qApp->TrVars()->FormulaToUser(currentSeamAllowance, qApp->Settings()->GetOsSeparator()); + const QString def = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); uiTabPaths->plainTextEditFormulaWidthAfter->setPlainText(def); if (QPushButton* button = qobject_cast(sender())) { @@ -1368,7 +1378,8 @@ void DialogSeamAllowance::PathDialogClosed(int result) m_newPaths.insert(dialogTool->GetToolId(), newPath); QPointer saveCommand = - new SavePiecePathOptions(toolId, currentPath, newPath, qApp->getCurrentDocument(), + new SavePiecePathOptions(toolId, currentPath, newPath, + VAbstractValApplication::VApp()->getCurrentDocument(), const_cast(data), dialogTool->GetToolId()); m_undoStack.append(saveCommand); UpdateCurrentCustomSARecord(); @@ -1420,7 +1431,8 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result) m_newPlaceLabels.insert(dialogTool->GetToolId(), newLabel); QPointer saveCommand = - new SavePlaceLabelOptions(toolId, currentLabel, newLabel, qApp->getCurrentDocument(), + new SavePlaceLabelOptions(toolId, currentLabel, newLabel, + VAbstractValApplication::VApp()->getCurrentDocument(), const_cast(data), dialogTool->GetToolId()); m_undoStack.append(saveCommand); UpdateCurrentPlaceLabelRecords(); @@ -1656,7 +1668,7 @@ void DialogSeamAllowance::UpdateGrainlineValues() { plbVal = uiTabGrainline->labelLen; plbText = uiTabGrainline->labelEditLen; - qsUnit = QChar(QChar::Space) + UnitsToStr(qApp->patternUnits()); + qsUnit = QChar(QChar::Space) + UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); } plbVal->setToolTip(tr("Value")); @@ -1665,7 +1677,8 @@ void DialogSeamAllowance::UpdateGrainlineValues() QString qsVal; try { - qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator()); + qsFormula = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); Calculator cal; qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula); if (qIsInf(dVal) == true || qIsNaN(dVal) == true) @@ -1725,13 +1738,13 @@ void DialogSeamAllowance::UpdateDetailLabelValues() { plbVal = uiTabLabels->labelDLWidth; plbText = uiTabLabels->labelEditDLWidth; - qsUnit = QChar(QChar::Space) + UnitsToStr(qApp->patternUnits()); + qsUnit = QChar(QChar::Space) + UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); } else if (i == 1) { plbVal = uiTabLabels->labelDLHeight; plbText = uiTabLabels->labelEditDLHeight; - qsUnit = QChar(QChar::Space) + UnitsToStr(qApp->patternUnits()); + qsUnit = QChar(QChar::Space) + UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); } else { @@ -1747,7 +1760,8 @@ void DialogSeamAllowance::UpdateDetailLabelValues() try { - qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator()); + qsFormula = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); Calculator cal; qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula); if (qIsInf(dVal) == true || qIsNaN(dVal) == true) @@ -1811,13 +1825,13 @@ void DialogSeamAllowance::UpdatePatternLabelValues() { plbVal = uiTabLabels->labelPLWidth; plbText = uiTabLabels->labelEditPLWidth; - qsUnit = QChar(QChar::Space) + UnitsToStr(qApp->patternUnits()); + qsUnit = QChar(QChar::Space) + UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); } else if (i == 1) { plbVal = uiTabLabels->labelPLHeight; plbText = uiTabLabels->labelEditPLHeight; - qsUnit = QChar(QChar::Space) + UnitsToStr(qApp->patternUnits()); + qsUnit = QChar(QChar::Space) + UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); } else { @@ -1832,7 +1846,8 @@ void DialogSeamAllowance::UpdatePatternLabelValues() QString qsVal; try { - qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator()); + qsFormula = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); Calculator cal; qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula); if (qIsInf(dVal) == true || qIsNaN(dVal) == true) @@ -1973,7 +1988,9 @@ void DialogSeamAllowance::EditGrainlineFormula() DialogEditWrongFormula dlg(data, NULL_ID, this); dlg.setWindowTitle(title); - dlg.SetFormula(qApp->TrVars()->TryFormulaFromUser(pleFormula->toPlainText(), qApp->Settings()->GetOsSeparator())); + dlg.SetFormula(VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(pleFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); dlg.setCheckZero(bCheckZero); if (dlg.exec() == QDialog::Accepted) { @@ -2029,7 +2046,9 @@ void DialogSeamAllowance::EditDLFormula() DialogEditWrongFormula dlg(data, NULL_ID, this); dlg.setWindowTitle(title); - dlg.SetFormula(qApp->TrVars()->TryFormulaFromUser(pleFormula->toPlainText(), qApp->Settings()->GetOsSeparator())); + dlg.SetFormula(VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(pleFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); dlg.setCheckZero(bCheckZero); if (dlg.exec() == QDialog::Accepted) { @@ -2088,7 +2107,9 @@ void DialogSeamAllowance::EditPLFormula() DialogEditWrongFormula dlg(data, NULL_ID, this); dlg.setWindowTitle(title); - dlg.SetFormula(qApp->TrVars()->TryFormulaFromUser(pleFormula->toPlainText(), qApp->Settings()->GetOsSeparator())); + dlg.SetFormula(VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(pleFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); dlg.setCheckZero(bCheckZero); if (dlg.exec() == QDialog::Accepted) { @@ -2191,7 +2212,7 @@ void DialogSeamAllowance::EvalWidth() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = uiTabPaths->labelEditWidth; formulaData.labelResult = uiTabPaths->labelResultWidth; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -2224,7 +2245,7 @@ void DialogSeamAllowance::EvalWidthBefore() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = uiTabPaths->labelEditBefore; formulaData.labelResult = uiTabPaths->labelResultBefore; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -2255,7 +2276,7 @@ void DialogSeamAllowance::EvalWidthAfter() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = uiTabPaths->labelEditAfter; formulaData.labelResult = uiTabPaths->labelResultAfter; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = true; @@ -2286,7 +2307,7 @@ void DialogSeamAllowance::EvalPassmarkLength() formulaData.variables = data->DataVariables(); formulaData.labelEditFormula = uiTabPassmarks->labelEditPassmarkLength; formulaData.labelResult = uiTabPassmarks->labelResultPassmarkLength; - formulaData.postfix = UnitsToStr(qApp->patternUnits(), true); + formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; formulaData.checkLessThanZero = false; @@ -2310,7 +2331,7 @@ void DialogSeamAllowance::FXWidth() dialog->setWindowTitle(tr("Edit seam allowance width")); dialog->SetFormula(GetFormulaSAWidth()); dialog->setCheckLessThanZero(true); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormulaSAWidth(dialog->GetFormula()); @@ -2324,7 +2345,7 @@ void DialogSeamAllowance::FXWidthBefore() dialog->setWindowTitle(tr("Edit seam allowance width before")); dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore)); dialog->setCheckLessThanZero(true); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetCurrentSABefore(dialog->GetFormula()); @@ -2338,7 +2359,7 @@ void DialogSeamAllowance::FXWidthAfter() dialog->setWindowTitle(tr("Edit seam allowance width after")); dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter)); dialog->setCheckLessThanZero(true); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetCurrentSAAfter(dialog->GetFormula()); @@ -2351,7 +2372,7 @@ void DialogSeamAllowance::FXPassmarkLength() QScopedPointer dialog(new DialogEditWrongFormula(data, toolId, this)); dialog->setWindowTitle(tr("Edit passmark length")); dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkLength)); - dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true)); + dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) { SetFormularPassmarkLength(dialog->GetFormula()); @@ -2486,7 +2507,7 @@ void DialogSeamAllowance::PatternPinPointChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::EditPieceLabel() { - DialogEditLabel editor(qApp->getCurrentDocument(), data); + DialogEditLabel editor(VAbstractValApplication::VApp()->getCurrentDocument(), data); editor.SetTemplate(m_templateLines); editor.SetPiece(GetPiece()); @@ -2911,9 +2932,11 @@ void DialogSeamAllowance::InitMainPathTab() } }); - uiTabPaths->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping()); - uiTabPaths->checkBoxForceFlipping->setChecked(qApp->Settings()->GetForceWorkpieceFlipping()); - uiTabPaths->checkBoxHideMainPath->setChecked(qApp->Settings()->IsHideMainPath()); + uiTabPaths->checkBoxForbidFlipping->setChecked( + VAbstractApplication::VApp()->Settings()->GetForbidWorkpieceFlipping()); + uiTabPaths->checkBoxForceFlipping->setChecked( + VAbstractApplication::VApp()->Settings()->GetForceWorkpieceFlipping()); + uiTabPaths->checkBoxHideMainPath->setChecked(VAbstractApplication::VApp()->Settings()->IsHideMainPath()); uiTabPaths->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu); connect(uiTabPaths->listWidgetMainPath, &QListWidget::customContextMenuRequested, this, @@ -2980,10 +3003,11 @@ void DialogSeamAllowance::InitSeamAllowanceTab() }); // init the default seam allowance, convert the value if app unit is different than pattern unit - m_saWidth = UnitConvertor(qApp->Settings()->GetDefaultSeamAllowance(), - StrToUnits(qApp->Settings()->GetUnit()), qApp->patternUnits()); + m_saWidth = UnitConvertor(VAbstractApplication::VApp()->Settings()->GetDefaultSeamAllowance(), + StrToUnits(VAbstractApplication::VApp()->Settings()->GetUnit()), + VAbstractValApplication::VApp()->patternUnits()); - uiTabPaths->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth)); + uiTabPaths->plainTextEditFormulaWidth->setPlainText(VAbstractApplication::VApp()->LocaleToString(m_saWidth)); InitNodesList(); connect(uiTabPaths->comboBoxNodes, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -3188,11 +3212,11 @@ void DialogSeamAllowance::InitLabelsTab() // Pattern label data uiTabLabels->lineEditCustomerEmail->setClearButtonEnabled(true); - uiTabLabels->lineEditCustomerName->setText(qApp->GetCustomerName()); - uiTabLabels->lineEditCustomerEmail->setText(qApp->CustomerEmail()); - uiTabLabels->dateEditCustomerBirthDate->setDate(qApp->GetCustomerBirthDate()); + uiTabLabels->lineEditCustomerName->setText(VAbstractValApplication::VApp()->GetCustomerName()); + uiTabLabels->lineEditCustomerEmail->setText(VAbstractValApplication::VApp()->CustomerEmail()); + uiTabLabels->dateEditCustomerBirthDate->setDate(VAbstractValApplication::VApp()->GetCustomerBirthDate()); - if (qApp->GetMeasurementsType() == MeasurementsType::Individual) + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Individual) { uiTabLabels->lineEditCustomerName->setDisabled(true); uiTabLabels->lineEditCustomerName->setToolTip(tr("The customer name from individual measurements")); @@ -3351,7 +3375,8 @@ void DialogSeamAllowance::InitAllPinComboboxes() QString DialogSeamAllowance::GetFormulaSAWidth() const { QString width = uiTabPaths->plainTextEditFormulaWidth->toPlainText(); - return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator()); + return VAbstractApplication::VApp()->TrVars() + ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -3363,7 +3388,8 @@ QVector> &DialogSeamAllowance::UndoStack() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula) { - const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString width = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (width.length() > 80) { @@ -3385,7 +3411,8 @@ void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula) //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetFormularPassmarkLength(const QString &formula) { - const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString width = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (width.length() > 80) { @@ -3449,7 +3476,8 @@ void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula) angleFormula = '0'; } - const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3468,7 +3496,8 @@ void DialogSeamAllowance::SetGrainlineLength(QString lengthFormula) lengthFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = qApp->TrVars()->FormulaToUser(lengthFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(lengthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3488,7 +3517,8 @@ void DialogSeamAllowance::SetDLWidth(QString widthFormula) widthFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(widthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3508,7 +3538,8 @@ void DialogSeamAllowance::SetDLHeight(QString heightFormula) heightFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(heightFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3528,7 +3559,8 @@ void DialogSeamAllowance::SetDLAngle(QString angleFormula) angleFormula = '0'; } - const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3548,7 +3580,8 @@ void DialogSeamAllowance::SetPLWidth(QString widthFormula) widthFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(widthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3568,7 +3601,8 @@ void DialogSeamAllowance::SetPLHeight(QString heightFormula) heightFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(heightFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3588,7 +3622,8 @@ void DialogSeamAllowance::SetPLAngle(QString angleFormula) angleFormula = '0'; } - const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3626,7 +3661,7 @@ void DialogSeamAllowance::ShowPieceSpecialPointsWithRect(const QListWidget *list m_visSpecialPoints->SetShowRect(showRect); m_visSpecialPoints->SetRect(CurrentRect()); - if (not qApp->getCurrentScene()->items().contains(m_visSpecialPoints)) + if (not VAbstractValApplication::VApp()->getCurrentScene()->items().contains(m_visSpecialPoints)) { m_visSpecialPoints->VisualMode(NULL_ID); m_visSpecialPoints->setZValue(10); // pins should be on top @@ -3724,7 +3759,7 @@ void DialogSeamAllowance::SavePatternLabelData() m_doc->SetPatternName(uiTabLabels->lineEditPatternName->text()); m_doc->SetPatternNumber(uiTabLabels->lineEditPatternNumber->text()); m_doc->SetCompanyName(uiTabLabels->lineEditCompanyName->text()); - if (qApp->GetMeasurementsType() != MeasurementsType::Individual) + if (VAbstractValApplication::VApp()->GetMeasurementsType() != MeasurementsType::Individual) { m_doc->SetCustomerName(uiTabLabels->lineEditCustomerName->text()); m_doc->SetCustomerBirthDate(uiTabLabels->dateEditCustomerBirthDate->date()); @@ -3834,7 +3869,7 @@ void DialogSeamAllowance::EditPatternLabel() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ManagePatternMaterials() { - VSettings *settings = qApp->ValentinaSettings(); + VSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); DialogPatternMaterials editor(m_patternMaterials, settings->IsRememberPatternMaterials()); diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp index e4aed0b78..151ed27fc 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp @@ -133,7 +133,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini { if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { - qApp->getUndoStack()->beginMacro(tr("Flipping by axis")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("Flipping by axis")); } VAbstractTool::AddRecord(initData.id, Tool::FlippingByAxis, initData.doc); @@ -150,7 +150,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { VAbstractOperation::CreateVisibilityGroup(initData); - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } return tool; diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp index f1bf49012..8dadba3e1 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp @@ -126,7 +126,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini { if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { - qApp->getUndoStack()->beginMacro(tr("flipping by line")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("flipping by line")); } VAbstractTool::AddRecord(initData.id, Tool::FlippingByLine, initData.doc); @@ -144,7 +144,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { VAbstractOperation::CreateVisibilityGroup(initData); - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } return tool; diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index 10622dfba..95c1d20a5 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -140,7 +140,7 @@ void VAbstractOperation::ChangeLabelPosition(quint32 id, const QPointF &pos) if (QGraphicsScene *sc = item->scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), item); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), item); } } } @@ -176,7 +176,7 @@ void VAbstractOperation::SetLabelVisible(quint32 id, bool visible) item->RefreshPointGeometry(*point); if (QGraphicsScene *sc = item->scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), item); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), item); } } } @@ -238,8 +238,10 @@ QVector VAbstractOperation::ExtractDestinationData(const QDomEl { DestinationItem d; d.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR); - d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QChar('1'))); - d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QChar('1'))); + d.mx = VAbstractValApplication::VApp() + ->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QChar('1'))); + d.my = VAbstractValApplication::VApp() + ->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QChar('1'))); d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr); destination.append(d); } @@ -593,7 +595,7 @@ void VAbstractOperation::ChangeLabelVisibility(quint32 id, bool visible) { dItem->showLabel = visible; } - qApp->getUndoStack()->push(new OperationShowLabel(doc, m_id, id, visible)); + VAbstractApplication::VApp()->getUndoStack()->push(new OperationShowLabel(doc, m_id, id, visible)); } } } @@ -608,7 +610,7 @@ void VAbstractOperation::ApplyToolOptions(const QList &oldDependencies, if (updateToolOptions && updateVisibilityOptions) { - qApp->getUndoStack()->beginMacro(tr("operation options")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("operation options")); } if (updateToolOptions) @@ -616,7 +618,7 @@ void VAbstractOperation::ApplyToolOptions(const QList &oldDependencies, SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies, newDependencies, doc, m_id); connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); - qApp->getUndoStack()->push(saveOptions); + VAbstractApplication::VApp()->getUndoStack()->push(saveOptions); } if (updateVisibilityOptions) @@ -629,7 +631,7 @@ void VAbstractOperation::ApplyToolOptions(const QList &oldDependencies, { ChangeGroupOptions *groupOptions = new ChangeGroupOptions(doc, group, groupName, groupTags); connect(groupOptions, &ChangeGroupOptions::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups); - qApp->getUndoStack()->push(groupOptions); + VAbstractApplication::VApp()->getUndoStack()->push(groupOptions); } else { @@ -649,13 +651,13 @@ void VAbstractOperation::ApplyToolOptions(const QList &oldDependencies, { DelGroup *delGroup = new DelGroup(doc, group); connect(delGroup, &DelGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups); - qApp->getUndoStack()->push(delGroup); + VAbstractApplication::VApp()->getUndoStack()->push(delGroup); } } if (updateToolOptions && updateVisibilityOptions) { - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } } @@ -668,22 +670,22 @@ void VAbstractOperation::PerformDelete() qCDebug(vTool, "Begin deleting."); if (deleteGroup) { - qApp->getUndoStack()->beginMacro(tr("delete operation")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("delete operation")); qCDebug(vTool, "Deleting the linked group."); DelGroup *delGroup = new DelGroup(doc, group); connect(delGroup, &DelGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups); - qApp->getUndoStack()->push(delGroup); + VAbstractApplication::VApp()->getUndoStack()->push(delGroup); } qCDebug(vTool, "Deleting the tool."); DelTool *delTool = new DelTool(doc, m_id); connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); - qApp->getUndoStack()->push(delTool); + VAbstractApplication::VApp()->getUndoStack()->push(delTool); if (deleteGroup) { - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } } @@ -722,7 +724,7 @@ void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos) dItem->mx = pos.x(); dItem->my = pos.y(); } - qApp->getUndoStack()->push(new OperationMoveLabel(m_id, doc, pos, id)); + VAbstractApplication::VApp()->getUndoStack()->push(new OperationMoveLabel(m_id, doc, pos, id)); } } } @@ -752,9 +754,9 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag) VAbstractSimple *obj = operatedObjects.value(dItem.id, nullptr); - doc->SetAttributeOrRemoveIf(item, AttrMx, qApp->fromPixel(dItem.mx), + doc->SetAttributeOrRemoveIf(item, AttrMx, VAbstractValApplication::VApp()->fromPixel(dItem.mx), obj && obj->GetType() != GOType::Point); - doc->SetAttributeOrRemoveIf(item, AttrMy, qApp->fromPixel(dItem.my), + doc->SetAttributeOrRemoveIf(item, AttrMy, VAbstractValApplication::VApp()->fromPixel(dItem.my), obj && obj->GetType() != GOType::Point); doc->SetAttributeOrRemoveIf(item, AttrShowLabel, dItem.showLabel, dItem.showLabel); @@ -930,8 +932,8 @@ QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const "%6" "") .arg(tr("Label"), curve->ObjectName(), tr("Length")) - .arg(qApp->fromPixel(curve->GetLength())) - .arg(UnitsToStr(qApp->patternUnits(), true), MakeToolTip()); + .arg(VAbstractValApplication::VApp()->fromPixel(curve->GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), MakeToolTip()); return toolTip; } @@ -964,7 +966,7 @@ void VAbstractOperation::CreateVisibilityGroup(const VAbstractOperationInitData { AddGroup *addGroup = new AddGroup(group, initData.doc); connect(addGroup, &AddGroup::UpdateGroups, initData.doc, &VAbstractPattern::UpdateVisiblityGroups); - qApp->getUndoStack()->push(addGroup); + VAbstractApplication::VApp()->getUndoStack()->push(addGroup); } return; diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index fce7d2458..447d1bad7 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -176,7 +176,8 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData) calcAngle = CheckFormula(initData.id, initData.formulaAngle, initData.data); calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data); - calcLength = qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)); + calcLength = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength, + initData.data)); QPointF rotationOrigin; QSharedPointer originPoint; @@ -319,7 +320,7 @@ QT_WARNING_POP { if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { - qApp->getUndoStack()->beginMacro(tr("move")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("move")); } VAbstractTool::AddRecord(initData.id, Tool::Move, initData.doc); @@ -341,7 +342,7 @@ QT_WARNING_POP if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { VAbstractOperation::CreateVisibilityGroup(initData); - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } return tool; @@ -401,7 +402,7 @@ VFormula VToolMove::GetFormulaLength() const VFormula fLength(formulaLength, getData()); fLength.setCheckZero(true); fLength.setToolId(m_id); - fLength.setPostfix(UnitsToStr(qApp->patternUnits())); + fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); fLength.Eval(); return fLength; } @@ -460,10 +461,13 @@ void VToolMove::SetVisualization() SCASSERT(visual != nullptr) visual->SetObjects(SourceToObjects(source)); - visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator())); - visual->SetRotationAngle(qApp->TrVars()->FormulaToUser(formulaRotationAngle, - qApp->Settings()->GetOsSeparator())); - visual->SetLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); + visual->SetAngle(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetRotationAngle(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaRotationAngle, + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetRotationOriginPointId(origPointId); visual->RefreshGeometry(); } @@ -530,7 +534,7 @@ QString VToolMove::MakeToolTip() const .arg(GetFormulaAngle().getDoubleValue()) // 2 .arg(tr("Length")) // 3 .arg(GetFormulaLength().getDoubleValue()) // 4 - .arg(UnitsToStr(qApp->patternUnits(), true), // 5 + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), // 5 tr("Rotation angle")) // 6 .arg(GetFormulaRotationAngle().getDoubleValue()) // 7 .arg(tr("Rotation origin point"), // 8 diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 5b6062ba0..2bef5b625 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -260,7 +260,7 @@ QT_WARNING_POP { if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { - qApp->getUndoStack()->beginMacro(tr("rotate")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("rotate")); } VAbstractTool::AddRecord(initData.id, Tool::Rotation, initData.doc); @@ -277,7 +277,7 @@ QT_WARNING_POP if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup) { VAbstractOperation::CreateVisibilityGroup(initData); - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } return tool; @@ -344,7 +344,8 @@ void VToolRotation::SetVisualization() visual->SetObjects(SourceToObjects(source)); visual->SetOriginPointId(origPointId); - visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator())); + visual->SetAngle(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index d56785d93..454ab86b9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -62,7 +62,7 @@ VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint3 controlPoints(), sceneType(SceneObject::Unknown), m_isHovered(false), - detailsMode(qApp->Settings()->IsShowCurveDetails()), + detailsMode(VAbstractApplication::VApp()->Settings()->IsShowCurveDetails()), m_acceptHoverEvents(true), m_parentRefresh(false) { @@ -96,7 +96,8 @@ QPainterPath VAbstractSpline::shape() const //--------------------------------------------------------------------------------------------------------------------- void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - const qreal width = ScaleWidth(m_isHovered ? qApp->Settings()->WidthMainLine() : qApp->Settings()->WidthHairLine(), + const qreal width = ScaleWidth(m_isHovered ? VAbstractApplication::VApp()->Settings()->WidthMainLine() + : VAbstractApplication::VApp()->Settings()->WidthHairLine(), SceneScale(scene())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(m_id); @@ -202,8 +203,8 @@ QString VAbstractSpline::MakeToolTip() const " %1: %2 %3 " "") .arg(tr("Length")) - .arg(qApp->fromPixel(curve->GetLength())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Label"), curve->ObjectName()); + .arg(VAbstractValApplication::VApp()->fromPixel(curve->GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Label"), curve->ObjectName()); return toolTip; } @@ -364,7 +365,7 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin QString newAngle1F = QString().setNum(newAngle1); qreal newLength1 = line.length(); - QString newLength1F = QString().setNum(qApp->fromPixel(newLength1)); + QString newLength1F = QString().setNum(VAbstractValApplication::VApp()->fromPixel(newLength1)); if (not qmu::QmuTokenParser::IsSingle(spline.GetStartAngleFormula())) { @@ -394,7 +395,7 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin QString newAngle2F = QString().setNum(newAngle2); qreal newLength2 = line.length(); - QString newLength2F = QString().setNum(qApp->fromPixel(newLength2)); + QString newLength2F = QString().setNum(VAbstractValApplication::VApp()->fromPixel(newLength2)); if (not qmu::QmuTokenParser::IsSingle(spline.GetEndAngleFormula())) { diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h index d6a9dd008..6894ca666 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h @@ -199,7 +199,7 @@ inline void VAbstractSpline::ShowToolVisualization(bool show) if (QGraphicsScene *sc = scene()) { // Showing/hiding control points require recalculation scene size. - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index 84c979651..0261bbeb7 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -142,7 +142,7 @@ VToolArc* VToolArc::Create(VToolArcInitData &initData) { qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; - calcRadius = qApp->toPixel(CheckFormula(initData.id, initData.radius, initData.data)); + calcRadius = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.radius, initData.data)); calcF1 = CheckFormula(initData.id, initData.f1, initData.data); calcF2 = CheckFormula(initData.id, initData.f2, initData.data); @@ -197,7 +197,7 @@ VFormula VToolArc::GetFormulaRadius() const VFormula radius(arc->GetFormulaRadius(), getData()); radius.setCheckZero(true); radius.setToolId(m_id); - radius.setPostfix(UnitsToStr(qApp->patternUnits())); + radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.Eval(); return radius; } @@ -372,11 +372,14 @@ void VToolArc::SetVisualization() VisToolArc *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - const VTranslateVars *trVars = qApp->TrVars(); + const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); visual->setObject1Id(arc->GetCenter().id()); - visual->setRadius(trVars->FormulaToUser(arc->GetFormulaRadius(), qApp->Settings()->GetOsSeparator())); - visual->setF1(trVars->FormulaToUser(arc->GetFormulaF1(), qApp->Settings()->GetOsSeparator())); - visual->setF2(trVars->FormulaToUser(arc->GetFormulaF2(), qApp->Settings()->GetOsSeparator())); + visual->setRadius(trVars->FormulaToUser( + arc->GetFormulaRadius(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->setF1(trVars->FormulaToUser( + arc->GetFormulaF1(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->setF2(trVars->FormulaToUser( + arc->GetFormulaF2(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(arc->GetPenStyle())); visual->setApproximationScale(arc->GetApproximationScale()); visual->RefreshGeometry(); @@ -396,9 +399,9 @@ QString VToolArc::MakeToolTip() const " %8: %9° " "") .arg(tr("Length")) - .arg(qApp->fromPixel(arc->GetLength())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Radius")) - .arg(qApp->fromPixel(arc->GetRadius())) + .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Radius")) + .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetRadius())) .arg(tr("Start angle")) .arg(arc->GetStartAngle()) .arg(tr("End angle")) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index 6da50512b..cb0029d35 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -124,8 +124,8 @@ VToolArcWithLength *VToolArcWithLength::Create(VToolArcWithLengthInitData &initD { qreal calcRadius = 0, calcF1 = 0, calcLength = 0; - calcRadius = qApp->toPixel(CheckFormula(initData.id, initData.radius, initData.data)); - calcLength = qApp->toPixel(CheckFormula(initData.id, initData.length, initData.data)); + calcRadius = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.radius, initData.data)); + calcLength = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.length, initData.data)); calcF1 = CheckFormula(initData.id, initData.f1, initData.data); const VPointF c = *initData.data->GeometricObject(initData.center); @@ -178,7 +178,7 @@ VFormula VToolArcWithLength::GetFormulaRadius() const VFormula radius(arc->GetFormulaRadius(), getData()); radius.setCheckZero(true); radius.setToolId(m_id); - radius.setPostfix(UnitsToStr(qApp->patternUnits())); + radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.Eval(); return radius; } @@ -237,7 +237,7 @@ VFormula VToolArcWithLength::GetFormulaLength() const VFormula radius(arc->GetFormulaLength(), getData()); radius.setCheckZero(true); radius.setToolId(m_id); - radius.setPostfix(UnitsToStr(qApp->patternUnits())); + radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.Eval(); return radius; } @@ -351,11 +351,14 @@ void VToolArcWithLength::SetVisualization() VisToolArcWithLength *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - const VTranslateVars *trVars = qApp->TrVars(); + const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); visual->setObject1Id(arc->GetCenter().id()); - visual->setRadius(trVars->FormulaToUser(arc->GetFormulaRadius(), qApp->Settings()->GetOsSeparator())); - visual->setF1(trVars->FormulaToUser(arc->GetFormulaF1(), qApp->Settings()->GetOsSeparator())); - visual->setLength(trVars->FormulaToUser(arc->GetFormulaLength(), qApp->Settings()->GetOsSeparator())); + visual->setRadius(trVars->FormulaToUser(arc->GetFormulaRadius(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->setF1(trVars->FormulaToUser(arc->GetFormulaF1(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->setLength(trVars->FormulaToUser(arc->GetFormulaLength(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(arc->GetPenStyle())); visual->setApproximationScale(arc->GetApproximationScale()); visual->RefreshGeometry(); @@ -375,9 +378,9 @@ QString VToolArcWithLength::MakeToolTip() const " %8: %9° " "") .arg(tr("Length")) - .arg(qApp->fromPixel(arc->GetLength())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Radius")) - .arg(qApp->fromPixel(arc->GetRadius())) + .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Radius")) + .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetRadius())) .arg(tr("Start angle")) .arg(arc->GetStartAngle()) .arg(tr("End angle")) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index ee9b1231f..a35e91227 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -147,8 +147,8 @@ VToolEllipticalArc* VToolEllipticalArc::Create(VToolEllipticalArcInitData &initD { qreal calcRadius1 = 0, calcRadius2 = 0, calcF1 = 0, calcF2 = 0, calcRotationAngle = 0; - calcRadius1 = qApp->toPixel(CheckFormula(initData.id, initData.radius1, initData.data)); - calcRadius2 = qApp->toPixel(CheckFormula(initData.id, initData.radius2, initData.data)); + calcRadius1 = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.radius1, initData.data)); + calcRadius2 = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.radius2, initData.data)); calcF1 = CheckFormula(initData.id, initData.f1, initData.data); calcF2 = CheckFormula(initData.id, initData.f2, initData.data); @@ -206,7 +206,7 @@ VFormula VToolEllipticalArc::GetFormulaRadius1() const VFormula radius1(elArc->GetFormulaRadius1(), getData()); radius1.setCheckZero(true); radius1.setToolId(m_id); - radius1.setPostfix(UnitsToStr(qApp->patternUnits())); + radius1.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius1.Eval(); return radius1; } @@ -235,7 +235,7 @@ VFormula VToolEllipticalArc::GetFormulaRadius2() const VFormula radius2(elArc->GetFormulaRadius2(), getData()); radius2.setCheckZero(true); radius2.setToolId(m_id); - radius2.setPostfix(UnitsToStr(qApp->patternUnits())); + radius2.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius2.Eval(); return radius2; } @@ -421,14 +421,18 @@ void VToolEllipticalArc::SetVisualization() VisToolEllipticalArc *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - const VTranslateVars *trVars = qApp->TrVars(); + const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); visual->setObject1Id(elArc->GetCenter().id()); - visual->setRadius1(trVars->FormulaToUser(elArc->GetFormulaRadius1(), qApp->Settings()->GetOsSeparator())); - visual->setRadius2(trVars->FormulaToUser(elArc->GetFormulaRadius2(), qApp->Settings()->GetOsSeparator())); - visual->setF1(trVars->FormulaToUser(elArc->GetFormulaF1(), qApp->Settings()->GetOsSeparator())); - visual->setF2(trVars->FormulaToUser(elArc->GetFormulaF2(), qApp->Settings()->GetOsSeparator())); + visual->setRadius1(trVars->FormulaToUser(elArc->GetFormulaRadius1(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->setRadius2(trVars->FormulaToUser(elArc->GetFormulaRadius2(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->setF1(trVars->FormulaToUser(elArc->GetFormulaF1(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->setF2(trVars->FormulaToUser(elArc->GetFormulaF2(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setRotationAngle(trVars->FormulaToUser(elArc->GetFormulaRotationAngle(), - qApp->Settings()->GetOsSeparator())); + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(elArc->GetPenStyle())); visual->RefreshGeometry(); } @@ -449,12 +453,12 @@ QString VToolEllipticalArc::MakeToolTip() const " %14: %15° " "") .arg(tr("Length")) // 1 - .arg(qApp->fromPixel(elArc->GetLength())) // 2 - .arg(UnitsToStr(qApp->patternUnits(), true), // 3 + .arg(VAbstractValApplication::VApp()->fromPixel(elArc->GetLength())) // 2 + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), // 3 tr("Radius") + QLatin1Char('1')) // 4 - .arg(qApp->fromPixel(elArc->GetRadius1())) // 5 + .arg(VAbstractValApplication::VApp()->fromPixel(elArc->GetRadius1())) // 5 .arg(tr("Radius") + QLatin1Char('2')) // 6 - .arg(qApp->fromPixel(elArc->GetRadius2())) // 7 + .arg(VAbstractValApplication::VApp()->fromPixel(elArc->GetRadius2())) // 7 .arg(tr("Start angle")) // 8 .arg(elArc->GetStartAngle()) // 9 .arg(tr("End angle")) // 10 diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 2e0e6d6f0..6613e1978 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -211,8 +211,10 @@ VToolSpline *VToolSpline::Create(VToolSplineInitData &initData) const qreal calcAngle1 = CheckFormula(initData.id, initData.a1, initData.data); const qreal calcAngle2 = CheckFormula(initData.id, initData.a2, initData.data); - const qreal calcLength1 = qApp->toPixel(CheckFormula(initData.id, initData.l1, initData.data)); - const qreal calcLength2 = qApp->toPixel(CheckFormula(initData.id, initData.l2, initData.data)); + const qreal calcLength1 = + VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.l1, initData.data)); + const qreal calcLength2 = + VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.l2, initData.data)); auto p1 = initData.data->GeometricObject(initData.point1); auto p4 = initData.data->GeometricObject(initData.point4); @@ -267,7 +269,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp Q_UNUSED(indexSpline) const QSharedPointer spline = VAbstractTool::data.GeometricObject(m_id); - if (qApp->Settings()->IsFreeCurveMode() && not moved) + if (VAbstractApplication::VApp()->Settings()->IsFreeCurveMode() && not moved) { oldMoveSpline = QSharedPointer::create(*spline); moved = true; @@ -275,7 +277,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp const VSpline spl = CorrectedSpline(*spline, position, pos); - if (not qApp->Settings()->IsFreeCurveMode()) + if (not VAbstractApplication::VApp()->Settings()->IsFreeCurveMode()) { UndoCommandMove(*spline, spl); } @@ -287,7 +289,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } } @@ -408,7 +410,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event) const auto spline = VAbstractTool::data.GeometricObject(m_id); - if (qApp->Settings()->IsFreeCurveMode() && not moved) + if (VAbstractApplication::VApp()->Settings()->IsFreeCurveMode() && not moved) { oldMoveSpline = QSharedPointer::create(*spline); moved = true; @@ -451,7 +453,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event) newMoveSpline = QSharedPointer::create(spline->GetP1(), p2, p3, spline->GetP4()); - if (not qApp->Settings()->IsFreeCurveMode()) + if (not VAbstractApplication::VApp()->Settings()->IsFreeCurveMode()) { UndoCommandMove(*spline, *newMoveSpline); } @@ -462,7 +464,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } @@ -505,19 +507,19 @@ void VToolSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } VAbstractSpline::hoverEnterEvent(event); } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } } @@ -610,7 +612,7 @@ void VToolSpline::RefreshCtrlPoints() //--------------------------------------------------------------------------------------------------------------------- void VToolSpline::CurveReleased() { - if (qApp->Settings()->IsFreeCurveMode() && moved) + if (VAbstractApplication::VApp()->Settings()->IsFreeCurveMode() && moved) { UndoCommandMove(*oldMoveSpline, *newMoveSpline); @@ -675,5 +677,5 @@ void VToolSpline::UndoCommandMove(const VSpline &oldSpl, const VSpline &newSpl) { MoveSpline *moveSpl = new MoveSpline(doc, oldSpl, newSpl, m_id); connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); - qApp->getUndoStack()->push(moveSpl); + VAbstractApplication::VApp()->getUndoStack()->push(moveSpl); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index 6d1b726c2..dca3524d1 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -258,8 +258,10 @@ VToolSplinePath *VToolSplinePath::Create(VToolSplinePathInitData &initData) const qreal calcAngle1 = CheckFormula(initData.id, initData.a1[i], initData.data); const qreal calcAngle2 = CheckFormula(initData.id, initData.a2[i], initData.data); - const qreal calcLength1 = qApp->toPixel(CheckFormula(initData.id, initData.l1[i], initData.data)); - const qreal calcLength2 = qApp->toPixel(CheckFormula(initData.id, initData.l2[i], initData.data)); + const qreal calcLength1 = + VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.l1[i], initData.data)); + const qreal calcLength2 = + VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.l2[i], initData.data)); const auto p = *initData.data->GeometricObject(initData.points.at(i)); @@ -287,7 +289,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons { const QSharedPointer oldSplPath = VAbstractTool::data.GeometricObject(m_id); - if (qApp->Settings()->IsFreeCurveMode() && not moved) + if (VAbstractApplication::VApp()->Settings()->IsFreeCurveMode() && not moved) { oldMoveSplinePath = QSharedPointer::create(*oldSplPath); moved = true; @@ -298,7 +300,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons UpdateControlPoints(spl, newSplPath, indexSpline); - if (not qApp->Settings()->IsFreeCurveMode()) + if (not VAbstractApplication::VApp()->Settings()->IsFreeCurveMode()) { UndoCommandMove(*oldSplPath, *newSplPath); } @@ -310,7 +312,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } } @@ -413,7 +415,7 @@ void VToolSplinePath::UndoCommandMove(const VSplinePath &oldPath, const VSplineP { MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldPath, newPath, m_id); connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); - qApp->getUndoStack()->push(moveSplPath); + VAbstractApplication::VApp()->getUndoStack()->push(moveSplPath); } //--------------------------------------------------------------------------------------------------------------------- @@ -604,7 +606,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { const auto oldSplPath = VAbstractTool::data.GeometricObject(m_id); - if (qApp->Settings()->IsFreeCurveMode() && not moved) + if (VAbstractApplication::VApp()->Settings()->IsFreeCurveMode() && not moved) { oldMoveSplinePath = QSharedPointer::create(*oldSplPath); moved = true; @@ -655,7 +657,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event) UpdateControlPoints(spl, newMoveSplinePath, splIndex); - if (not qApp->Settings()->IsFreeCurveMode()) + if (not VAbstractApplication::VApp()->Settings()->IsFreeCurveMode()) { UndoCommandMove(*oldSplPath, *newMoveSplinePath); } @@ -666,7 +668,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } @@ -712,19 +714,19 @@ void VToolSplinePath::hoverEnterEvent(QGraphicsSceneHoverEvent *event) } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } VAbstractSpline::hoverEnterEvent(event); } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } } @@ -844,7 +846,7 @@ void VToolSplinePath::RefreshCtrlPoints() //--------------------------------------------------------------------------------------------------------------------- void VToolSplinePath::CurveReleased() { - if (qApp->Settings()->IsFreeCurveMode() && moved) + if (VAbstractApplication::VApp()->Settings()->IsFreeCurveMode() && moved) { UndoCommandMove(*oldMoveSplinePath, *newMoveSplinePath); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp index 1192a5037..680ad92ad 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp @@ -148,7 +148,7 @@ void VToolDoublePoint::SetLabelVisible(quint32 id, bool visible) firstPoint->RefreshPointGeometry(*point); if (QGraphicsScene *sc = firstPoint->scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), firstPoint); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), firstPoint); } } else if (p2id == id) @@ -158,7 +158,7 @@ void VToolDoublePoint::SetLabelVisible(quint32 id, bool visible) secondPoint->RefreshPointGeometry(*point); if (QGraphicsScene *sc = secondPoint->scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), secondPoint); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), secondPoint); } } } @@ -238,7 +238,7 @@ void VToolDoublePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) if (QGraphicsScene *sc = firstPoint->scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), firstPoint); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), firstPoint); } } else if (id == p2id) @@ -250,7 +250,7 @@ void VToolDoublePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) if (QGraphicsScene *sc = secondPoint->scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), secondPoint); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), secondPoint); } } } @@ -296,11 +296,13 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id, const QPointF &pos) { if (id == p1id) { - qApp->getUndoStack()->push(new MoveDoubleLabel(doc, pos, MoveDoublePoint::FirstPoint, m_id, p1id)); + VAbstractApplication::VApp()->getUndoStack()->push( + new MoveDoubleLabel(doc, pos, MoveDoublePoint::FirstPoint, m_id, p1id)); } else if (id == p2id) { - qApp->getUndoStack()->push(new MoveDoubleLabel(doc, pos, MoveDoublePoint::SecondPoint, m_id, p2id)); + VAbstractApplication::VApp()->getUndoStack()->push( + new MoveDoubleLabel(doc, pos, MoveDoublePoint::SecondPoint, m_id, p2id)); } } @@ -369,16 +371,16 @@ void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer &o auto SavePoint1 = [this](QDomElement &tag, const QSharedPointer &point) { doc->SetAttribute(tag, AttrName1, point->name()); - doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx())); - doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my())); + doc->SetAttribute(tag, AttrMx1, VAbstractValApplication::VApp()->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy1, VAbstractValApplication::VApp()->fromPixel(point->my())); doc->SetAttribute(tag, AttrShowLabel1, point->IsShowLabel()); }; auto SavePoint2 = [this](QDomElement &tag, const QSharedPointer &point) { doc->SetAttribute(tag, AttrName2, point->name()); - doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx())); - doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my())); + doc->SetAttribute(tag, AttrMx2, VAbstractValApplication::VApp()->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy2, VAbstractValApplication::VApp()->fromPixel(point->my())); doc->SetAttribute(tag, AttrShowLabel2, point->IsShowLabel()); }; @@ -420,11 +422,13 @@ void VToolDoublePoint::ChangeLabelVisibility(quint32 id, bool visible) { if (id == p1id) { - qApp->getUndoStack()->push(new ShowDoubleLabel(doc, m_id, p1id, visible, ShowDoublePoint::FirstPoint)); + VAbstractApplication::VApp()->getUndoStack()->push( + new ShowDoubleLabel(doc, m_id, p1id, visible, ShowDoublePoint::FirstPoint)); } else if (id == p2id) { - qApp->getUndoStack()->push(new ShowDoubleLabel(doc, m_id, p2id, visible, ShowDoublePoint::SecondPoint)); + VAbstractApplication::VApp()->getUndoStack()->push( + new ShowDoubleLabel(doc, m_id, p2id, visible, ShowDoublePoint::SecondPoint)); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index 83d1acd30..c64823d52 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -49,7 +49,7 @@ VToolCut::VToolCut(const VToolCutInitData &initData, QGraphicsItem *parent) : VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), formula(initData.formula), baseCurveId(initData.baseCurveId), - detailsMode(qApp->Settings()->IsShowCurveDetails()), + detailsMode(VAbstractApplication::VApp()->Settings()->IsShowCurveDetails()), m_aliasSuffix1(initData.aliasSuffix1), m_aliasSuffix2(initData.aliasSuffix2) { @@ -85,7 +85,7 @@ VFormula VToolCut::GetFormulaLength() const VFormula val(formula, getData()); val.setCheckZero(true); val.setToolId(m_id); - val.setPostfix(UnitsToStr(qApp->patternUnits())); + val.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); val.Eval(); return val; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index 8792e66f7..7104a6d23 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -141,7 +141,7 @@ VToolCutArc* VToolCutArc::Create(VToolCutInitData &initData) VArc arc1; VArc arc2; - QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2); + QPointF point = arc->CutArc(VAbstractValApplication::VApp()->toPixel(result), arc1, arc2); arc1.SetAliasSuffix(initData.aliasSuffix1); arc1.SetAliasSuffix(initData.aliasSuffix2); @@ -270,7 +270,8 @@ void VToolCutArc::SetVisualization() SCASSERT(visual != nullptr) visual->setObject1Id(baseCurveId); - visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); @@ -284,7 +285,8 @@ QString VToolCutArc::MakeToolTip() const { const QSharedPointer arc = VAbstractTool::data.GeometricObject(baseCurveId); - const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString expression = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); const QString arcStr = tr("Arc"); @@ -295,7 +297,7 @@ QString VToolCutArc::MakeToolTip() const VArc ar1; VArc ar2; - arc->CutArc(qApp->toPixel(length), ar1, ar2); + arc->CutArc(VAbstractValApplication::VApp()->toPixel(length), ar1, ar2); ar1.setId(m_id + 1); ar2.setId(m_id + 2); @@ -308,9 +310,10 @@ QString VToolCutArc::MakeToolTip() const " %6: %7° " " %8: %9° ") .arg(arcStr + arcNumber + QChar(QChar::Space) + lengthStr) - .arg(qApp->fromPixel(arc.GetLength())) - .arg(UnitsToStr(qApp->patternUnits(), true), arcStr + arcNumber + QChar(QChar::Space) + radiusStr) - .arg(qApp->fromPixel(arc.GetRadius())) + .arg(VAbstractValApplication::VApp()->fromPixel(arc.GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + arcStr + arcNumber + QChar(QChar::Space) + radiusStr) + .arg(VAbstractValApplication::VApp()->fromPixel(arc.GetRadius())) .arg(arcStr + arcNumber + QChar(QChar::Space) + startAngleStr) .arg(arc.GetStartAngle()) .arg(arcStr + arcNumber + QChar(QChar::Space) + endAngleStr) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index 84435bcd8..6a0e332c8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -143,7 +143,7 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData) const qreal result = CheckFormula(initData.id, initData.formula, initData.data); QPointF spl1p2, spl1p3, spl2p2, spl2p3; - QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); + QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -267,7 +267,8 @@ void VToolCutSpline::SetVisualization() SCASSERT(visual != nullptr) visual->setObject1Id(baseCurveId); - visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); @@ -281,11 +282,12 @@ QString VToolCutSpline::MakeToolTip() const { const auto spl = VAbstractTool::data.GeometricObject(baseCurveId); - const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString expression = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); QPointF spl1p2, spl1p3, spl2p2, spl2p3; - QPointF point = spl->CutSpline(qApp->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3); + QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3); VSpline spline1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(point)); VSpline spline2 = VSpline(VPointF(point), spl2p2, spl2p3, spl->GetP4()); @@ -300,9 +302,10 @@ QString VToolCutSpline::MakeToolTip() const " %4: %5 %3 " "") .arg(curveStr + QLatin1String("1 ") + lengthStr) - .arg(qApp->fromPixel(spline1.GetLength())) - .arg(UnitsToStr(qApp->patternUnits(), true), curveStr + QLatin1String("2 ") + lengthStr) - .arg(qApp->fromPixel(spline2.GetLength())) + .arg(VAbstractValApplication::VApp()->fromPixel(spline1.GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + curveStr + QLatin1String("2 ") + lengthStr) + .arg(VAbstractValApplication::VApp()->fromPixel(spline2.GetLength())) .arg(curveStr + QLatin1String(" 1") + tr("label"), spline1.ObjectName(), curveStr + QLatin1String(" 2") + tr("label"), spline2.ObjectName()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 7fbe7fede..d7747b075 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -148,7 +148,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutInitData &initData) VSplinePath *splPath1 = nullptr; VSplinePath *splPath2 = nullptr; - VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(result), splPath, initData.name, &splPath1, &splPath2); + VPointF *p = VToolCutSplinePath::CutSplinePath( + VAbstractValApplication::VApp()->toPixel(result), splPath, initData.name, &splPath1, &splPath2); SCASSERT(splPath1 != nullptr) SCASSERT(splPath2 != nullptr) @@ -362,7 +363,8 @@ void VToolCutSplinePath::SetVisualization() SCASSERT(visual != nullptr) visual->setObject1Id(baseCurveId); - visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); @@ -376,12 +378,14 @@ QString VToolCutSplinePath::MakeToolTip() const { const auto splPath = VAbstractTool::data.GeometricObject(baseCurveId); - const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const QString expression = VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); VSplinePath *splPath1 = nullptr; VSplinePath *splPath2 = nullptr; - VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(length), splPath, "X", &splPath1, &splPath2); + VPointF *p = VToolCutSplinePath::CutSplinePath( + VAbstractValApplication::VApp()->toPixel(length), splPath, "X", &splPath1, &splPath2); delete p; // Don't need this point const QString curveStr = tr("Curve"); @@ -394,9 +398,10 @@ QString VToolCutSplinePath::MakeToolTip() const " %4: %5 %3 " "") .arg(curveStr + QLatin1String("1 ") + lengthStr) - .arg(qApp->fromPixel(splPath1->GetLength())) - .arg(UnitsToStr(qApp->patternUnits(), true), curveStr + QLatin1String("2 ") + lengthStr) - .arg(qApp->fromPixel(splPath2->GetLength())) + .arg(VAbstractValApplication::VApp()->fromPixel(splPath1->GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + curveStr + QLatin1String("2 ") + lengthStr) + .arg(VAbstractValApplication::VApp()->fromPixel(splPath2->GetLength())) .arg(curveStr + QLatin1String(" 1") + tr("label"), splPath1->ObjectName(), curveStr + QLatin1String(" 2") + tr("label"), splPath2->ObjectName()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index 6d2da01ac..e830f755f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -142,7 +142,8 @@ void VToolAlongLine::SetVisualization() SCASSERT(visual != nullptr) visual->setObject1Id(basePointId); visual->setObject2Id(secondPointId); - visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } @@ -166,12 +167,12 @@ QString VToolAlongLine::MakeToolTip() const " %7: %8 %3 " "") .arg(tr("Length")) - .arg(qApp->fromPixel(curLine.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Angle")) + .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(curLine.angle()) .arg(QStringLiteral("%1->%2").arg(basePoint->name(), current->name()), QStringLiteral("%1->%2").arg(current->name(), secondPoint->name())) - .arg(qApp->fromPixel(curToSecond.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToSecond.length())) .arg(tr("Label"), current->name()); return toolTip; } @@ -269,7 +270,8 @@ VToolAlongLine* VToolAlongLine::Create(VToolAlongLineInitData &initData) length->SetName(currentLength); initData.data->AddVariable(length); - line.setLength(qApp->toPixel(CheckFormula(initData.id, initData.formula, initData.data))); + line.setLength(VAbstractValApplication::VApp()->toPixel( + CheckFormula(initData.id, initData.formula, initData.data))); VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index c3a2597f0..f5f23dab4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -177,7 +177,8 @@ VToolBisector* VToolBisector::Create(VToolBisectorInitData &initData) const qreal result = CheckFormula(initData.id, initData.formula, initData.data); QPointF fPoint = VToolBisector::FindPoint(static_cast(*firstPoint), static_cast(*secondPoint), - static_cast(*thirdPoint), qApp->toPixel(result)); + static_cast(*thirdPoint), + VAbstractValApplication::VApp()->toPixel(result)); VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -304,7 +305,8 @@ void VToolBisector::SetVisualization() visual->setObject1Id(firstPointId); visual->setObject2Id(basePointId); visual->setObject3Id(thirdPointId); - visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 91cdefdd2..64ea6c4b1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -144,8 +144,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis const QString errorMsg = tr("Error calculating point '%1'. There is no intersection with curve '%2' and axis" " through point '%3' with angle %4°") .arg(initData.name, curve->ObjectName(), basePoint->name()).arg(angle); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } const qreal segLength = curve->GetLengthByPoint(fPoint); @@ -302,7 +302,8 @@ void VToolCurveIntersectAxis::SetVisualization() visual->setObject1Id(curveId); visual->setAxisPointId(basePointId); - visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator())); + visual->SetAngle(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index a937939c9..c57824b11 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -139,7 +139,8 @@ VToolEndLine* VToolEndLine::Create(VToolEndLineInitData &initData) QLineF line = QLineF(static_cast(*basePoint), QPointF(basePoint->x()+100, basePoint->y())); line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); //First set angle. - line.setLength(qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data))); + line.setLength(VAbstractValApplication::VApp() + ->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data))); VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -229,8 +230,10 @@ void VToolEndLine::SetVisualization() SCASSERT(visual != nullptr) visual->setObject1Id(basePointId); - visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); - visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetAngle(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 71deadfa3..787878526 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -287,13 +287,13 @@ QString VToolHeight::MakeToolTip() const " %8: %9 %3 " "") .arg(tr("Length")) - .arg(qApp->fromPixel(curLine.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Angle")) + .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(curLine.angle()) .arg(QString("%1->%2").arg(p1Line->name(), current->name())) - .arg(qApp->fromPixel(p1ToCur.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1ToCur.length())) .arg(QString("%1->%2").arg(p2Line->name(), current->name())) - .arg(qApp->fromPixel(p2ToCur.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(p2ToCur.length())) .arg(tr("Label"), current->name()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 5415067c1..5134682fc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -136,8 +136,8 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(VToolLineIntersectAxisIni const QString errorMsg = tr("Error calculating point '%1'. Line (%2;%3) doesn't have intersection with axis " "through point '%4' and angle %5°") .arg(initData.name, firstPoint->name(), secondPoint->name(), basePoint->name()).arg(axis.angle()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); @@ -322,7 +322,8 @@ void VToolLineIntersectAxis::SetVisualization() visual->setObject1Id(firstPointId); visual->setPoint2Id(secondPointId); visual->setAxisPointId(basePointId); - visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator())); + visual->SetAngle(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } @@ -348,13 +349,13 @@ QString VToolLineIntersectAxis::MakeToolTip() const " %8: %9 %3 " "") .arg(tr("Length")) - .arg(qApp->fromPixel(curLine.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Angle")) + .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(curLine.angle()) .arg(QString("%1->%2").arg(firstPoint->name(), current->name())) - .arg(qApp->fromPixel(firstToCur.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(firstToCur.length())) .arg(QString("%1->%2").arg(current->name(), secondPoint->name())) - .arg(qApp->fromPixel(curToSecond.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToSecond.length())) .arg(tr("Label"), current->name()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp index 6725ad7cc..26ba4d215 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp @@ -157,8 +157,8 @@ QString VToolLinePoint::MakeToolTip() const " %4: %5° " "") .arg(tr("Length")) - .arg(qApp->fromPixel(line.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Angle")) + .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(line.angle()) .arg(tr("Label"), second->name()); return toolTip; @@ -217,7 +217,7 @@ VFormula VToolLinePoint::GetFormulaLength() const VFormula fLength(formulaLength, this->getData()); fLength.setCheckZero(false); fLength.setToolId(m_id); - fLength.setPostfix(UnitsToStr(qApp->patternUnits())); + fLength.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); fLength.Eval(); return fLength; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index ff2bf7437..e223b26d4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -142,7 +142,7 @@ VToolNormal* VToolNormal::Create(VToolNormalInitData initData) const qreal result = CheckFormula(initData.id, initData.formula, initData.data); QPointF fPoint = VToolNormal::FindPoint(static_cast(*firstPoint), static_cast(*secondPoint), - qApp->toPixel(result), initData.angle); + VAbstractValApplication::VApp()->toPixel(result), initData.angle); VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -274,7 +274,8 @@ void VToolNormal::SetVisualization() visual->setObject1Id(basePointId); visual->setObject2Id(secondPointId); - visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetAngle(angle); visual->setLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index 895f95edb..dfc03f864 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -193,7 +193,8 @@ VToolShoulderPoint* VToolShoulderPoint::Create(VToolShoulderPointInitData &initD QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast(*firstPoint), static_cast(*secondPoint), - static_cast(*shoulderPoint), qApp->toPixel(result)); + static_cast(*shoulderPoint), + VAbstractValApplication::VApp()->toPixel(result)); VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -322,7 +323,8 @@ void VToolShoulderPoint::SetVisualization() visual->setObject1Id(pShoulder); visual->setLineP1Id(basePointId); visual->setLineP2Id(p2Line); - visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator())); + visual->setLength(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->setLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } @@ -345,11 +347,11 @@ QString VToolShoulderPoint::MakeToolTip() const " %6: %7 %3 " "") .arg(tr("Length")) - .arg(qApp->fromPixel(firstToCur.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Angle")) + .arg(VAbstractValApplication::VApp()->fromPixel(firstToCur.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(firstToCur.angle()) .arg(QString("%1->%2").arg(second->name(), current->name())) - .arg(qApp->fromPixel(secondToCur.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(secondToCur.length())) .arg(tr("Label"), current->name()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index f2bd56923..605f8fa7c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -165,7 +165,7 @@ void VToolBasePoint::AddToFile() AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP); connect(addPP, &AddPatternPiece::ClearScene, doc, &VAbstractPattern::ClearScene); connect(addPP, &AddPatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); - qApp->getUndoStack()->push(addPP); + VAbstractApplication::VApp()->getUndoStack()->push(addPP); } //--------------------------------------------------------------------------------------------------------------------- @@ -190,7 +190,7 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), m_id, this->scene()); connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); - qApp->getUndoStack()->push(moveSP); + VAbstractApplication::VApp()->getUndoStack()->push(moveSP); const QList viewList = scene()->views(); if (not viewList.isEmpty()) { @@ -209,7 +209,7 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co QPointF VToolBasePoint::GetBasePointPos() const { const QSharedPointer p = VAbstractTool::data.GeometricObject(m_id); - QPointF pos(qApp->fromPixel(p->x()), qApp->fromPixel(p->y())); + QPointF pos(VAbstractValApplication::VApp()->fromPixel(p->x()), VAbstractValApplication::VApp()->fromPixel(p->y())); return pos; } @@ -217,8 +217,8 @@ QPointF VToolBasePoint::GetBasePointPos() const void VToolBasePoint::SetBasePointPos(const QPointF &pos) { QSharedPointer p = VAbstractTool::data.GeometricObject(m_id); - p->setX(qApp->toPixel(pos.x())); - p->setY(qApp->toPixel(pos.y())); + p->setX(VAbstractValApplication::VApp()->toPixel(pos.x())); + p->setY(VAbstractValApplication::VApp()->toPixel(pos.y())); QSharedPointer obj = qSharedPointerCast(p); @@ -229,7 +229,7 @@ void VToolBasePoint::SetBasePointPos(const QPointF &pos) void VToolBasePoint::DeleteToolWithConfirm(bool ask) { qCDebug(vTool, "Deleting base point."); - emit qApp->getSceneView()->itemClicked(nullptr); + emit VAbstractValApplication::VApp()->getSceneView()->itemClicked(nullptr); if (ask) { qCDebug(vTool, "Asking."); @@ -243,7 +243,7 @@ void VToolBasePoint::DeleteToolWithConfirm(bool ask) qCDebug(vTool, "Begin deleting."); DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw); connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); - qApp->getUndoStack()->push(deletePP); + VAbstractApplication::VApp()->getUndoStack()->push(deletePP); // Throw exception, this will help prevent case when we forget to immediately quit function. VExceptionToolWasDeleted e("Tool was used after deleting."); @@ -267,8 +267,8 @@ void VToolBasePoint::SaveDialog(QDomElement &domElement, QList &oldDepe const QPointF p = dialogTool->GetPoint(); const QString name = dialogTool->GetPointName(); doc->SetAttribute(domElement, AttrName, name); - doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(p.x()))); - doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(p.y()))); + doc->SetAttribute(domElement, AttrX, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.y()))); const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); @@ -321,8 +321,8 @@ void VToolBasePoint::SaveOptions(QDomElement &tag, QSharedPointer &obj SCASSERT(point.isNull() == false) doc->SetAttribute(tag, AttrType, ToolType); - doc->SetAttribute(tag, AttrX, qApp->fromPixel(point->x())); - doc->SetAttribute(tag, AttrY, qApp->fromPixel(point->y())); + doc->SetAttribute(tag, AttrX, VAbstractValApplication::VApp()->fromPixel(point->x())); + doc->SetAttribute(tag, AttrY, VAbstractValApplication::VApp()->fromPixel(point->y())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index fe63d38dd..0031d57fa 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -151,8 +151,8 @@ VToolLineIntersect* VToolLineIntersect::Create(VToolLineIntersectInitData initDa const QString errorMsg = tr("Error calculating point '%1'. Lines (%2;%3) and (%4;%5) have no point of " "intersection") .arg(initData.name, p1Line1->name(), p2Line1->name(), p1Line2->name(), p2Line2->name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); @@ -327,13 +327,14 @@ QString VToolLineIntersect::MakeToolTip() const " %8: %9 %3 " "") .arg(QString("%1->%2").arg(p1L1->name(), current->name())) - .arg(qApp->fromPixel(p1L1ToCur.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), QString("%1->%2").arg(current->name(), p2L1->name())) - .arg(qApp->fromPixel(curToP2L1.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1L1ToCur.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + QString("%1->%2").arg(current->name(), p2L1->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToP2L1.length())) .arg(QString("%1->%2").arg(p1L2->name(), current->name())) - .arg(qApp->fromPixel(p1L2ToCur.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1L2ToCur.length())) .arg(QString("%1->%2").arg(current->name(), p2L2->name())) - .arg(qApp->fromPixel(curToP2L2.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToP2L2.length())) .arg(tr("Label"), current->name()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 34df55804..36b6d2c23 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -123,8 +123,8 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(VToolPointFromA { const QString errorMsg = tr("Error calculating point '%1'. Tangent to arc '%2' from point '%3' cannot be found") .arg(initData.name, arc.ObjectName(), tPoint.name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index 0890794a2..cfb9a6d71 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -118,7 +118,8 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const QPo //--------------------------------------------------------------------------------------------------------------------- VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(VToolPointFromCircleAndTangentInitData &initData) { - const qreal radius = qApp->toPixel(CheckFormula(initData.id, initData.circleRadius, initData.data)); + const qreal radius = + VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.circleRadius, initData.data)); const VPointF cPoint = *initData.data->GeometricObject(initData.circleCenterId); const VPointF tPoint = *initData.data->GeometricObject(initData.tangentPointId); @@ -132,8 +133,8 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(VToolPoin "from point '%4' cannot be found") .arg(initData.name, cPoint.name()).arg(radius).arg(tPoint.name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); @@ -208,7 +209,7 @@ VFormula VToolPointFromCircleAndTangent::GetCircleRadius() const VFormula radius(circleRadius, getData()); radius.setCheckZero(true); radius.setToolId(m_id); - radius.setPostfix(UnitsToStr(qApp->patternUnits())); + radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.Eval(); return radius; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 30bbda66c..8cd5ab9fe 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -209,17 +209,18 @@ VToolPointOfContact* VToolPointOfContact::Create(VToolPointOfContactInitData &in const qreal result = CheckFormula(initData.id, initData.radius, initData.data); QPointF fPoint; - const bool success = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast(*centerP), + const bool success = VToolPointOfContact::FindPoint(VAbstractValApplication::VApp()->toPixel(result), + static_cast(*centerP), static_cast(*firstP), static_cast(*secondP), &fPoint); if (not success) { - const QString errorMsg = tr("Error calculating point '%1'. Circle with center '%2' and radius '%3' doesn't have " - "intersection with line (%4;%5)") + const QString errorMsg = tr("Error calculating point '%1'. Circle with center '%2' and radius '%3' doesn't " + "have intersection with line (%4;%5)") .arg(initData.name, centerP->name()).arg(result).arg(firstP->name(), secondP->name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); @@ -354,7 +355,8 @@ void VToolPointOfContact::SetVisualization() visual->setObject1Id(firstPointId); visual->setLineP2Id(secondPointId); visual->setRadiusId(center); - visual->setRadius(qApp->TrVars()->FormulaToUser(arcRadius, qApp->Settings()->GetOsSeparator())); + visual->setRadius(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(arcRadius, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->RefreshGeometry(); } } @@ -379,11 +381,12 @@ QString VToolPointOfContact::MakeToolTip() const " %8: %9° " "") .arg(QStringLiteral("%1->%2").arg(p1->name(), current->name())) - .arg(qApp->fromPixel(p1ToCur.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), QStringLiteral("%1->%2").arg(p2->name(), current->name())) - .arg(qApp->fromPixel(p2ToCur.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1ToCur.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + QStringLiteral("%1->%2").arg(p2->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(p2ToCur.length())) .arg(QStringLiteral("%1 %2->%3").arg(tr("Length"), centerP->name(), current->name())) - .arg(qApp->fromPixel(centerToCur.length())) + .arg(VAbstractValApplication::VApp()->fromPixel(centerToCur.length())) .arg(QStringLiteral("%1 %2->%3").arg(tr("Angle"), centerP->name(), current->name())) .arg(centerToCur.angle()) .arg(tr("Label"), current->name()); @@ -416,7 +419,7 @@ VFormula VToolPointOfContact::getArcRadius() const VFormula radius(arcRadius, this->getData()); radius.setCheckZero(true); radius.setToolId(m_id); - radius.setPostfix(UnitsToStr(qApp->patternUnits())); + radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.Eval(); return radius; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index 9f9c44d4f..a5d58c658 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -122,8 +122,8 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(VToolPointOfI { const QString errorMsg = tr("Error calculating point '%1'. Arcs '%2' and '%3' have no point of intersection") .arg(initData.name, firstArc->ObjectName(), secondArc->ObjectName()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index dabd037bf..956229048 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -122,8 +122,10 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const Q VToolPointOfIntersectionCircles * VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData &initData) { - const qreal calcC1Radius = qApp->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data)); - const qreal calcC2Radius = qApp->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data)); + const qreal calcC1Radius = VAbstractValApplication::VApp() + ->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data)); + const qreal calcC2Radius = VAbstractValApplication::VApp() + ->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data)); const VPointF c1Point = *initData.data->GeometricObject(initData.firstCircleCenterId); const VPointF c2Point = *initData.data->GeometricObject(initData.secondCircleCenterId); @@ -136,8 +138,8 @@ VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData { const QString errorMsg = tr("Error calculating point '%1'. Circles with centers in points '%2' and '%3' have " "no point of intersection").arg(initData.name, c1Point.name(), c2Point.name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); @@ -221,7 +223,7 @@ VFormula VToolPointOfIntersectionCircles::GetFirstCircleRadius() const VFormula radius(firstCircleRadius, getData()); radius.setCheckZero(true); radius.setToolId(m_id); - radius.setPostfix(UnitsToStr(qApp->patternUnits())); + radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.Eval(); return radius; } @@ -246,7 +248,7 @@ VFormula VToolPointOfIntersectionCircles::GetSecondCircleRadius() const VFormula radius(secondCircleRadius, getData()); radius.setCheckZero(true); radius.setToolId(m_id); - radius.setPostfix(UnitsToStr(qApp->patternUnits())); + radius.setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); radius.Eval(); return radius; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index 95a2ce7a5..6378c4223 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -127,8 +127,8 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPoin { const QString errorMsg = tr("Error calculating point '%1'. Curves '%2' and '%3' have no point of intersection") .arg(initData.name, curve1->name(), curve2->name()); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 2fec444b5..547c392eb 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -139,7 +139,7 @@ void VToolSinglePoint::SetLabelVisible(quint32 id, bool visible) RefreshPointGeometry(*point); if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } } @@ -162,7 +162,7 @@ void VToolSinglePoint::UpdateNamePosition(quint32 id, const QPointF &pos) { if (id == m_id) { - qApp->getUndoStack()->push(new MoveLabel(doc, pos, id)); + VAbstractApplication::VApp()->getUndoStack()->push(new MoveLabel(doc, pos, id)); } } @@ -320,8 +320,8 @@ void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer &o SCASSERT(point.isNull() == false) doc->SetAttribute(tag, AttrName, point->name()); - doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + doc->SetAttribute(tag, AttrMx, VAbstractValApplication::VApp()->fromPixel(point->mx())); + doc->SetAttribute(tag, AttrMy, VAbstractValApplication::VApp()->fromPixel(point->my())); doc->SetAttribute(tag, AttrShowLabel, point->IsShowLabel()); } @@ -330,7 +330,7 @@ void VToolSinglePoint::ChangeLabelVisibility(quint32 id, bool visible) { if (id == m_id) { - qApp->getUndoStack()->push(new ShowLabel(doc, id, visible)); + VAbstractApplication::VApp()->getUndoStack()->push(new ShowLabel(doc, id, visible)); } } @@ -347,7 +347,7 @@ void VToolSinglePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 79833306d..69d689438 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -149,8 +149,8 @@ VToolTriangle* VToolTriangle::Create(VToolTriangleInitData initData) { const QString errorMsg = tr("Error calculating point '%1'. Point of intersection cannot be found") .arg(initData.name); - qApp->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index e0bcde203..1a30a49ea 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -132,7 +132,7 @@ void VDrawTool::ApplyToolOptions(const QList &oldDependencies, const QL SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, oldDependencies, newDependencies, doc, m_id); connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); - qApp->getUndoStack()->push(saveOptions); + VAbstractApplication::VApp()->getUndoStack()->push(saveOptions); } } @@ -162,7 +162,7 @@ void VDrawTool::SaveOption(QSharedPointer &obj) SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, QList(), QList(), doc, m_id); connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); - qApp->getUndoStack()->push(saveOptions); + VAbstractApplication::VApp()->getUndoStack()->push(saveOptions); } else { @@ -261,7 +261,7 @@ void VDrawTool::AddToCalculation(const QDomElement &domElement) AddToCalc *addToCal = new AddToCalc(domElement, doc); connect(addToCal, &AddToCalc::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); - qApp->getUndoStack()->push(addToCal); + VAbstractApplication::VApp()->getUndoStack()->push(addToCal); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 37d943bdd..2574a2f2e 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -283,8 +283,8 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI else if (selectedAction == actionOption) { qCDebug(vTool, "Show options."); - emit qApp->getSceneView()->itemClicked(nullptr); - m_dialog = QPointer(new Dialog(getData(), m_id, qApp->getMainWindow())); + emit VAbstractValApplication::VApp()->getSceneView()->itemClicked(nullptr); + m_dialog = QPointer(new Dialog(getData(), m_id, VAbstractValApplication::VApp()->getMainWindow())); m_dialog->setModal(true); connect(m_dialog.data(), &DialogTool::DialogClosed, this, &VDrawTool::FullUpdateFromGuiOk); @@ -313,17 +313,19 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI quint32 groupId = selectedAction->data().toUInt(); QDomElement item = doc->AddItemToGroup(this->getId(), itemId, groupId); - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = + qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->clearSelection(); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) { AddItemToGroup *addItemToGroup = new AddItemToGroup(item, doc, groupId); connect(addItemToGroup, &AddItemToGroup::UpdateGroups, window, &VAbstractMainWindow::UpdateVisibilityGroups); - qApp->getUndoStack()->push(addItemToGroup); + VAbstractApplication::VApp()->getUndoStack()->push(addItemToGroup); } } else if (selectedAction->actionGroup() == actionsRemoveFromGroup) @@ -331,13 +333,14 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI quint32 groupId = selectedAction->data().toUInt(); QDomElement item = doc->RemoveItemFromGroup(this->getId(), itemId, groupId); - VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow()); + VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) { RemoveItemFromGroup *removeItemFromGroup = new RemoveItemFromGroup(item, doc, groupId); connect(removeItemFromGroup, &RemoveItemFromGroup::UpdateGroups, window, &VAbstractMainWindow::UpdateVisibilityGroups); - qApp->getUndoStack()->push(removeItemFromGroup); + VAbstractApplication::VApp()->getUndoStack()->push(removeItemFromGroup); } } } diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index c562b3e5d..c5356fb07 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -299,7 +299,7 @@ void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } } @@ -448,8 +448,8 @@ QString VToolLine::MakeToolTip() const " %4: %5° " "") .arg(tr("Length")) - .arg(qApp->fromPixel(line.length())) - .arg(UnitsToStr(qApp->patternUnits(), true), tr("Angle")) + .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(line.angle()); return toolTip; } diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index ef521e4b8..e39e82378 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -186,7 +186,7 @@ void VNodePoint::ChangeLabelPosition(quint32 id, const QPointF &pos) RefreshLine(); if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } } @@ -201,7 +201,7 @@ void VNodePoint::SetLabelVisible(quint32 id, bool visible) RefreshPointGeometry(*point); if (QGraphicsScene *sc = scene()) { - VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(sc, VAbstractValApplication::VApp()->getSceneView(), this); } } } @@ -240,8 +240,8 @@ void VNodePoint::AddToFile() doc->SetAttribute(domElement, VDomDocument::AttrId, m_id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrIdObject, idNode); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); + doc->SetAttribute(domElement, AttrMx, VAbstractValApplication::VApp()->fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, VAbstractValApplication::VApp()->fromPixel(point->my())); doc->SetAttribute(domElement, AttrShowLabel, point->IsShowLabel()); if (idTool != NULL_ID) { @@ -287,7 +287,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) */ void VNodePoint::NameChangePosition(const QPointF &pos) { - qApp->getUndoStack()->push(new MoveLabel(doc, pos - this->pos(), m_id)); + VAbstractApplication::VApp()->getUndoStack()->push(new MoveLabel(doc, pos - this->pos(), m_id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -607,7 +607,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") } return;//Leave this method immediately after call!!! case ContextMenuOption::ShowLabel: - qApp->getUndoStack()->push(new ShowLabel(doc, m_id, selectedAction->isChecked())); + VAbstractApplication::VApp()->getUndoStack()->push( + new ShowLabel(doc, m_id, selectedAction->isChecked())); break; case ContextMenuOption::Exclude: emit ToggleExcludeState(m_id); diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp index 1f34135cf..e0ad5a386 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp @@ -121,7 +121,7 @@ QString VToolPiecePath::getTagName() const //--------------------------------------------------------------------------------------------------------------------- void VToolPiecePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - qreal width = qApp->Settings()->WidthHairLine(); + qreal width = VAbstractApplication::VApp()->Settings()->WidthHairLine(); const qreal scale = SceneScale(scene()); if (scale > 1) @@ -254,7 +254,7 @@ void VToolPiecePath::AddToFile() incrementReferens(); // Manually increment reference since in this case a piece tool will not do this for us } - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_pieceId)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_pieceId)); } } diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp index 12b79e610..1b930f809 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp @@ -151,7 +151,7 @@ void VToolPin::AddToFile() newDet.GetPins().append(m_id); incrementReferens(); // Manually increment reference since in this case a piece tool will not do this for us - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_pieceId)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_pieceId)); } } diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp index 58c7d7c9a..611ced9a4 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.cpp @@ -61,8 +61,10 @@ VToolPlaceLabel *VToolPlaceLabel::Create(const QPointer &dialog, VAb //--------------------------------------------------------------------------------------------------------------------- VToolPlaceLabel *VToolPlaceLabel::Create(VToolPlaceLabelInitData &initData) { - const qreal w = qAbs(qApp->toPixel(CheckFormula(initData.id, initData.width, initData.data))); - const qreal h = qAbs(qApp->toPixel(CheckFormula(initData.id, initData.height, initData.data))); + const qreal w = + qAbs(VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.width, initData.data))); + const qreal h = + qAbs(VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.height, initData.data))); const qreal a = CheckFormula(initData.id, initData.angle, initData.data); const qreal v = CheckFormula(initData.id, initData.visibilityTrigger, initData.data); @@ -203,7 +205,7 @@ void VToolPlaceLabel::AddToFile() newDet.GetPlaceLabels().append(m_id); incrementReferens(); // Manually increment reference since in this case a piece tool will not do this for us - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_pieceId)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_pieceId)); } } diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 1354397d3..863609606 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -149,9 +149,9 @@ qreal VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VCont << "Expression: " << e.GetExpr() << "\n" << "--------------------------------------"; - if (qApp->IsAppInGUIMode()) + if (VAbstractApplication::VApp()->IsAppInGUIMode()) { - QScopedPointer dialogUndo(new DialogUndo(qApp->getMainWindow())); + QScopedPointer dialogUndo(new DialogUndo(VAbstractValApplication::VApp()->getMainWindow())); forever { if (dialogUndo->exec() == QDialog::Accepted) @@ -159,7 +159,8 @@ qreal VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VCont const UndoButton resultUndo = dialogUndo->Result(); if (resultUndo == UndoButton::Fix) { - auto *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow()); + auto *dialog = new DialogEditWrongFormula(data, toolId, + VAbstractValApplication::VApp()->getMainWindow()); dialog->setWindowTitle(tr("Edit wrong formula")); dialog->SetFormula(formula); if (dialog->exec() == QDialog::Accepted) @@ -213,7 +214,7 @@ void VAbstractTool::DeleteToolWithConfirm(bool ask) if (_referens == 0) { qCDebug(vTool, "No children."); - emit qApp->getSceneView()->itemClicked(nullptr); + emit VAbstractValApplication::VApp()->getSceneView()->itemClicked(nullptr); if (ask) { qCDebug(vTool, "Asking."); @@ -242,18 +243,18 @@ void VAbstractTool::PerformDelete() qCDebug(vTool, "Begin deleting."); DelTool *delTool = new DelTool(doc, m_id); connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); - qApp->getUndoStack()->push(delTool); + VAbstractApplication::VApp()->getUndoStack()->push(delTool); } //--------------------------------------------------------------------------------------------------------------------- int VAbstractTool::ConfirmDeletion() { - if (false == qApp->Settings()->GetConfirmItemDelete()) + if (false == VAbstractApplication::VApp()->Settings()->GetConfirmItemDelete()) { return QMessageBox::Yes; } - Utils::CheckableMessageBox msgBox(qApp->getMainWindow()); + Utils::CheckableMessageBox msgBox(VAbstractValApplication::VApp()->getMainWindow()); msgBox.setWindowTitle(tr("Confirm deletion")); msgBox.setText(tr("Do you really want to delete?")); msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); @@ -264,7 +265,7 @@ int VAbstractTool::ConfirmDeletion() if (dialogResult == QDialog::Accepted) { - qApp->Settings()->SetConfirmItemDelete(not msgBox.isChecked()); + VAbstractApplication::VApp()->Settings()->SetConfirmItemDelete(not msgBox.isChecked()); } return dialogResult == QDialog::Accepted ? QMessageBox::Yes : QMessageBox::No; diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index 80d6135b2..aa156f780 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -210,7 +210,7 @@ template inline void VAbstractTool::AddVisualization() { T *visual = new T(getData()); - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->addItem(visual); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 291cce2dd..d77503abc 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -151,7 +151,7 @@ VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initD VAbstractTool::AddRecord(initData.id, Tool::Piece, initData.doc); piece = new VToolSeamAllowance(initData); initData.scene->addItem(piece); - VMainGraphicsView::NewSceneRect(initData.scene, qApp->getSceneView(), piece); + VMainGraphicsView::NewSceneRect(initData.scene, VAbstractValApplication::VApp()->getSceneView(), piece); VAbstractPattern::AddTool(initData.id, piece); } //Very important to delete it. Only this tool need this special variable. @@ -262,7 +262,7 @@ void VToolSeamAllowance::InsertNodes(const QVector &nodes, quint32 p InitNode(node, scene, saTool); } - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, pieceId)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, pieceId)); } } @@ -274,8 +274,8 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl doc->SetAttribute(domElement, VDomDocument::AttrId, id); doc->SetAttribute(domElement, AttrName, piece.GetName()); doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy())); + doc->SetAttribute(domElement, AttrMx, VAbstractValApplication::VApp()->fromPixel(piece.GetMx())); + doc->SetAttribute(domElement, AttrMy, VAbstractValApplication::VApp()->fromPixel(piece.GetMy())); doc->SetAttributeOrRemoveIf(domElement, AttrInLayout, piece.IsInLayout(), piece.IsInLayout()); doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping()); doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping()); @@ -432,7 +432,7 @@ void VToolSeamAllowance::Update(const VPiece &piece) setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); VAbstractTool::data.UpdatePiece(m_id, piece); RefreshGeometry(); - VMainGraphicsView::NewSceneRect(m_sceneDetails, qApp->getSceneView(), this); + VMainGraphicsView::NewSceneRect(m_sceneDetails, VAbstractValApplication::VApp()->getSceneView(), this); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } @@ -686,8 +686,8 @@ void VToolSeamAllowance::UpdateGrainline() { const QString errorMsg = QObject::tr("Piece '%1'. Grainline is not valid.") .arg(detail.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } else @@ -708,7 +708,7 @@ void VToolSeamAllowance::SaveMoveDetail(const QPointF& ptPos) SavePieceOptions* moveCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); moveCommand->setText(tr("move pattern piece label")); - qApp->getUndoStack()->push(moveCommand); + VAbstractApplication::VApp()->getUndoStack()->push(moveCommand); } //--------------------------------------------------------------------------------------------------------------------- @@ -728,7 +728,7 @@ void VToolSeamAllowance::SaveResizeDetail(qreal dLabelW, int iFontSize) SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); resizeCommand->setText(tr("resize pattern piece label")); - qApp->getUndoStack()->push(resizeCommand); + VAbstractApplication::VApp()->getUndoStack()->push(resizeCommand); } //--------------------------------------------------------------------------------------------------------------------- @@ -749,7 +749,7 @@ void VToolSeamAllowance::SaveRotationDetail(qreal dRot) SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); rotateCommand->setText(tr("rotate pattern piece label")); - qApp->getUndoStack()->push(rotateCommand); + VAbstractApplication::VApp()->getUndoStack()->push(rotateCommand); } @@ -765,7 +765,7 @@ void VToolSeamAllowance::SaveMovePattern(const QPointF &ptPos) SavePieceOptions* moveCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); moveCommand->setText(tr("move pattern info label")); - qApp->getUndoStack()->push(moveCommand); + VAbstractApplication::VApp()->getUndoStack()->push(moveCommand); } //--------------------------------------------------------------------------------------------------------------------- @@ -785,7 +785,7 @@ void VToolSeamAllowance::SaveResizePattern(qreal dLabelW, int iFontSize) SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); resizeCommand->setText(tr("resize pattern info label")); - qApp->getUndoStack()->push(resizeCommand); + VAbstractApplication::VApp()->getUndoStack()->push(resizeCommand); } //--------------------------------------------------------------------------------------------------------------------- @@ -804,7 +804,7 @@ void VToolSeamAllowance::SaveRotationPattern(qreal dRot) SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); rotateCommand->setText(tr("rotate pattern info label")); - qApp->getUndoStack()->push(rotateCommand); + VAbstractApplication::VApp()->getUndoStack()->push(rotateCommand); } @@ -818,7 +818,7 @@ void VToolSeamAllowance::SaveMoveGrainline(const QPointF& ptPos) SavePieceOptions* moveCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); moveCommand->setText(tr("move grainline")); - qApp->getUndoStack()->push(moveCommand); + VAbstractApplication::VApp()->getUndoStack()->push(moveCommand); } //--------------------------------------------------------------------------------------------------------------------- @@ -833,7 +833,7 @@ void VToolSeamAllowance::SaveResizeGrainline(qreal dLength) SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); resizeCommand->setText(tr("resize grainline")); - qApp->getUndoStack()->push(resizeCommand); + VAbstractApplication::VApp()->getUndoStack()->push(resizeCommand); } //--------------------------------------------------------------------------------------------------------------------- @@ -847,7 +847,7 @@ void VToolSeamAllowance::SaveRotateGrainline(qreal dRot, const QPointF& ptPos) SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); rotateCommand->setText(tr("rotate grainline")); - qApp->getUndoStack()->push(rotateCommand); + VAbstractApplication::VApp()->getUndoStack()->push(rotateCommand); } //--------------------------------------------------------------------------------------------------------------------- @@ -857,7 +857,7 @@ void VToolSeamAllowance::SaveRotateGrainline(qreal dRot, const QPointF& ptPos) void VToolSeamAllowance::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QPen toolPen = pen(); - toolPen.setWidthF(ScaleWidth(qApp->Settings()->WidthHairLine(), SceneScale(scene()))); + toolPen.setWidthF(ScaleWidth(VAbstractApplication::VApp()->Settings()->WidthHairLine(), SceneScale(scene()))); setPen(toolPen); m_seamAllowance->setPen(toolPen); @@ -931,7 +931,8 @@ void VToolSeamAllowance::AddToFile() AddPins(doc, domElement, piece.GetPins()); AddPlaceLabels(doc, domElement, piece.GetPlaceLabels()); - qApp->getUndoStack()->push(new AddPiece(domElement, doc, VAbstractTool::data, m_sceneDetails, m_drawName)); + VAbstractApplication::VApp()->getUndoStack()->push(new AddPiece(domElement, doc, VAbstractTool::data, + m_sceneDetails, m_drawName)); } //--------------------------------------------------------------------------------------------------------------------- @@ -981,7 +982,8 @@ QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change // value - this is new position. const QPointF newPos = value.toPointF(); - qApp->getUndoStack()->push(new MovePiece(doc, newPos.x(), newPos.y(), m_id, scene())); + VAbstractApplication::VApp()->getUndoStack()->push(new MovePiece(doc, newPos.x(), newPos.y(), m_id, + scene())); const QList viewList = scene()->views(); if (not viewList.isEmpty()) @@ -1077,13 +1079,13 @@ void VToolSeamAllowance::hoverEnterEvent(QGraphicsSceneHoverEvent *event) } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } QGraphicsPathItem::hoverEnterEvent(event); } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } } @@ -1170,7 +1172,7 @@ void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event) { if (not toolList.isEmpty()) { - qApp->getUndoStack()->beginMacro(tr("multi deletion")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("multi deletion")); for(auto tool : toolList) { @@ -1184,7 +1186,7 @@ void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event) Q_UNUSED(e); if (not toolList.isEmpty()) { - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } return;//Leave this method immediately!!! } @@ -1304,8 +1306,8 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) QPainterPath path; - if (qApp->Settings()->IsPieceShowMainPath() || not detail.IsHideMainPath() || not detail.IsSeamAllowance() - || detail.IsSeamAllowanceBuiltIn()) + if (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not detail.IsHideMainPath() + || not detail.IsSeamAllowance() || detail.IsSeamAllowanceBuiltIn()) { m_mainPath = QPainterPath(); m_mainPathRect = QRectF(); @@ -1331,8 +1333,8 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) { const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.") .arg(detail.GetName()); - qApp->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } path.addPath(detail.SeamAllowancePath(futureSeamAllowance.result())); path.setFillRule(Qt::OddEvenFill); @@ -1343,7 +1345,7 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) m_seamAllowance->setPath(QPainterPath()); } - if (qApp->IsAppInGUIMode()) + if (VAbstractApplication::VApp()->IsAppInGUIMode()) { QTimer::singleShot(100, Qt::CoarseTimer, this, [this, updateChildren]() { @@ -1392,35 +1394,37 @@ void VToolSeamAllowance::SaveDialogChange(const QString &undoText) const bool groupChange = not undocommands.isEmpty(); SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, m_id); - if (VAbstractMainWindow *window = qobject_cast(qApp->getMainWindow())) + if (VAbstractMainWindow *window = + qobject_cast(VAbstractValApplication::VApp()->getMainWindow())) { // Better not to crash here, just silently do not update list. connect(saveCommand, &SavePieceOptions::UpdateGroups, window, &VAbstractMainWindow::UpdateDetailsList); } if (groupChange) { - qApp->getUndoStack()->beginMacro(undoText.isEmpty() ? saveCommand->text(): undoText); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(undoText.isEmpty() ? saveCommand->text(): undoText); for (auto command : undocommands) { - qApp->getUndoStack()->push(command); + VAbstractApplication::VApp()->getUndoStack()->push(command); command.clear(); // To prevent double free memory } undocommands.clear(); } - qApp->getUndoStack()->push(saveCommand); + VAbstractApplication::VApp()->getUndoStack()->push(saveCommand); if (groupChange) { - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); } } //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::ShowOptions() { - QPointer dialog = new DialogSeamAllowance(getData(), doc, m_id, qApp->getMainWindow()); + QPointer dialog = new DialogSeamAllowance(getData(), doc, m_id, + VAbstractValApplication::VApp()->getMainWindow()); dialog->EnableApply(true); m_dialog = dialog; m_dialog->setModal(true); @@ -1435,22 +1439,23 @@ void VToolSeamAllowance::ToggleInLayout(bool checked) { auto togglePrint = new TogglePieceInLayout(m_id, checked, &(VAbstractTool::data), doc); connect(togglePrint, &TogglePieceInLayout::Toggled, doc, &VAbstractPattern::CheckInLayoutList); - qApp->getUndoStack()->push(togglePrint); + VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::ToggleForbidFlipping(bool checked) { - qApp->getUndoStack()->push(new TogglePieceForceForbidFlipping(m_id, checked, - ForceForbidFlippingType::ForbidFlipping, - &(VAbstractTool::data), doc)); + VAbstractApplication::VApp()->getUndoStack()->push( + new TogglePieceForceForbidFlipping(m_id, checked, ForceForbidFlippingType::ForbidFlipping, + &(VAbstractTool::data), doc)); } //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::ToggleForceFlipping(bool checked) { - qApp->getUndoStack()->push(new TogglePieceForceForbidFlipping(m_id, checked, ForceForbidFlippingType::ForceFlipping, - &(VAbstractTool::data), doc)); + VAbstractApplication::VApp()->getUndoStack()->push( + new TogglePieceForceForbidFlipping(m_id, checked, ForceForbidFlippingType::ForceFlipping, + &(VAbstractTool::data), doc)); } //--------------------------------------------------------------------------------------------------------------------- @@ -1473,7 +1478,7 @@ void VToolSeamAllowance::ToggleExcludeState(quint32 id) node.SetExcluded(not node.IsExcluded()); newDet.GetPath()[i] = node; - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); return; } } @@ -1493,7 +1498,7 @@ void VToolSeamAllowance::ToggleNodePointAngleType(quint32 id, PieceNodeAngle typ node.SetAngleType(type); newDet.GetPath()[i] = node; - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); return; } } @@ -1513,7 +1518,7 @@ void VToolSeamAllowance::ToggleNodePointPassmark(quint32 id, bool toggle) node.SetPassmark(toggle); newDet.GetPath()[i] = node; - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); return; } } @@ -1533,7 +1538,7 @@ void VToolSeamAllowance::TogglePassmarkAngleType(quint32 id, PassmarkAngleType t node.SetPassmarkAngleType(type); newDet.GetPath()[i] = node; - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); return; } } @@ -1553,7 +1558,7 @@ void VToolSeamAllowance::TogglePassmarkLineType(quint32 id, PassmarkLineType typ node.SetPassmarkLineType(type); newDet.GetPath()[i] = node; - qApp->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); + VAbstractApplication::VApp()->getUndoStack()->push(new SavePieceOptions(oldDet, newDet, doc, m_id)); return; } } @@ -1864,7 +1869,7 @@ void VToolSeamAllowance::DeleteToolWithConfirm(bool ask) } } - qApp->getUndoStack()->push(delDet.take()); + VAbstractApplication::VApp()->getUndoStack()->push(delDet.take()); // Throw exception, this will help prevent case when we forget to immediately quit function. VExceptionToolWasDeleted e(tr("Tool was used after deleting.")); @@ -1901,7 +1906,7 @@ bool VToolSeamAllowance::PrepareLabelData(const VPatternLabelData &labelData, co } labelItem->SetMoveType(type); - QFont fnt = qApp->Settings()->GetLabelFont(); + QFont fnt = VAbstractApplication::VApp()->Settings()->GetLabelFont(); { const int iFS = labelData.GetFontSize(); iFS < MIN_FONT_SIZE ? fnt.setPixelSize(MIN_FONT_SIZE) : fnt.setPixelSize(iFS); diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 21bc1fe28..5c5bfd8c2 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -1766,9 +1766,9 @@ VToolUnionDetails* VToolUnionDetails::Create(const QPointer &dialog, initData.typeCreation = Source::FromGui; initData.retainPieces = dialogTool->RetainPieces(); - qApp->getUndoStack()->beginMacro(tr("union details")); + VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("union details")); VToolUnionDetails* tool = Create(initData); - qApp->getUndoStack()->endMacro(); + VAbstractApplication::VApp()->getUndoStack()->endMacro(); return tool; } diff --git a/src/libs/vtools/undocommands/addpiece.cpp b/src/libs/vtools/undocommands/addpiece.cpp index 52cc347f8..2415020d7 100644 --- a/src/libs/vtools/undocommands/addpiece.cpp +++ b/src/libs/vtools/undocommands/addpiece.cpp @@ -127,7 +127,7 @@ void AddPiece::redo() m_scene->addItem(m_tool); m_tool->ConnectOutsideSignals(); m_tool->show(); - VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(), m_tool); + VMainGraphicsView::NewSceneRect(m_scene, VAbstractValApplication::VApp()->getSceneView(), m_tool); m_tool.clear(); } diff --git a/src/libs/vtools/undocommands/addtocalc.cpp b/src/libs/vtools/undocommands/addtocalc.cpp index a91bc142c..d6530422d 100644 --- a/src/libs/vtools/undocommands/addtocalc.cpp +++ b/src/libs/vtools/undocommands/addtocalc.cpp @@ -76,8 +76,9 @@ void AddToCalc::undo() return; } emit NeedFullParsing(); - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); - if (qApp->GetDrawMode() == Draw::Calculation) + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo } @@ -118,7 +119,8 @@ void AddToCalc::redo() return; } RedoFullParsing(); - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- @@ -127,7 +129,7 @@ void AddToCalc::RedoFullParsing() if (redoFlag) { emit NeedFullParsing(); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo } diff --git a/src/libs/vtools/undocommands/deletepatternpiece.cpp b/src/libs/vtools/undocommands/deletepatternpiece.cpp index 43f930a5b..15c6b9503 100644 --- a/src/libs/vtools/undocommands/deletepatternpiece.cpp +++ b/src/libs/vtools/undocommands/deletepatternpiece.cpp @@ -82,7 +82,7 @@ void DeletePatternPiece::undo() } emit NeedFullParsing(); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(namePP);//Without this user will not see this change } @@ -93,7 +93,7 @@ void DeletePatternPiece::redo() { qCDebug(vUndo, "Redo."); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(namePP);//Without this user will not see this change } diff --git a/src/libs/vtools/undocommands/deletepiece.cpp b/src/libs/vtools/undocommands/deletepiece.cpp index 95984f697..1d2f7a64c 100644 --- a/src/libs/vtools/undocommands/deletepiece.cpp +++ b/src/libs/vtools/undocommands/deletepiece.cpp @@ -102,7 +102,7 @@ void DeletePiece::undo() m_scene->addItem(m_tool); m_tool->ConnectOutsideSignals(); m_tool->show(); - VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(), m_tool); + VMainGraphicsView::NewSceneRect(m_scene, VAbstractValApplication::VApp()->getSceneView(), m_tool); m_tool.clear(); emit doc->UpdateInLayoutList(); } diff --git a/src/libs/vtools/undocommands/deltool.cpp b/src/libs/vtools/undocommands/deltool.cpp index cf4642163..dd2f2229b 100644 --- a/src/libs/vtools/undocommands/deltool.cpp +++ b/src/libs/vtools/undocommands/deltool.cpp @@ -59,7 +59,7 @@ void DelTool::undo() UndoDeleteAfterSibling(parentNode, siblingId); emit NeedFullParsing(); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) {//Keep last! emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change } @@ -70,7 +70,7 @@ void DelTool::redo() { qCDebug(vUndo, "Redo."); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) {//Keep first! emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change } diff --git a/src/libs/vtools/undocommands/label/movedoublelabel.cpp b/src/libs/vtools/undocommands/label/movedoublelabel.cpp index 51a84eb61..40ff3242a 100644 --- a/src/libs/vtools/undocommands/label/movedoublelabel.cpp +++ b/src/libs/vtools/undocommands/label/movedoublelabel.cpp @@ -44,7 +44,7 @@ MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const QPointF &pos, Move : MoveAbstractLabel(doc, pointId, pos, parent), m_type(type), m_idTool(toolId), - m_scene(qApp->getCurrentScene()) + m_scene(VAbstractValApplication::VApp()->getCurrentScene()) { if (type == MoveDoublePoint::FirstPoint) { @@ -60,16 +60,20 @@ MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const QPointF &pos, Move { if (type == MoveDoublePoint::FirstPoint) { - m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx1, "0.0")); - m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy1, "0.0")); + m_oldPos.rx() = + VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMx1, "0.0")); + m_oldPos.ry() = + VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMy1, "0.0")); qCDebug(vUndo, "Label old Mx1 %f", m_oldPos.x()); qCDebug(vUndo, "Label old My1 %f", m_oldPos.y()); } else { - m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx2, "0.0")); - m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy2, "0.0")); + m_oldPos.rx() = + VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMx2, "0.0")); + m_oldPos.ry() = + VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMy2, "0.0")); qCDebug(vUndo, "Label old Mx2 %f", m_oldPos.x()); qCDebug(vUndo, "Label old My2 %f", m_oldPos.y()); @@ -134,13 +138,17 @@ void MoveDoubleLabel::Do(const QPointF &pos) { if (m_type == MoveDoublePoint::FirstPoint) { - doc->SetAttribute(domElement, AttrMx1, QString().setNum(qApp->fromPixel(pos.x()))); - doc->SetAttribute(domElement, AttrMy1, QString().setNum(qApp->fromPixel(pos.y()))); + doc->SetAttribute(domElement, AttrMx1, + QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.x()))); + doc->SetAttribute(domElement, AttrMy1, + QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.y()))); } else { - doc->SetAttribute(domElement, AttrMx2, QString().setNum(qApp->fromPixel(pos.x()))); - doc->SetAttribute(domElement, AttrMy2, QString().setNum(qApp->fromPixel(pos.y()))); + doc->SetAttribute(domElement, AttrMx2, + QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.x()))); + doc->SetAttribute(domElement, AttrMy2, + QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.y()))); } if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(m_idTool))) diff --git a/src/libs/vtools/undocommands/label/movelabel.cpp b/src/libs/vtools/undocommands/label/movelabel.cpp index 250af6c6a..32ff9644e 100644 --- a/src/libs/vtools/undocommands/label/movelabel.cpp +++ b/src/libs/vtools/undocommands/label/movelabel.cpp @@ -42,15 +42,15 @@ //--------------------------------------------------------------------------------------------------------------------- MoveLabel::MoveLabel(VAbstractPattern *doc, const QPointF &pos, const quint32 &id, QUndoCommand *parent) : MoveAbstractLabel(doc, id, pos, parent), - m_scene(qApp->getCurrentScene()) + m_scene(VAbstractValApplication::VApp()->getCurrentScene()) { setText(tr("move point label")); QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); if (domElement.isElement()) { - m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0")); - m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy, "0.0")); + m_oldPos.rx() = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0")); + m_oldPos.ry() = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMy, "0.0")); qCDebug(vUndo, "Label old Mx %f", m_oldPos.x()); qCDebug(vUndo, "Label old My %f", m_oldPos.y()); @@ -94,8 +94,8 @@ void MoveLabel::Do(const QPointF &pos) QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(pos.x()))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(pos.y()))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.x()))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.y()))); if (VAbstractTool *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) { diff --git a/src/libs/vtools/undocommands/label/operationmovelabel.cpp b/src/libs/vtools/undocommands/label/operationmovelabel.cpp index 51817d374..196e87f82 100644 --- a/src/libs/vtools/undocommands/label/operationmovelabel.cpp +++ b/src/libs/vtools/undocommands/label/operationmovelabel.cpp @@ -44,7 +44,7 @@ OperationMoveLabel::OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, co QUndoCommand *parent) : MoveAbstractLabel(doc, idPoint, pos, parent), m_idTool(idTool), - m_scene(qApp->getCurrentScene()) + m_scene(VAbstractValApplication::VApp()->getCurrentScene()) { setText(tr("move point label")); @@ -53,8 +53,8 @@ OperationMoveLabel::OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, co const QDomElement element = GetDestinationObject(m_idTool, nodeId); if (element.isElement()) { - m_oldPos.rx() = qApp->toPixel(doc->GetParametrDouble(element, AttrMx, "0.0")); - m_oldPos.ry() = qApp->toPixel(doc->GetParametrDouble(element, AttrMy, "0.0")); + m_oldPos.rx() = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(element, AttrMx, "0.0")); + m_oldPos.ry() = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(element, AttrMy, "0.0")); qCDebug(vUndo, "Label old Mx %f", m_oldPos.x()); qCDebug(vUndo, "Label old My %f", m_oldPos.y()); @@ -98,8 +98,8 @@ void OperationMoveLabel::Do(const QPointF &pos) QDomElement domElement = GetDestinationObject(m_idTool, nodeId); if (not domElement.isNull() && domElement.isElement()) { - doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(pos.x()))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(pos.y()))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.x()))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(VAbstractValApplication::VApp()->fromPixel(pos.y()))); if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(m_idTool))) { diff --git a/src/libs/vtools/undocommands/label/operationshowlabel.cpp b/src/libs/vtools/undocommands/label/operationshowlabel.cpp index e314a6a7d..0c2a9d3ea 100644 --- a/src/libs/vtools/undocommands/label/operationshowlabel.cpp +++ b/src/libs/vtools/undocommands/label/operationshowlabel.cpp @@ -41,7 +41,7 @@ OperationShowLabel::OperationShowLabel(VAbstractPattern *doc, quint32 idTool, qu : VUndoCommand(QDomElement(), doc, parent), m_visible(visible), m_oldVisible(not visible), - m_scene(qApp->getCurrentScene()), + m_scene(VAbstractValApplication::VApp()->getCurrentScene()), m_idTool(idTool) { nodeId = idPoint; @@ -90,7 +90,7 @@ void OperationShowLabel::Do(bool visible) { tool->SetLabelVisible(nodeId, visible); } - VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(m_scene, VAbstractValApplication::VApp()->getSceneView()); } else { diff --git a/src/libs/vtools/undocommands/label/showdoublelabel.cpp b/src/libs/vtools/undocommands/label/showdoublelabel.cpp index 8522c3d1f..3467f18c7 100644 --- a/src/libs/vtools/undocommands/label/showdoublelabel.cpp +++ b/src/libs/vtools/undocommands/label/showdoublelabel.cpp @@ -41,7 +41,7 @@ ShowDoubleLabel::ShowDoubleLabel(VAbstractPattern *doc, quint32 toolId, quint32 : VUndoCommand(QDomElement(), doc, parent), m_visible(visible), m_oldVisible(not visible), - m_scene(qApp->getCurrentScene()), + m_scene(VAbstractValApplication::VApp()->getCurrentScene()), m_type(type), m_idTool(toolId) { @@ -110,7 +110,7 @@ void ShowDoubleLabel::Do(bool visible) { tool->SetLabelVisible(nodeId, visible); } - VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(m_scene, VAbstractValApplication::VApp()->getSceneView()); } else { diff --git a/src/libs/vtools/undocommands/label/showlabel.cpp b/src/libs/vtools/undocommands/label/showlabel.cpp index f5c8a9450..a508b26b1 100644 --- a/src/libs/vtools/undocommands/label/showlabel.cpp +++ b/src/libs/vtools/undocommands/label/showlabel.cpp @@ -40,7 +40,7 @@ ShowLabel::ShowLabel(VAbstractPattern *doc, quint32 id, bool visible, QUndoComma : VUndoCommand(QDomElement(), doc, parent), m_visible(visible), m_oldVisible(true), - m_scene(qApp->getCurrentScene()) + m_scene(VAbstractValApplication::VApp()->getCurrentScene()) { setText(tr("toggle label")); @@ -49,7 +49,7 @@ ShowLabel::ShowLabel(VAbstractPattern *doc, quint32 id, bool visible, QUndoComma QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); if (domElement.isElement()) { - m_oldVisible = doc->GetParametrBool(domElement, AttrShowLabel, trueStr); + m_oldVisible = VDomDocument::GetParametrBool(domElement, AttrShowLabel, trueStr); } else { diff --git a/src/libs/vtools/undocommands/movepiece.cpp b/src/libs/vtools/undocommands/movepiece.cpp index a6077aa9a..aea5d82b3 100644 --- a/src/libs/vtools/undocommands/movepiece.cpp +++ b/src/libs/vtools/undocommands/movepiece.cpp @@ -55,8 +55,8 @@ MovePiece::MovePiece(VAbstractPattern *doc, const double &x, const double &y, co QDomElement domElement = doc->elementById(id, VAbstractPattern::TagDetail); if (domElement.isElement()) { - m_oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0")); - m_oldY = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMy, "0.0")); + m_oldX = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0")); + m_oldY = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrMy, "0.0")); } else { @@ -117,7 +117,7 @@ void MovePiece::Do(qreal x, qreal y) { tool->Move(x, y); } - VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(), tool); + VMainGraphicsView::NewSceneRect(m_scene, VAbstractValApplication::VApp()->getSceneView(), tool); } else { @@ -128,6 +128,6 @@ void MovePiece::Do(qreal x, qreal y) //--------------------------------------------------------------------------------------------------------------------- void MovePiece::SaveCoordinates(QDomElement &domElement, double x, double y) { - doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(x))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(y))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(VAbstractValApplication::VApp()->fromPixel(x))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(VAbstractValApplication::VApp()->fromPixel(y))); } diff --git a/src/libs/vtools/undocommands/movespline.cpp b/src/libs/vtools/undocommands/movespline.cpp index 170839705..0ef95274b 100644 --- a/src/libs/vtools/undocommands/movespline.cpp +++ b/src/libs/vtools/undocommands/movespline.cpp @@ -45,7 +45,7 @@ MoveSpline::MoveSpline(VAbstractPattern *doc, const VSpline &oldSpl, const VSpli : VUndoCommand(QDomElement(), doc, parent), oldSpline(oldSpl), newSpline(newSpl), - scene(qApp->getCurrentScene()) + scene(VAbstractValApplication::VApp()->getCurrentScene()) { setText(tr("move spline")); nodeId = id; diff --git a/src/libs/vtools/undocommands/movesplinepath.cpp b/src/libs/vtools/undocommands/movesplinepath.cpp index d0615056d..12968642f 100644 --- a/src/libs/vtools/undocommands/movesplinepath.cpp +++ b/src/libs/vtools/undocommands/movesplinepath.cpp @@ -44,7 +44,7 @@ MoveSplinePath::MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplP : VUndoCommand(QDomElement(), doc, parent), oldSplinePath(oldSplPath), newSplinePath(newSplPath), - scene(qApp->getCurrentScene()) + scene(VAbstractValApplication::VApp()->getCurrentScene()) { setText(tr("move spline path")); nodeId = id; diff --git a/src/libs/vtools/undocommands/movespoint.cpp b/src/libs/vtools/undocommands/movespoint.cpp index 123ecf020..bbf9d0f26 100644 --- a/src/libs/vtools/undocommands/movespoint.cpp +++ b/src/libs/vtools/undocommands/movespoint.cpp @@ -52,8 +52,8 @@ MoveSPoint::MoveSPoint(VAbstractPattern *doc, const double &x, const double &y, QDomElement domElement = doc->elementById(id, VAbstractPattern::TagPoint); if (domElement.isElement()) { - oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrX, "0.0")); - oldY = qApp->toPixel(doc->GetParametrDouble(domElement, AttrY, "0.0")); + oldX = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrX, "0.0")); + oldY = VAbstractValApplication::VApp()->toPixel(doc->GetParametrDouble(domElement, AttrY, "0.0")); qCDebug(vUndo, "SPoint oldX %f", oldX); qCDebug(vUndo, "SPoint oldY %f", oldY); @@ -121,8 +121,8 @@ void MoveSPoint::Do(double x, double y) QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(x))); - doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(y))); + doc->SetAttribute(domElement, AttrX, QString().setNum(VAbstractValApplication::VApp()->fromPixel(x))); + doc->SetAttribute(domElement, AttrY, QString().setNum(VAbstractValApplication::VApp()->fromPixel(y))); emit NeedLiteParsing(Document::LitePPParse); } diff --git a/src/libs/vtools/undocommands/undogroup.cpp b/src/libs/vtools/undocommands/undogroup.cpp index 3dde2498a..c0e29fc89 100644 --- a/src/libs/vtools/undocommands/undogroup.cpp +++ b/src/libs/vtools/undocommands/undogroup.cpp @@ -87,8 +87,9 @@ void AddGroup::undo() return; } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); - if (qApp->GetDrawMode() == Draw::Calculation) + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo } @@ -114,7 +115,8 @@ void AddGroup::redo() return; } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); } //RenameGroup @@ -238,7 +240,7 @@ void AddItemToGroup::performUndoRedo(bool isUndo) } doc->SetModified(true); - emit qApp->getCurrentDocument()->patternChanged(false); + emit VAbstractValApplication::VApp()->getCurrentDocument()->patternChanged(false); QDomElement groups = doc->CreateGroups(); if (not groups.isNull()) @@ -258,8 +260,9 @@ void AddItemToGroup::performUndoRedo(bool isUndo) return; } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); - if (qApp->GetDrawMode() == Draw::Calculation) + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo } @@ -322,7 +325,7 @@ void RemoveItemFromGroup::performUndoRedo(bool isUndo) } doc->SetModified(true); - emit qApp->getCurrentDocument()->patternChanged(false); + emit VAbstractValApplication::VApp()->getCurrentDocument()->patternChanged(false); QDomElement groups = doc->CreateGroups(); if (not groups.isNull()) @@ -342,9 +345,10 @@ void RemoveItemFromGroup::performUndoRedo(bool isUndo) return; } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo } @@ -404,7 +408,8 @@ void ChangeGroupVisibility::Do(bool visible) emit UpdateGroup(nodeId, visible); - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); } else { @@ -471,7 +476,8 @@ void ChangeMultipleGroupsVisibility::undo() doc->ParseGroups(groups); } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); emit UpdateMultipleGroups(groupsState); } @@ -508,7 +514,8 @@ void ChangeMultipleGroupsVisibility::redo() doc->ParseGroups(groups); } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); emit UpdateMultipleGroups(groupsState); } @@ -529,7 +536,7 @@ void DelGroup::undo() { qCDebug(vUndo, "Undo."); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change } @@ -547,7 +554,8 @@ void DelGroup::undo() return; } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- @@ -555,7 +563,7 @@ void DelGroup::redo() { qCDebug(vUndo, "Redo."); - if (qApp->GetDrawMode() == Draw::Calculation) + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) {//Keep first! emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change } @@ -592,5 +600,6 @@ void DelGroup::redo() return; } - VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + VMainGraphicsView::NewSceneRect(VAbstractValApplication::VApp()->getCurrentScene(), + VAbstractValApplication::VApp()->getSceneView()); } diff --git a/src/libs/vtools/visualization/line/operation/visoperation.cpp b/src/libs/vtools/visualization/line/operation/visoperation.cpp index 7147e14d7..32bc0638f 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.cpp +++ b/src/libs/vtools/visualization/line/operation/visoperation.cpp @@ -66,7 +66,7 @@ void VisOperation::SetObjects(const QVector &objects) void VisOperation::VisualMode(const quint32 &pointId) { Q_UNUSED(pointId) - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) Visualization::scenePos = scene->getScenePos(); diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp index 984540d0f..550a91c9c 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp @@ -145,7 +145,7 @@ void VisToolMove::RefreshGeometry() qreal cursorLength = rLine.length(); rLine.setP2(Ray(origin, rLine.angle())); //Radius of point circle, but little bigger. Need handle with hover sizes. - qreal minL = ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5; + qreal minL = ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5; if (cursorLength > minL) { tempRoationAngle = rLine.angle(); @@ -164,19 +164,21 @@ void VisToolMove::RefreshGeometry() DrawLine(rotationLine, rLine, supportColor3, Qt::DashLine); DrawLine(xAxis, QLineF(origin, Ray(origin, 0)), supportColor3, Qt::DashLine); - VArc arc(VPointF(origin), ScaledRadius(SceneScale(qApp->getCurrentScene()))*2, 0, tempRoationAngle); + VArc arc(VPointF(origin), + ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*2, 0, tempRoationAngle); DrawPath(angleArc, arc.GetPath(), supportColor3, Qt::SolidLine, Qt::RoundCap); } DrawLine(this, line, supportColor2, Qt::DashLine); DrawPoint(pointFinish, line.p2(), supportColor); - static const QString prefix = UnitsToStr(qApp->patternUnits(), true); + static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); if (qFuzzyIsNull(length)) { Visualization::toolTip = tr("Length = %1%2, angle = %3°, %4 - sticking angle, " "Mouse click - finish selecting a position") - .arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)), - qApp->Settings()->GetOsSeparator()), prefix) + .arg(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + QString::number(VAbstractValApplication::VApp()->fromPixel(tempLength)), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()), prefix) .arg(tempAngle) .arg(VModifierKey::Shift()); } @@ -184,8 +186,9 @@ void VisToolMove::RefreshGeometry() { Visualization::toolTip = tr("Length = %1%2, angle = %3°, rotation angle = %4°, %5 - sticking angle, " "%6 - change rotation origin point, Mouse click - finish creating") - .arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)), - qApp->Settings()->GetOsSeparator()), prefix) + .arg(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + QString::number(VAbstractValApplication::VApp()->fromPixel(tempLength)), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()), prefix) .arg(tempAngle) .arg(tempRoationAngle) .arg(VModifierKey::Shift(), VModifierKey::Control()); @@ -227,7 +230,7 @@ QString VisToolMove::Length() const //--------------------------------------------------------------------------------------------------------------------- qreal VisToolMove::LengthValue() const { - return qApp->fromPixel(line().length()); + return VAbstractValApplication::VApp()->fromPixel(line().length()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp index d1c570693..7a76e7e44 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp @@ -117,7 +117,7 @@ void VisToolRotation::RefreshGeometry() DrawLine(xAxis, QLineF(static_cast(*origin), Ray(static_cast(*origin), 0)), supportColor2, Qt::DashLine); - VArc arc(*origin, ScaledRadius(SceneScale(qApp->getCurrentScene()))*2, 0, tempAngle); + VArc arc(*origin, ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*2, 0, tempAngle); DrawPath(angleArc, arc.GetPath(), supportColor2, Qt::SolidLine, Qt::RoundCap); Visualization::toolTip = tr("Rotating angle = %1°, %2 - sticking angle, " diff --git a/src/libs/vtools/visualization/line/vistoolendline.cpp b/src/libs/vtools/visualization/line/vistoolendline.cpp index 88e9e6906..959b36ef1 100644 --- a/src/libs/vtools/visualization/line/vistoolendline.cpp +++ b/src/libs/vtools/visualization/line/vistoolendline.cpp @@ -79,12 +79,13 @@ void VisToolEndLine::RefreshGeometry() DrawPoint(point, line.p2(), mainColor); } DrawLine(this, line, mainColor, lineStyle); - static const QString prefix = UnitsToStr(qApp->patternUnits(), true); + static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); Visualization::toolTip = tr("Point at distance and angle: angle = %1°, length = %2%3; " "%4 - sticking angle, %5 - finish creation") .arg(this->line().angle()) - .arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(this->line().length())), - qApp->Settings()->GetOsSeparator()), + .arg(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser(QString::number(VAbstractValApplication::VApp()->fromPixel(this->line().length())), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()), prefix, VModifierKey::Shift(), VModifierKey::EnterKey()); } @@ -103,7 +104,7 @@ void VisToolEndLine::SetAngle(const QString &expression) //--------------------------------------------------------------------------------------------------------------------- QString VisToolEndLine::Length() const { - return QString::number(qApp->fromPixel(this->line().length())); + return QString::number(VAbstractValApplication::VApp()->fromPixel(this->line().length())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp index a33a895c1..99975c1e2 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp @@ -88,7 +88,7 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionArcs::VisualMode(const quint32 &id) { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) this->arc1Id = id; diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp index 3f31a9fd5..44dcdef30 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp @@ -93,7 +93,7 @@ void VisToolPointOfIntersectionCircles::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::VisualMode(const quint32 &id) { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) this->object1Id = id; diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp index 140d5eb56..7c1fcff07 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp @@ -55,7 +55,7 @@ VisPieceSpecialPoints::VisPieceSpecialPoints(const VContainer *data, QGraphicsIt supportColor2(Qt::darkGreen) { m_rectItem = InitItem(supportColor2, this); - m_rectItem->SetWidth(qApp->Settings()->WidthHairLine()); + m_rectItem->SetWidth(VAbstractApplication::VApp()->Settings()->WidthHairLine()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp index bf1bc6780..c2383eb62 100644 --- a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp @@ -83,7 +83,7 @@ void VisToolPointOfIntersectionCurves::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCurves::VisualMode(const quint32 &id) { - auto scene = qobject_cast(qApp->getCurrentScene()); + auto scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) this->object1Id = id; diff --git a/src/libs/vtools/visualization/path/vistoolspline.cpp b/src/libs/vtools/visualization/path/vistoolspline.cpp index 30e6b3da0..227b9534b 100644 --- a/src/libs/vtools/visualization/path/vistoolspline.cpp +++ b/src/libs/vtools/visualization/path/vistoolspline.cpp @@ -88,7 +88,7 @@ VisToolSpline::~VisToolSpline() void VisToolSpline::RefreshGeometry() { //Radius of point circle, but little bigger. Need handle with hover sizes. - const static qreal radius = ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5; + const static qreal radius = ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5; if (object1Id > NULL_ID) { diff --git a/src/libs/vtools/visualization/path/vistoolsplinepath.cpp b/src/libs/vtools/visualization/path/vistoolsplinepath.cpp index d7daaaacc..51fe8eee0 100644 --- a/src/libs/vtools/visualization/path/vistoolsplinepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolsplinepath.cpp @@ -217,7 +217,8 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size) if (not ctrlPoints[lastPoint]->isVisible()) { //Radius of point circle, but little bigger. Need handle with hover sizes. - if (QLineF(pSpl, ctrlPoint).length() > ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5) + if (QLineF(pSpl, ctrlPoint).length() > + ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5) { if (size == 1) { diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index 9c75dc178..ce5ae0c3e 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -72,7 +72,7 @@ VScaledEllipse *InitPointItem(const QColor &color, QGraphicsItem *parent, qreal visPen.setColor(color); point->setPen(visPen); - point->setRect(PointRect(ScaledRadius(SceneScale(qApp->getCurrentScene())))); + point->setRect(PointRect(ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())))); point->setPos(QPointF()); point->setFlags(QGraphicsItem::ItemStacksBehindParent); point->setZValue(z); @@ -133,7 +133,7 @@ void Visualization::setScenePos(const QPointF &value) //--------------------------------------------------------------------------------------------------------------------- void Visualization::VisualMode(const quint32 &pointId) { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) this->object1Id = pointId; @@ -184,7 +184,7 @@ VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *par qreal Visualization::FindLengthFromUser(const QString &expression, const QHash > *vars, bool fromUser) { - return qApp->toPixel(FindValFromUser(expression, vars, fromUser)); + return VAbstractValApplication::VApp()->toPixel(FindValFromUser(expression, vars, fromUser)); } //--------------------------------------------------------------------------------------------------------------------- @@ -204,7 +204,8 @@ qreal Visualization::FindValFromUser(const QString &expression, QString formula = expression; if (fromUser) { - formula = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); + formula = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } QScopedPointer cal(new Calculator()); diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h index 8c7014411..95e87a044 100644 --- a/src/libs/vtools/visualization/visualization.h +++ b/src/libs/vtools/visualization/visualization.h @@ -125,7 +125,7 @@ template inline void Visualization::AddItem(Item *item) { SCASSERT(item != nullptr) - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->addItem(item); diff --git a/src/libs/vwidgets/global.cpp b/src/libs/vwidgets/global.cpp index 3545157de..bf033e730 100644 --- a/src/libs/vwidgets/global.cpp +++ b/src/libs/vwidgets/global.cpp @@ -39,7 +39,7 @@ const qreal minVisibleFontSize = 5; inline qreal DefPointRadiusPixel() { - return (qApp->Settings()->GetLineWidth() + 0.8) / 25.4 * PrintDPI; + return (VAbstractApplication::VApp()->Settings()->GetLineWidth() + 0.8) / 25.4 * PrintDPI; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/scalesceneitems.cpp b/src/libs/vwidgets/scalesceneitems.cpp index 172ec9e9c..ff056fff9 100644 --- a/src/libs/vwidgets/scalesceneitems.cpp +++ b/src/libs/vwidgets/scalesceneitems.cpp @@ -48,7 +48,8 @@ VScaledLine::VScaledLine(const QLineF &line, QGraphicsItem *parent) void VScaledLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QPen lPen = pen(); - const qreal width = ScaleWidth(m_isBoldLine ? qApp->Settings()->WidthMainLine() : qApp->Settings()->WidthHairLine(), + const qreal width = ScaleWidth(m_isBoldLine ? VAbstractApplication::VApp()->Settings()->WidthMainLine() + : VAbstractApplication::VApp()->Settings()->WidthHairLine(), SceneScale(scene())); lPen.setWidthF(qRound(width*100.)/100.); setPen(lPen); @@ -77,7 +78,7 @@ VScaledEllipse::VScaledEllipse(QGraphicsItem *parent) void VScaledEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { const qreal scale = SceneScale(scene()); - const qreal width = ScaleWidth(qApp->Settings()->WidthMainLine(), scale); + const qreal width = ScaleWidth(VAbstractApplication::VApp()->Settings()->WidthMainLine(), scale); QPen visPen = pen(); visPen.setWidthF(width); diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index 73ae710fa..ff5616f33 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -138,7 +138,7 @@ VAbstractMainWindow::VAbstractMainWindow(QWidget *parent) bool VAbstractMainWindow::ContinueFormatRewrite(const QString ¤tFormatVersion, const QString &maxFormatVersion) { - if (qApp->Settings()->GetConfirmFormatRewriting()) + if (VAbstractApplication::VApp()->Settings()->GetConfirmFormatRewriting()) { Utils::CheckableMessageBox msgBox(this); msgBox.setWindowTitle(tr("Confirm format rewriting")); @@ -154,7 +154,7 @@ bool VAbstractMainWindow::ContinueFormatRewrite(const QString ¤tFormatVers if (dialogResult == QDialog::Accepted) { - qApp->Settings()->SetConfirmFormatRewriting(not msgBox.isChecked()); + VAbstractApplication::VApp()->Settings()->SetConfirmFormatRewriting(not msgBox.isChecked()); return true; } else @@ -169,8 +169,8 @@ bool VAbstractMainWindow::ContinueFormatRewrite(const QString ¤tFormatVers void VAbstractMainWindow::ToolBarStyle(QToolBar *bar) const { SCASSERT(bar != nullptr) - qApp->Settings()->GetToolBarStyle() ? bar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon) - : bar->setToolButtonStyle(Qt::ToolButtonIconOnly); + VAbstractApplication::VApp()->Settings()->GetToolBarStyle() ? bar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon) + : bar->setToolButtonStyle(Qt::ToolButtonIconOnly); } //--------------------------------------------------------------------------------------------------------------------- @@ -181,7 +181,7 @@ QString VAbstractMainWindow::CSVFilePath() const QString path = QDir::homePath() + QChar('/') + tr("values") + QChar('.') + suffix; QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr, - qApp->NativeFileDialog()); + VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { @@ -222,7 +222,7 @@ void VAbstractMainWindow::UpdateRecentFileActions() //--------------------------------------------------------------------------------------------------------------------- void VAbstractMainWindow::WindowsLocale() { - qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); } //--------------------------------------------------------------------------------------------------------------------- @@ -236,17 +236,17 @@ void VAbstractMainWindow::ExportDataToCSV() } DialogExportToCSV dialog(this); - dialog.SetWithHeader(qApp->Settings()->GetCSVWithHeader()); - dialog.SetSelectedMib(qApp->Settings()->GetCSVCodec()); - dialog.SetSeparator(qApp->Settings()->GetCSVSeparator()); + dialog.SetWithHeader(VAbstractApplication::VApp()->Settings()->GetCSVWithHeader()); + dialog.SetSelectedMib(VAbstractApplication::VApp()->Settings()->GetCSVCodec()); + dialog.SetSeparator(VAbstractApplication::VApp()->Settings()->GetCSVSeparator()); if (dialog.exec() == QDialog::Accepted) { ExportToCSVData(fileName, dialog.IsWithHeader(), dialog.GetSelectedMib(), dialog.GetSeparator()); - qApp->Settings()->SetCSVSeparator(dialog.GetSeparator()); - qApp->Settings()->SetCSVCodec(dialog.GetSelectedMib()); - qApp->Settings()->SetCSVWithHeader(dialog.IsWithHeader()); + VAbstractApplication::VApp()->Settings()->SetCSVSeparator(dialog.GetSeparator()); + VAbstractApplication::VApp()->Settings()->SetCSVCodec(dialog.GetSelectedMib()); + VAbstractApplication::VApp()->Settings()->SetCSVWithHeader(dialog.IsWithHeader()); } } diff --git a/src/libs/vwidgets/vcurvepathitem.cpp b/src/libs/vwidgets/vcurvepathitem.cpp index a35098a28..e25f6f8c8 100644 --- a/src/libs/vwidgets/vcurvepathitem.cpp +++ b/src/libs/vwidgets/vcurvepathitem.cpp @@ -38,7 +38,7 @@ VCurvePathItem::VCurvePathItem(QGraphicsItem *parent) : QGraphicsPathItem(parent), m_directionArrows(), m_points(), - m_defaultWidth(qApp->Settings()->WidthMainLine()) + m_defaultWidth(VAbstractApplication::VApp()->Settings()->WidthMainLine()) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/vgrainlineitem.cpp b/src/libs/vwidgets/vgrainlineitem.cpp index d564f896c..d6437afa9 100644 --- a/src/libs/vwidgets/vgrainlineitem.cpp +++ b/src/libs/vwidgets/vgrainlineitem.cpp @@ -70,7 +70,7 @@ VGrainlineItem::VGrainlineItem(QGraphicsItem* pParent) m_ptCenter(), m_dAngle(0), m_eArrowType(GrainlineArrowDirection::atBoth), - m_penWidth(qApp->Settings()->WidthMainLine()) + m_penWidth(VAbstractApplication::VApp()->Settings()->WidthMainLine()) { setAcceptHoverEvents(true); m_inactiveZ = 5; @@ -107,7 +107,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption pP->save(); QColor clr = Qt::black; - const qreal width = ScaleWidth(qApp->Settings()->WidthHairLine(), SceneScale(scene())); + const qreal width = ScaleWidth(VAbstractApplication::VApp()->Settings()->WidthHairLine(), SceneScale(scene())); pP->setPen(QPen(clr, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); pP->setRenderHints(QPainter::Antialiasing); @@ -528,7 +528,7 @@ void VGrainlineItem::hoverEnterEvent(QGraphicsSceneHoverEvent *pME) if (flags() & QGraphicsItem::ItemIsMovable) { SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); - m_penWidth = qApp->Settings()->WidthMainLine() + 1; + m_penWidth = VAbstractApplication::VApp()->Settings()->WidthMainLine() + 1; } VPieceItem::hoverEnterEvent(pME); } @@ -538,7 +538,7 @@ void VGrainlineItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *pME) { if (flags() & QGraphicsItem::ItemIsMovable) { - m_penWidth = qApp->Settings()->WidthMainLine(); + m_penWidth = VAbstractApplication::VApp()->Settings()->WidthMainLine(); } VPieceItem::hoverLeaveEvent(pME); } diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index 33659fd00..3c3167b0a 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -91,9 +91,9 @@ void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic }; QFont font = this->font(); - if (font.pointSize() != qApp->Settings()->GetLabelFontSize()) + if (font.pointSize() != VAbstractApplication::VApp()->Settings()->GetLabelFontSize()) { - font.setPointSize(qApp->Settings()->GetLabelFontSize()); + font.setPointSize(VAbstractApplication::VApp()->Settings()->GetLabelFontSize()); setFont(font); } @@ -239,7 +239,7 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) } else { - setCursor(qApp->getSceneView()->viewport()->cursor()); + setCursor(VAbstractValApplication::VApp()->getSceneView()->viewport()->cursor()); } this->setBrush(Qt::green); @@ -369,8 +369,8 @@ void VGraphicsSimpleTextItem::Init() this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus this->setAcceptHoverEvents(true); QFont font = this->font(); - font.setPointSize(qApp->Settings()->GetLabelFontSize()); + font.setPointSize(VAbstractApplication::VApp()->Settings()->GetLabelFontSize()); setFont(font); - m_oldScale = minVisibleFontSize / qApp->Settings()->GetLabelFontSize(); + m_oldScale = minVisibleFontSize / VAbstractApplication::VApp()->Settings()->GetLabelFontSize(); setScale(m_oldScale); } diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 480cdf400..a12fed05e 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -71,7 +71,7 @@ qreal ScrollingSteps(QWheelEvent* wheel_event) const QPoint numPixels = wheel_event->pixelDelta(); const QPoint numDegrees = wheel_event->angleDelta() / 8; qreal numSteps = 0; - VSettings *settings = qobject_cast(qApp->Settings()); + VSettings *settings = qobject_cast(VAbstractApplication::VApp()->Settings()); if (not numPixels.isNull()) { @@ -106,7 +106,8 @@ qreal PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event) scheduledScrollings += numSteps; } - scheduledScrollings *= qobject_cast(qApp->Settings())->GetScrollingAcceleration(); + scheduledScrollings *= + qobject_cast(VAbstractApplication::VApp()->Settings())->GetScrollingAcceleration(); return scheduledScrollings; } @@ -198,7 +199,7 @@ void GraphicsViewZoom::set_zoom_factor_base(double value) //--------------------------------------------------------------------------------------------------------------------- void GraphicsViewZoom::InitScrollingAnimation() { - VSettings *settings = qobject_cast(qApp->Settings()); + VSettings *settings = qobject_cast(VAbstractApplication::VApp()->Settings()); if (not verticalScrollAnim.isNull()) { @@ -429,7 +430,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent) m_oldCursor(), m_currentCursor(Qt::ArrowCursor) { - VSettings *settings = qobject_cast(qApp->Settings()); + VSettings *settings = qobject_cast(VAbstractApplication::VApp()->Settings()); if (settings && settings->IsOpenGLRender()) { QOpenGLWidget *viewport = new QOpenGLWidget(); @@ -643,7 +644,8 @@ void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VMainGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton && qApp->Settings()->IsDoubleClickZoomFitBestCurrentPP()) + if (event->button() == Qt::LeftButton && + VAbstractApplication::VApp()->Settings()->IsDoubleClickZoomFitBestCurrentPP()) { emit ZoomFitBestCurrent(); } diff --git a/src/libs/vwidgets/vnobrushscalepathitem.cpp b/src/libs/vwidgets/vnobrushscalepathitem.cpp index f2a072779..f8f09376d 100644 --- a/src/libs/vwidgets/vnobrushscalepathitem.cpp +++ b/src/libs/vwidgets/vnobrushscalepathitem.cpp @@ -37,7 +37,7 @@ //--------------------------------------------------------------------------------------------------------------------- VNoBrushScalePathItem::VNoBrushScalePathItem(QGraphicsItem *parent) : QGraphicsPathItem(parent), - m_defaultWidth(qApp->Settings()->WidthHairLine()) + m_defaultWidth(VAbstractApplication::VApp()->Settings()->WidthHairLine()) { } diff --git a/src/libs/vwidgets/vscenepoint.cpp b/src/libs/vwidgets/vscenepoint.cpp index 2cf30a48c..5c7d2aa12 100644 --- a/src/libs/vwidgets/vscenepoint.cpp +++ b/src/libs/vwidgets/vscenepoint.cpp @@ -66,7 +66,8 @@ void VScenePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio { const qreal scale = SceneScale(scene()); - if (qApp->Settings()->GetLabelFontSize()*scale < minVisibleFontSize || qApp->Settings()->GetHideLabels()) + if (VAbstractApplication::VApp()->Settings()->GetLabelFontSize()*scale < minVisibleFontSize || + VAbstractApplication::VApp()->Settings()->GetHideLabels()) { m_namePoint->setVisible(false); m_lineName->setVisible(false); @@ -175,7 +176,8 @@ void VScenePoint::RefreshLine() //--------------------------------------------------------------------------------------------------------------------- void VScenePoint::ScaleMainPenWidth(qreal scale) { - const qreal width = ScaleWidth(m_isHovered ? qApp->Settings()->WidthMainLine() : qApp->Settings()->WidthHairLine(), + const qreal width = ScaleWidth(m_isHovered ? VAbstractApplication::VApp()->Settings()->WidthMainLine() + : VAbstractApplication::VApp()->Settings()->WidthHairLine(), scale); setPen(QPen(CorrectColor(this, m_baseColor), width)); diff --git a/src/libs/vwidgets/vsimplecurve.cpp b/src/libs/vwidgets/vsimplecurve.cpp index 22e11f316..7c434600b 100644 --- a/src/libs/vwidgets/vsimplecurve.cpp +++ b/src/libs/vwidgets/vsimplecurve.cpp @@ -175,7 +175,8 @@ void VSimpleCurve::keyReleaseEvent(QKeyEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VSimpleCurve::ScalePenWidth() { - qreal width = m_isHovered ? qApp->Settings()->WidthMainLine() : qApp->Settings()->WidthHairLine(); + qreal width = m_isHovered ? VAbstractApplication::VApp()->Settings()->WidthMainLine() + : VAbstractApplication::VApp()->Settings()->WidthHairLine(); width = ScaleWidth(width, SceneScale(scene())); setPen(QPen(CorrectColor(this, m_curve->GetColor()), width, LineStyleToPenStyle(m_curve->GetPenStyle()))); } diff --git a/src/test/CollectionTest/CollectionTest.pro b/src/test/CollectionTest/CollectionTest.pro index 8d1262865..dbde17e42 100644 --- a/src/test/CollectionTest/CollectionTest.pro +++ b/src/test/CollectionTest/CollectionTest.pro @@ -126,16 +126,7 @@ DEPENDPATH += $$PWD/../../libs/vformat win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a -# VLayout static library (depend on IFC, VGeometry, VPatternDB) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout - -INCLUDEPATH += $$PWD/../../libs/vlayout -DEPENDPATH += $$PWD/../../libs/vlayout - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a - -#VPatternDB static library (depend on vgeometry, vmisc) +#VPatternDB static library (depend on vgeometry, vmisc, VLayout) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb INCLUDEPATH += $$PWD/../../libs/vpatterndb @@ -144,6 +135,15 @@ DEPENDPATH += $$PWD/../../libs/vpatterndb win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a +# VLayout static library (depend on IFC, VGeometry) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout + +INCLUDEPATH += $$PWD/../../libs/vlayout +DEPENDPATH += $$PWD/../../libs/vlayout + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + # VGeometry static library (depend on ifc) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR} -lvgeometry diff --git a/src/test/TranslationsTest/TranslationsTest.pro b/src/test/TranslationsTest/TranslationsTest.pro index 5ef2c3862..919ae2f77 100644 --- a/src/test/TranslationsTest/TranslationsTest.pro +++ b/src/test/TranslationsTest/TranslationsTest.pro @@ -111,16 +111,7 @@ DEPENDPATH += $$PWD/../../libs/vtest win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtest/$${DESTDIR}/vtest.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtest/$${DESTDIR}/libvtest.a -# VLayout static library (depend on IFC, VGeometry, VPatternDB) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout - -INCLUDEPATH += $$PWD/../../libs/vlayout -DEPENDPATH += $$PWD/../../libs/vlayout - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a - -#VPatternDB static library (depend on vgeometry, vmisc) +#VPatternDB static library (depend on vgeometry, vmisc, VLayout) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb INCLUDEPATH += $$PWD/../../libs/vpatterndb @@ -129,6 +120,15 @@ DEPENDPATH += $$PWD/../../libs/vpatterndb win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a +# VLayout static library (depend on IFC, VGeometry) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout + +INCLUDEPATH += $$PWD/../../libs/vlayout +DEPENDPATH += $$PWD/../../libs/vlayout + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + ## VGeometry static library (depend on ifc) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR} -lvgeometry diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index 7cff6b9be..360a4852c 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -168,16 +168,7 @@ DEPENDPATH += $$PWD/../../libs/vformat win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a -# VLayout static library (depend on IFC, VGeometry, VPatternDB) -unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout - -INCLUDEPATH += $$PWD/../../libs/vlayout -DEPENDPATH += $$PWD/../../libs/vlayout - -win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib -else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a - -#VPatternDB static library (depend on vgeometry, vmisc) +#VPatternDB static library (depend on vgeometry, vmisc, VLayout) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb INCLUDEPATH += $$PWD/../../libs/vpatterndb @@ -186,6 +177,15 @@ DEPENDPATH += $$PWD/../../libs/vpatterndb win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a +# VLayout static library (depend on IFC, VGeometry) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout + +INCLUDEPATH += $$PWD/../../libs/vlayout +DEPENDPATH += $$PWD/../../libs/vlayout + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + # VGeometry static library (depend on ifc, VMisc) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR} -lvgeometry diff --git a/src/test/ValentinaTest/tst_vpiece.cpp b/src/test/ValentinaTest/tst_vpiece.cpp index 26f816a35..b96923e24 100644 --- a/src/test/ValentinaTest/tst_vpiece.cpp +++ b/src/test/ValentinaTest/tst_vpiece.cpp @@ -51,7 +51,7 @@ void TST_VPiece::Issue620() // Check main path const Unit unit = Unit::Cm; QSharedPointer data(new VContainer(nullptr, &unit, VContainer::UniqueNamespace())); - qApp->SetPatternUnits(unit); + VAbstractValApplication::VApp()->SetPatternUnits(unit); VPiece detail; AbstractTest::PieceFromJson(QStringLiteral("://Issue_620/input.json"), detail, data); diff --git a/src/test/ValentinaTest/tst_vtranslatevars.cpp b/src/test/ValentinaTest/tst_vtranslatevars.cpp index 8e49de21d..31062c8f9 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.cpp +++ b/src/test/ValentinaTest/tst_vtranslatevars.cpp @@ -45,7 +45,7 @@ TST_VTranslateVars::TST_VTranslateVars(QObject *parent) void TST_VTranslateVars::initTestCase() { m_trMs = new VTranslateVars(); - qApp->SetTrVars(m_trMs); + TestVApplication::VApp()->SetTrVars(m_trMs); } //---------------------------------------------------------------------------------------------------------------------