Show dialog "Fix broken formula" only in GUI mode.
--HG-- branch : develop
This commit is contained in:
parent
8b7602e223
commit
d227ce68c2
|
@ -322,6 +322,15 @@ bool MApplication::IsTestMode() const
|
|||
return testMode;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication class.
|
||||
*/
|
||||
bool MApplication::IsAppInGUIMode() const
|
||||
{
|
||||
return IsTestMode();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
TMainWindow *MApplication::MainWindow()
|
||||
{
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
virtual bool notify(QObject * receiver, QEvent * event) Q_DECL_OVERRIDE;
|
||||
|
||||
bool IsTestMode() const;
|
||||
virtual bool IsAppInGUIMode() const;
|
||||
TMainWindow *MainWindow();
|
||||
QList<TMainWindow*> MainWindows();
|
||||
|
||||
|
|
|
@ -671,6 +671,15 @@ bool VApplication::IsGUIMode()
|
|||
return (VCommandLine::instance != nullptr) && VCommandLine::instance->IsGuiEnabled();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication class.
|
||||
*/
|
||||
bool VApplication::IsAppInGUIMode() const
|
||||
{
|
||||
return IsGUIMode();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const VCommandLinePtr VApplication::CommandLine() const
|
||||
{
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
void CollectReports() const;
|
||||
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
bool static IsGUIMode();
|
||||
virtual bool IsAppInGUIMode() const;
|
||||
|
||||
virtual void OpenSettings() Q_DECL_OVERRIDE;
|
||||
VSettings *ValentinaSettings();
|
||||
|
|
|
@ -94,6 +94,8 @@ public:
|
|||
|
||||
QUndoStack *getUndoStack() const;
|
||||
|
||||
virtual bool IsAppInGUIMode()const =0;
|
||||
|
||||
protected slots:
|
||||
void SyncSettings();
|
||||
|
||||
|
|
|
@ -299,6 +299,8 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
|
|||
<< "--------------------------------------";
|
||||
delete cal;
|
||||
|
||||
if (qApp->IsAppInGUIMode())
|
||||
{
|
||||
DialogUndo *dialogUndo = new DialogUndo(qApp->getMainWindow());
|
||||
forever
|
||||
{
|
||||
|
@ -307,7 +309,8 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
|
|||
const UndoButton resultUndo = dialogUndo->Result();
|
||||
if (resultUndo == UndoButton::Fix)
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow());
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId,
|
||||
qApp->getMainWindow());
|
||||
dialog->setWindowTitle(tr("Edit wrong formula"));
|
||||
dialog->SetFormula(formula);
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
|
@ -318,8 +321,8 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
|
|||
delete dialog;
|
||||
Calculator *cal1 = new Calculator();
|
||||
result = cal1->EvalFormula(data->PlainVariables(), formula);
|
||||
delete cal1; /* Here can be memory leak, but dialog already check this formula and probability
|
||||
* very low. */
|
||||
delete cal1; /* Here can be memory leak, but dialog already check this formula and
|
||||
probability very low. */
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -340,6 +343,11 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
|
|||
}
|
||||
delete dialogUndo;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,8 @@ VALENTINA_TEST_FILES += \
|
|||
tst_valentina/issue_256_correct.vit \
|
||||
tst_valentina/issue_256_wrong.vit \
|
||||
tst_valentina/issue_256_correct.vst \
|
||||
tst_valentina/issue_256_wrong.vit
|
||||
tst_valentina/issue_256_wrong.vit \
|
||||
tst_valentina/wrong_formula.val
|
||||
|
||||
COLLECTION_FILES += \
|
||||
$${PWD}/../../app/share/tables/standard/GOST_man_ru.vst \
|
||||
|
|
37
src/test/ValentinaTest/tst_valentina/wrong_formula.val
Normal file
37
src/test/ValentinaTest/tst_valentina/wrong_formula.val
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<pattern>
|
||||
<!--Pattern created with Valentina (http://www.valentina-project.org/).-->
|
||||
<version>0.2.2</version>
|
||||
<unit>cm</unit>
|
||||
<author/>
|
||||
<description/>
|
||||
<notes/>
|
||||
<measurements>issue_256_correct.vit</measurements>
|
||||
<increments/>
|
||||
<draw name="Pattern piece 1">
|
||||
<calculation>
|
||||
<point type="single" x="1.34938" y="1.24354" id="1" name="A" mx="0.132292" my="0.264583"/>
|
||||
<point type="endLine" typeLine="hair" id="2" name="A1" basePoint="1" mx="0.175422" lineColor="black" angle="0" my="0.27896" length="height_scapula/10+"/>
|
||||
<point type="endLine" typeLine="hair" id="3" name="A2" basePoint="1" mx="0.132292" lineColor="black" angle="269.719" my="0.264583" length="Line_A_A1"/>
|
||||
<point type="pointOfIntersection" id="4" name="A3" firstPoint="2" secondPoint="3" mx="0.132292" my="0.264583"/>
|
||||
<line typeLine="hair" id="5" firstPoint="3" secondPoint="4" lineColor="black"/>
|
||||
<line typeLine="hair" id="6" firstPoint="2" secondPoint="4" lineColor="black"/>
|
||||
</calculation>
|
||||
<modeling>
|
||||
<point type="modeling" id="7" idObject="1" mx="0.0264587" my="0.291041"/>
|
||||
<point type="modeling" id="8" idObject="2" mx="-1.85208" my="0.264583"/>
|
||||
<point type="modeling" id="9" idObject="4" mx="-2.03729" my="-1.71979"/>
|
||||
<point type="modeling" id="10" idObject="3" mx="0.47625" my="-1.95792"/>
|
||||
<point type="modeling" id="11" idObject="1" mx="0.0264587" my="0.291041"/>
|
||||
</modeling>
|
||||
<details>
|
||||
<detail closed="1" id="12" name="Detail" supplement="1" width="1" mx="0.185208" my="-0.079375">
|
||||
<node type="NodePoint" nodeType="Contour" idObject="7" mx="0" my="0"/>
|
||||
<node type="NodePoint" nodeType="Contour" idObject="8" mx="0" my="0"/>
|
||||
<node type="NodePoint" nodeType="Contour" idObject="9" mx="0" my="0"/>
|
||||
<node type="NodePoint" nodeType="Contour" idObject="10" mx="0" my="0"/>
|
||||
<node type="NodePoint" nodeType="Contour" idObject="11" mx="0" my="0"/>
|
||||
</detail>
|
||||
</details>
|
||||
</draw>
|
||||
</pattern>
|
|
@ -220,6 +220,11 @@ void TST_ValentinaCommandLine::TestMode_data() const
|
|||
QLatin1Literal("issue_256_wrong.vst"))
|
||||
<< false
|
||||
<< V_EX_NOINPUT;
|
||||
|
||||
QTest::newRow("Wrong formula.")<< "wrong_formula.val"
|
||||
<< QString("--test")
|
||||
<< false
|
||||
<< V_EX_DATAERR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user