Merge with develop
--HG-- branch : DialogTools
This commit is contained in:
commit
f14d21b7da
7
dist/valentina.desktop
vendored
7
dist/valentina.desktop
vendored
|
@ -1,10 +1,13 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Valentina
|
||||
Exec=valentina %U
|
||||
Version=1.0
|
||||
Encoding=UTF-8
|
||||
GenericName=Pattern making program
|
||||
Comment=Open source project of creating a pattern making program, whose allow create and modeling patterns of clothing
|
||||
Icon=valentina
|
||||
Exec=valentina
|
||||
Terminal=false
|
||||
MimeType=text/val;
|
||||
Categories=Graphics;VectorGraphics;2DGraphics;
|
||||
Version=1.0
|
||||
Name[uk]=valentina
|
||||
|
|
|
@ -49,6 +49,9 @@ Calculator::Calculator(const VContainer *data)
|
|||
DefinePostfixOprt(cm_Oprt, CmUnit);
|
||||
DefinePostfixOprt(mm_Oprt, MmUnit);
|
||||
DefinePostfixOprt(in_Oprt, InchUnit);
|
||||
|
||||
SetArgSep(',');
|
||||
SetDecSep('.');
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -65,7 +68,7 @@ Calculator::Calculator(const QString &formula, bool fromUser)
|
|||
DefinePostfixOprt(qApp->PostfixOperator(mm_Oprt), MmUnit);
|
||||
DefinePostfixOprt(qApp->PostfixOperator(in_Oprt), InchUnit);
|
||||
|
||||
QLocale loc = QLocale();
|
||||
QLocale loc = QLocale::system();
|
||||
SetDecSep(loc.decimalPoint().toLatin1());
|
||||
SetThousandsSep(loc.groupSeparator().toLatin1());
|
||||
SetArgSep(';');
|
||||
|
@ -75,6 +78,9 @@ Calculator::Calculator(const QString &formula, bool fromUser)
|
|||
DefinePostfixOprt(cm_Oprt, CmUnit);
|
||||
DefinePostfixOprt(mm_Oprt, MmUnit);
|
||||
DefinePostfixOprt(in_Oprt, InchUnit);
|
||||
|
||||
SetArgSep(',');
|
||||
SetDecSep('.');
|
||||
}
|
||||
|
||||
SetExpr(formula);
|
||||
|
|
|
@ -122,7 +122,7 @@ void DialogEndLine::setFormula(const QString &value)
|
|||
{
|
||||
this->DeployFormulaTextEdit();
|
||||
}
|
||||
ui->plainTextEditFormula->setPlainText(value);
|
||||
ui->plainTextEditFormula->setPlainText(formula);
|
||||
//QTextCursor cursor = ui->plainTextEditFormula->textCursor();
|
||||
//cursor.insertText(value);
|
||||
//ui->plainTextEditFormula->setCursor(cursor);
|
||||
|
|
|
@ -377,7 +377,8 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
|
|||
Calculator cal(data);
|
||||
const qreal result = cal.EvalFormula(formula);
|
||||
|
||||
label->setText(QString().setNum(result));
|
||||
QLocale loc = QLocale::system();
|
||||
label->setText(loc.toString(result));
|
||||
flag = true;
|
||||
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
||||
emit ToolTip("");
|
||||
|
@ -424,7 +425,8 @@ void DialogTool::Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *l
|
|||
Calculator cal(data);
|
||||
const qreal result = cal.EvalFormula(formula);
|
||||
|
||||
label->setText(QString().setNum(result));
|
||||
QLocale loc = QLocale::system();
|
||||
label->setText(loc.toString(result));
|
||||
flag = true;
|
||||
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
||||
emit ToolTip("");
|
||||
|
|
|
@ -47,6 +47,10 @@
|
|||
#include <QSourceLocation>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief MainWindow constructor.
|
||||
* @param parent parent widget.
|
||||
*/
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Valentina::ArrowTool),
|
||||
currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr),
|
||||
|
@ -67,6 +71,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
||||
view = new VMainGraphicsView();
|
||||
ui->LayoutView->addWidget(view);
|
||||
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
view->setScene(currentScene);
|
||||
|
||||
sceneDraw->setTransform(view->transform());
|
||||
|
@ -94,6 +100,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ActionNewDraw add to scene new pattern peace.
|
||||
*/
|
||||
void MainWindow::ActionNewDraw()
|
||||
{
|
||||
QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1);
|
||||
|
@ -183,6 +192,9 @@ void MainWindow::ActionNewDraw()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief OptionDraw help change name of pattern peace.
|
||||
*/
|
||||
void MainWindow::OptionDraw()
|
||||
{
|
||||
const QString activDraw = doc->GetNameActivDraw();
|
||||
|
@ -202,6 +214,14 @@ void MainWindow::OptionDraw()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetToolButton set tool and show dialog.
|
||||
* @param checked true if tool button checked.
|
||||
* @param t tool type.
|
||||
* @param cursor path tool cursor icon.
|
||||
* @param toolTip first tooltipe.
|
||||
* @param closeDialogSlot function what handle after close dialog.
|
||||
*/
|
||||
// TODO Issue 79 : remove function
|
||||
template <typename Dialog, typename Func>
|
||||
void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
|
||||
|
@ -234,6 +254,15 @@ void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// TODO Issue 79 : rename to SetToolButton
|
||||
template <typename Dialog, typename Func, typename Func2>
|
||||
/**
|
||||
* @brief SetToolButton set tool and show dialog.
|
||||
* @param checked true if tool button checked.
|
||||
* @param t tool type.
|
||||
* @param cursor path tool cursor icon.
|
||||
* @param toolTip first tooltipe.
|
||||
* @param closeDialogSlot function to handle close of dialog.
|
||||
* @param applyDialogSlot function to handle apply in dialog.
|
||||
*/
|
||||
void MainWindow::SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
|
||||
Func closeDialogSlot, Func2 applyDialogSlot)
|
||||
{
|
||||
|
@ -262,6 +291,10 @@ void MainWindow::SetToolButton2(bool checked, Valentina::Tools t, const QString
|
|||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialog handle close dialog
|
||||
* @param result result working dialog.
|
||||
*/
|
||||
template <typename DrawTool>
|
||||
void MainWindow::ClosedDialog(int result)
|
||||
{// TODO ISSUE 79 : delete
|
||||
|
@ -274,9 +307,14 @@ void MainWindow::ClosedDialog(int result)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialog handle close dialog
|
||||
* @param result result working dialog.
|
||||
*/
|
||||
// TODO ISSUE 79 : rename
|
||||
template <typename DrawTool>
|
||||
void MainWindow::ClosedDialog2(int result)
|
||||
{ // TODO ISSUE 79 : rename
|
||||
{
|
||||
Q_CHECK_PTR(dialogTool);
|
||||
if (result == QDialog::Accepted)
|
||||
{
|
||||
|
@ -301,6 +339,9 @@ void MainWindow::ClosedDialog2(int result)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ApplyDialog handle apply in dialog
|
||||
*/
|
||||
template <typename DrawTool>
|
||||
void MainWindow::ApplyDialog()
|
||||
{// TODO ISSUE 79 : copy
|
||||
|
@ -320,6 +361,10 @@ void MainWindow::ApplyDialog()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolEndLine handler tool endLine.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolEndLine(bool checked)
|
||||
{// TODO ISSUE 79 : copy
|
||||
// SetToolButton<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
|
||||
|
@ -329,18 +374,29 @@ void MainWindow::ToolEndLine(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/** // TODO ISSUE 79 : copy
|
||||
* @brief ApplyDialogEndLine actions after apply in DialogEndLine.
|
||||
*/
|
||||
void MainWindow::ApplyDialogEndLine()
|
||||
{ // TODO ISSUE 79 : copy
|
||||
ApplyDialog<VToolEndLine>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogEndLine actions after closing DialogEndLine.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogEndLine(int result)
|
||||
{
|
||||
ClosedDialog2<VToolEndLine>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolLine handler tool line.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolLine(bool checked)
|
||||
{
|
||||
SetToolButton<DialogLine>(checked, Valentina::LineTool, ":/cursor/line_cursor.png", tr("Select first point"),
|
||||
|
@ -348,12 +404,20 @@ void MainWindow::ToolLine(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogLine actions after closing DialogLine.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogLine(int result)
|
||||
{
|
||||
ClosedDialog<VToolLine>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolAlongLine handler tool alongLine.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolAlongLine(bool checked)
|
||||
{
|
||||
SetToolButton<DialogAlongLine>(checked, Valentina::AlongLineTool, ":/cursor/alongline_cursor.png",
|
||||
|
@ -361,12 +425,20 @@ void MainWindow::ToolAlongLine(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogAlongLine actions after closing DialogAlongLine.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogAlongLine(int result)
|
||||
{
|
||||
ClosedDialog<VToolAlongLine>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolShoulderPoint handler tool shoulderPoint.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolShoulderPoint(bool checked)
|
||||
{
|
||||
SetToolButton<DialogShoulderPoint>(checked, Valentina::ShoulderPointTool, ":/cursor/shoulder_cursor.png",
|
||||
|
@ -374,12 +446,20 @@ void MainWindow::ToolShoulderPoint(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogShoulderPoint actions after closing DialogShoulderPoint.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogShoulderPoint(int result)
|
||||
{
|
||||
ClosedDialog<VToolShoulderPoint>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolNormal handler tool normal.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolNormal(bool checked)
|
||||
{
|
||||
SetToolButton<DialogNormal>(checked, Valentina::NormalTool, ":/cursor/normal_cursor.png",
|
||||
|
@ -387,12 +467,20 @@ void MainWindow::ToolNormal(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogNormal actions after closing DialogNormal.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogNormal(int result)
|
||||
{
|
||||
ClosedDialog<VToolNormal>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolBisector handler tool bisector.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolBisector(bool checked)
|
||||
{
|
||||
SetToolButton<DialogBisector>(checked, Valentina::BisectorTool, ":/cursor/bisector_cursor.png",
|
||||
|
@ -400,12 +488,20 @@ void MainWindow::ToolBisector(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogBisector actions after closing DialogBisector.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogBisector(int result)
|
||||
{
|
||||
ClosedDialog<VToolBisector>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolLineIntersect handler tool lineIntersect.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolLineIntersect(bool checked)
|
||||
{
|
||||
SetToolButton<DialogLineIntersect>(checked, Valentina::LineIntersectTool, ":/cursor/intersect_cursor.png",
|
||||
|
@ -413,12 +509,20 @@ void MainWindow::ToolLineIntersect(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogLineIntersect actions after closing DialogLineIntersect.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogLineIntersect(int result)
|
||||
{
|
||||
ClosedDialog<VToolLineIntersect>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolSpline handler tool spline.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolSpline(bool checked)
|
||||
{
|
||||
SetToolButton<DialogSpline>(checked, Valentina::SplineTool, ":/cursor/spline_cursor.png",
|
||||
|
@ -426,12 +530,20 @@ void MainWindow::ToolSpline(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogSpline actions after closing DialogSpline.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogSpline(int result)
|
||||
{
|
||||
ClosedDialog<VToolSpline>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolCutSpline handler tool CutSpline.
|
||||
* @param checked true - button is checked
|
||||
*/
|
||||
void MainWindow::ToolCutSpline(bool checked)
|
||||
{
|
||||
SetToolButton<DialogCutSpline>(checked, Valentina::CutSplineTool, ":/cursor/spline_cut_point_cursor.png",
|
||||
|
@ -439,12 +551,20 @@ void MainWindow::ToolCutSpline(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogCutSpline actions after closing DialogCutSpline.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogCutSpline(int result)
|
||||
{
|
||||
ClosedDialog<VToolCutSpline>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolArc handler tool arc.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolArc(bool checked)
|
||||
{
|
||||
SetToolButton<DialogArc>(checked, Valentina::ArcTool, ":/cursor/arc_cursor.png",
|
||||
|
@ -452,12 +572,20 @@ void MainWindow::ToolArc(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogArc actions after closing DialogArc.
|
||||
* @param result result of dialog working..
|
||||
*/
|
||||
void MainWindow::ClosedDialogArc(int result)
|
||||
{
|
||||
ClosedDialog<VToolArc>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolSplinePath handler tool splinePath.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolSplinePath(bool checked)
|
||||
{
|
||||
SetToolButton<DialogSplinePath>(checked, Valentina::SplinePathTool, ":/cursor/splinepath_cursor.png",
|
||||
|
@ -465,12 +593,20 @@ void MainWindow::ToolSplinePath(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogSplinePath actions after closing DialogSplinePath.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogSplinePath(int result)
|
||||
{
|
||||
ClosedDialog<VToolSplinePath>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolCutSplinePath handler tool CutSplinePath.
|
||||
* @param checked true - button is checked
|
||||
*/
|
||||
void MainWindow::ToolCutSplinePath(bool checked)
|
||||
{
|
||||
SetToolButton<DialogCutSplinePath>(checked, Valentina::CutSplinePathTool,
|
||||
|
@ -479,12 +615,20 @@ void MainWindow::ToolCutSplinePath(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogCutSplinePath actions after closing DialogCutSplinePath.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogCutSplinePath(int result)
|
||||
{
|
||||
ClosedDialog<VToolCutSplinePath>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolPointOfContact handler tool pointOfContact.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolPointOfContact(bool checked)
|
||||
{
|
||||
SetToolButton<DialogPointOfContact>(checked, Valentina::PointOfContact, ":/cursor/pointcontact_cursor.png",
|
||||
|
@ -492,12 +636,20 @@ void MainWindow::ToolPointOfContact(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogPointOfContact actions after closing DialogPointOfContact.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogPointOfContact(int result)
|
||||
{
|
||||
ClosedDialog<VToolPointOfContact>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolDetail handler tool detail.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolDetail(bool checked)
|
||||
{
|
||||
SetToolButton<DialogDetail>(checked, Valentina::DetailTool, "://cursor/new_detail_cursor.png",
|
||||
|
@ -505,6 +657,10 @@ void MainWindow::ToolDetail(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogDetail actions after closing DialogDetail.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogDetail(int result)
|
||||
{
|
||||
if (result == QDialog::Accepted)
|
||||
|
@ -516,6 +672,10 @@ void MainWindow::ClosedDialogDetail(int result)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolHeight handler tool height.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolHeight(bool checked)
|
||||
{
|
||||
SetToolButton<DialogHeight>(checked, Valentina::Height, ":/cursor/height_cursor.png", tr("Select base point"),
|
||||
|
@ -523,12 +683,20 @@ void MainWindow::ToolHeight(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogHeight actions after closing DialogHeight.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogHeight(int result)
|
||||
{
|
||||
ClosedDialog<VToolHeight>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolTriangle handler tool triangle.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolTriangle(bool checked)
|
||||
{
|
||||
SetToolButton<DialogTriangle>(checked, Valentina::Triangle, ":/cursor/triangle_cursor.png",
|
||||
|
@ -536,12 +704,20 @@ void MainWindow::ToolTriangle(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogTriangle actions after closing DialogTriangle.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogTriangle(int result)
|
||||
{
|
||||
ClosedDialog<VToolTriangle>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolPointOfIntersection handler tool pointOfIntersection.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolPointOfIntersection(bool checked)
|
||||
{
|
||||
SetToolButton<DialogPointOfIntersection>(checked, Valentina::PointOfIntersection,
|
||||
|
@ -550,12 +726,20 @@ void MainWindow::ToolPointOfIntersection(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogPointOfIntersection actions after closing DialogPointOfIntersection.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogPointOfIntersection(int result)
|
||||
{
|
||||
ClosedDialog<VToolPointOfIntersection>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolUnionDetails handler tool unionDetails.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolUnionDetails(bool checked)
|
||||
{
|
||||
SetToolButton<DialogUnionDetails>(checked, Valentina::UnionDetails, ":/cursor/union_cursor.png",
|
||||
|
@ -565,6 +749,10 @@ void MainWindow::ToolUnionDetails(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogUnionDetails actions after closing DialogUnionDetails.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogUnionDetails(int result)
|
||||
{
|
||||
ClosedDialog<VToolUnionDetails>(result);
|
||||
|
@ -572,6 +760,10 @@ void MainWindow::ClosedDialogUnionDetails(int result)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolCutArc handler tool cutArc.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ToolCutArc(bool checked)
|
||||
{
|
||||
SetToolButton<DialogCutArc>(checked, Valentina::CutArcTool, ":/cursor/arc_cut_cursor.png", tr("Select arc"),
|
||||
|
@ -579,12 +771,19 @@ void MainWindow::ToolCutArc(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedDialogCutArc actions after closing DialogCutArc.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void MainWindow::ClosedDialogCutArc(int result)
|
||||
{
|
||||
ClosedDialog<VToolCutArc>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief About show widows about.
|
||||
*/
|
||||
void MainWindow::About()
|
||||
{
|
||||
DialogAboutApp * about_dialog = new DialogAboutApp(this);
|
||||
|
@ -593,18 +792,28 @@ void MainWindow::About()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AboutQt show widows aboutQt.
|
||||
*/
|
||||
void MainWindow::AboutQt()
|
||||
{
|
||||
QMessageBox::aboutQt(this, tr("About Qt"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ShowTool highlight tool.Tip show tools tooltip.
|
||||
* @param toolTip tooltip text.
|
||||
*/
|
||||
void MainWindow::ShowToolTip(const QString &toolTip)
|
||||
{
|
||||
helpLabel->setText(toolTip);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief tableClosed handle after close layout window.
|
||||
*/
|
||||
void MainWindow::tableClosed()
|
||||
{
|
||||
show();
|
||||
|
@ -629,6 +838,10 @@ void MainWindow::PatternProperties()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief showEvent handle after show window.
|
||||
* @param event show event.
|
||||
*/
|
||||
void MainWindow::showEvent( QShowEvent *event )
|
||||
{
|
||||
QMainWindow::showEvent( event );
|
||||
|
@ -649,6 +862,10 @@ void MainWindow::showEvent( QShowEvent *event )
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief closeEvent handle after close window.
|
||||
* @param event close event.
|
||||
*/
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (MaybeSave())
|
||||
|
@ -663,6 +880,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolBarOption enable option toolbar.
|
||||
*/
|
||||
void MainWindow::ToolBarOption()
|
||||
{
|
||||
if (qApp->patternType() == Pattern::Standard)
|
||||
|
@ -699,6 +919,9 @@ void MainWindow::ToolBarOption()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ToolBarDraws enable draw toolbar.
|
||||
*/
|
||||
void MainWindow::ToolBarDraws()
|
||||
{
|
||||
QLabel *labelPtternPieceName = new QLabel(tr("Pattern Piece: "));
|
||||
|
@ -750,6 +973,10 @@ void MainWindow::InitToolButtons()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief currentDrawChanged change active pattern peace.
|
||||
* @param index index in combobox.
|
||||
*/
|
||||
void MainWindow::currentDrawChanged( int index )
|
||||
{
|
||||
if (index != -1)
|
||||
|
@ -770,6 +997,10 @@ void MainWindow::currentDrawChanged( int index )
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief mouseMove save mouse position and show user.
|
||||
* @param scenePos position mouse.
|
||||
*/
|
||||
void MainWindow::mouseMove(const QPointF &scenePos)
|
||||
{
|
||||
QString string = QString("%1, %2").arg(static_cast<qint32>(qApp->fromPixel(scenePos.x())))
|
||||
|
@ -781,6 +1012,9 @@ void MainWindow::mouseMove(const QPointF &scenePos)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CanselTool cansel tool.
|
||||
*/
|
||||
void MainWindow::CancelTool()
|
||||
{
|
||||
delete dialogTool;
|
||||
|
@ -895,6 +1129,9 @@ void MainWindow::CancelTool()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ArrowTool enable arrow tool.
|
||||
*/
|
||||
void MainWindow::ArrowTool()
|
||||
{
|
||||
CancelTool();
|
||||
|
@ -906,12 +1143,19 @@ void MainWindow::ArrowTool()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ActionAroowTool set arrow tool. Cansel tool what was before.
|
||||
*/
|
||||
void MainWindow::ActionAroowTool()
|
||||
{
|
||||
ArrowTool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief keyPressEvent handle key press events.
|
||||
* @param event key event.
|
||||
*/
|
||||
void MainWindow::keyPressEvent ( QKeyEvent * event )
|
||||
{
|
||||
switch (event->key())
|
||||
|
@ -926,6 +1170,9 @@ void MainWindow::keyPressEvent ( QKeyEvent * event )
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SaveCurrentScene save scene options before set another.
|
||||
*/
|
||||
void MainWindow::SaveCurrentScene()
|
||||
{
|
||||
/*Save transform*/
|
||||
|
@ -938,6 +1185,9 @@ void MainWindow::SaveCurrentScene()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RestoreCurrentScene restore scene options after change.
|
||||
*/
|
||||
void MainWindow::RestoreCurrentScene()
|
||||
{
|
||||
/*Set transform for current scene*/
|
||||
|
@ -950,6 +1200,10 @@ void MainWindow::RestoreCurrentScene()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ActionDraw show draw scene.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ActionDraw(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
|
@ -983,6 +1237,10 @@ void MainWindow::ActionDraw(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ActionDetails show details scene.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ActionDetails(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
|
@ -1018,6 +1276,10 @@ void MainWindow::ActionDetails(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SaveAs save as pattern file.
|
||||
* @return true for successes saving.
|
||||
*/
|
||||
bool MainWindow::SaveAs()
|
||||
{
|
||||
QString filters(tr("Pattern files (*.val)"));
|
||||
|
@ -1045,6 +1307,10 @@ bool MainWindow::SaveAs()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Save save pattern file.
|
||||
* @return true for successes saving.
|
||||
*/
|
||||
bool MainWindow::Save()
|
||||
{
|
||||
if (curFile.isEmpty())
|
||||
|
@ -1065,19 +1331,27 @@ bool MainWindow::Save()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Open ask user select pattern file.
|
||||
*/
|
||||
void MainWindow::Open()
|
||||
{
|
||||
if (MaybeSave())
|
||||
{
|
||||
QString filter(tr("Pattern files (*.val)"));
|
||||
//Get list last open files
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
|
||||
QApplication::applicationName());
|
||||
QStringList files = settings.value("recentFileList").toStringList();
|
||||
QString dir;
|
||||
if (curFile.isEmpty())
|
||||
if (files.isEmpty())
|
||||
{
|
||||
dir = QDir::homePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = QFileInfo(curFile).absolutePath();
|
||||
//Absolute path to last open file
|
||||
dir = QFileInfo(files.first()).absolutePath();
|
||||
}
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter);
|
||||
if (fileName.isEmpty() == false)
|
||||
|
@ -1091,6 +1365,9 @@ void MainWindow::Open()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Options config dialog.
|
||||
*/
|
||||
void MainWindow::Options()
|
||||
{
|
||||
ConfigDialog dlg(this);
|
||||
|
@ -1101,6 +1378,9 @@ void MainWindow::Options()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Clear reset to default window.
|
||||
*/
|
||||
void MainWindow::Clear()
|
||||
{
|
||||
setCurrentFile("");
|
||||
|
@ -1123,6 +1403,9 @@ void MainWindow::Clear()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief NewPattern create new empty pattern.
|
||||
*/
|
||||
void MainWindow::NewPattern()
|
||||
{
|
||||
QProcess *v = new QProcess(this);
|
||||
|
@ -1131,6 +1414,9 @@ void MainWindow::NewPattern()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief haveChange enable action save if we have unsaved change.
|
||||
*/
|
||||
void MainWindow::PatternWasModified()
|
||||
{
|
||||
setWindowModified(doc->isPatternModified());
|
||||
|
@ -1138,6 +1424,10 @@ void MainWindow::PatternWasModified()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChangedSize change new size value.
|
||||
* @param text value size.
|
||||
*/
|
||||
void MainWindow::ChangedSize(const QString & text)
|
||||
{
|
||||
qint32 size = text.toInt();
|
||||
|
@ -1146,6 +1436,10 @@ void MainWindow::ChangedSize(const QString & text)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChangedGrowth change new height value.
|
||||
* @param text value height.
|
||||
*/
|
||||
void MainWindow::ChangedHeight(const QString &text)
|
||||
{
|
||||
qint32 growth = text.toInt();
|
||||
|
@ -1154,6 +1448,10 @@ void MainWindow::ChangedHeight(const QString &text)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetEnableWidgets enable action button.
|
||||
* @param enable enable value.
|
||||
*/
|
||||
void MainWindow::SetEnableWidgets(bool enable)
|
||||
{
|
||||
ui->actionSaveAs->setEnabled(enable);
|
||||
|
@ -1169,6 +1467,10 @@ void MainWindow::SetEnableWidgets(bool enable)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ActionTable show table with variables.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ActionTable(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
|
@ -1185,6 +1487,9 @@ void MainWindow::ActionTable(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedActionTable actions after closing table with variables.
|
||||
*/
|
||||
void MainWindow::ClosedActionTable()
|
||||
{
|
||||
ui->actionTable->setChecked(false);
|
||||
|
@ -1193,6 +1498,10 @@ void MainWindow::ClosedActionTable()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ActionHistory show tool history.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ActionHistory(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
|
@ -1210,6 +1519,10 @@ void MainWindow::ActionHistory(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ActionLayout begin creation layout.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void MainWindow::ActionLayout(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
|
@ -1228,6 +1541,9 @@ void MainWindow::ActionLayout(bool checked)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClosedActionHistory actions after closing history window with variables.
|
||||
*/
|
||||
void MainWindow::ClosedActionHistory()
|
||||
{
|
||||
ui->actionHistory->setChecked(false);
|
||||
|
@ -1235,6 +1551,10 @@ void MainWindow::ClosedActionHistory()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetEnableTool enable button.
|
||||
* @param enable enable value.
|
||||
*/
|
||||
void MainWindow::SetEnableTool(bool enable)
|
||||
{
|
||||
bool drawTools = false;
|
||||
|
@ -1272,6 +1592,9 @@ void MainWindow::SetEnableTool(bool enable)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief MinimumScrollBar set scroll bar to minimum.
|
||||
*/
|
||||
void MainWindow::MinimumScrollBar()
|
||||
{
|
||||
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
||||
|
@ -1281,6 +1604,11 @@ void MainWindow::MinimumScrollBar()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SavePattern save pattern file.
|
||||
* @param fileName pattern file name.
|
||||
* @return true if all is good.
|
||||
*/
|
||||
bool MainWindow::SavePattern(const QString &fileName)
|
||||
{
|
||||
QFileInfo tempInfo(fileName);
|
||||
|
@ -1297,6 +1625,9 @@ bool MainWindow::SavePattern(const QString &fileName)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AutoSavePattern start safe saving.
|
||||
*/
|
||||
void MainWindow::AutoSavePattern()
|
||||
{
|
||||
if (curFile.isEmpty() == false && doc->isPatternModified() == true)
|
||||
|
@ -1310,6 +1641,11 @@ void MainWindow::AutoSavePattern()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setCurrentFile the function is called to reset the state of a few variables when a file
|
||||
* is loaded or saved, or when the user starts editing a new file (in which case fileName is empty).
|
||||
* @param fileName file name.
|
||||
*/
|
||||
void MainWindow::setCurrentFile(const QString &fileName)
|
||||
{
|
||||
curFile = fileName;
|
||||
|
@ -1341,11 +1677,20 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief strippedName the function call around curFile to exclude the path to the file.
|
||||
* @param fullFileName full path to the file.
|
||||
* @return file name.
|
||||
*/
|
||||
QString MainWindow::strippedName(const QString &fullFileName)
|
||||
{
|
||||
return QFileInfo(fullFileName).fileName();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ReadSettings read setting for app.
|
||||
*/
|
||||
void MainWindow::ReadSettings()
|
||||
{
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
|
||||
|
@ -1357,6 +1702,9 @@ void MainWindow::ReadSettings()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief WriteSettings save setting for app.
|
||||
*/
|
||||
void MainWindow::WriteSettings()
|
||||
{
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
|
||||
|
@ -1366,6 +1714,10 @@ void MainWindow::WriteSettings()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief MaybeSave The function is called to save pending changes.
|
||||
* @return returns true in all cases, except when the user clicks Cancel.
|
||||
*/
|
||||
bool MainWindow::MaybeSave()
|
||||
{
|
||||
if (doc->isPatternModified())
|
||||
|
@ -1522,6 +1874,10 @@ MainWindow::~MainWindow()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief LoadPattern open pattern file.
|
||||
* @param fileName name of file.
|
||||
*/
|
||||
void MainWindow::LoadPattern(const QString &fileName)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -51,319 +51,72 @@ class MainWindow : public QMainWindow
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief MainWindow constructor.
|
||||
* @param parent parent widget.
|
||||
*/
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
/**
|
||||
* @brief LoadPattern open pattern file.
|
||||
* @param fileName name of file.
|
||||
*/
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
void LoadPattern(const QString &curFile);
|
||||
public slots:
|
||||
/**
|
||||
* @brief mouseMove save mouse position and show user.
|
||||
* @param scenePos position mouse.
|
||||
*/
|
||||
void mouseMove(const QPointF &scenePos);
|
||||
/**
|
||||
* @brief ActionAroowTool set arrow tool. Cansel tool what was before.
|
||||
*/
|
||||
void ActionAroowTool();
|
||||
/**
|
||||
* @brief ActionDraw show draw scene.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ActionDraw(bool checked);
|
||||
/**
|
||||
* @brief ActionDetails show details scene.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ActionDetails(bool checked);
|
||||
/**
|
||||
* @brief ActionNewDraw add to scene new pattern peace.
|
||||
*/
|
||||
void ActionNewDraw();
|
||||
/**
|
||||
* @brief SaveAs save as pattern file.
|
||||
* @return true for successes saving.
|
||||
*/
|
||||
bool SaveAs();
|
||||
/**
|
||||
* @brief Save save pattern file.
|
||||
* @return true for successes saving.
|
||||
*/
|
||||
bool Save();
|
||||
/**
|
||||
* @brief Open ask user select pattern file.
|
||||
*/
|
||||
void Open();
|
||||
/**
|
||||
* @brief Options config dialog.
|
||||
*/
|
||||
void Options();
|
||||
/**
|
||||
* @brief NewPattern create new empty pattern.
|
||||
*/
|
||||
void NewPattern();
|
||||
/**
|
||||
* @brief ActionTable show table with variables.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ActionTable(bool checked);
|
||||
/**
|
||||
* @brief ActionHistory show tool history.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ActionHistory(bool checked);
|
||||
/**
|
||||
* @brief ActionLayout begin creation layout.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ActionLayout(bool checked);
|
||||
/**
|
||||
* @brief currentDrawChanged change active pattern peace.
|
||||
* @param index index in combobox.
|
||||
*/
|
||||
void currentDrawChanged( int index );
|
||||
/**
|
||||
* @brief OptionDraw help change name of pattern peace.
|
||||
*/
|
||||
void OptionDraw();
|
||||
/**
|
||||
* @brief haveChange enable action save if we have unsaved change.
|
||||
*/
|
||||
void PatternWasModified();
|
||||
/**
|
||||
* @brief ChangedSize change new size value.
|
||||
* @param text value size.
|
||||
*/
|
||||
void ChangedSize(const QString &text);
|
||||
/**
|
||||
* @brief ChangedGrowth change new height value.
|
||||
* @param text value height.
|
||||
*/
|
||||
void ChangedHeight(const QString & text);
|
||||
/**
|
||||
* @brief ClosedActionTable actions after closing table with variables.
|
||||
*/
|
||||
void ClosedActionTable();
|
||||
/**
|
||||
* @brief ClosedActionHistory actions after closing history window with variables.
|
||||
*/
|
||||
void ClosedActionHistory();
|
||||
/**
|
||||
* @brief ToolEndLine handler tool endLine.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolEndLine(bool checked);
|
||||
/**
|
||||
* @brief ToolLine handler tool line.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolLine(bool checked);
|
||||
/**
|
||||
* @brief ToolAlongLine handler tool alongLine.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolAlongLine(bool checked);
|
||||
/**
|
||||
* @brief ToolShoulderPoint handler tool shoulderPoint.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolShoulderPoint(bool checked);
|
||||
/**
|
||||
* @brief ToolNormal handler tool normal.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolNormal(bool checked);
|
||||
/**
|
||||
* @brief ToolBisector handler tool bisector.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolBisector(bool checked);
|
||||
/**
|
||||
* @brief ToolLineIntersect handler tool lineIntersect.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolLineIntersect(bool checked);
|
||||
/**
|
||||
* @brief ToolSpline handler tool spline.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolSpline(bool checked);
|
||||
/**
|
||||
* @brief ToolCutSpline handler tool CutSpline.
|
||||
* @param checked true - button is checked
|
||||
*/
|
||||
void ToolCutSpline(bool checked);
|
||||
/**
|
||||
* @brief ToolArc handler tool arc.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolArc(bool checked);
|
||||
/**
|
||||
* @brief ToolSplinePath handler tool splinePath.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolSplinePath(bool checked);
|
||||
/**
|
||||
* @brief ToolCutSplinePath handler tool CutSplinePath.
|
||||
* @param checked true - button is checked
|
||||
*/
|
||||
void ToolCutSplinePath(bool checked);
|
||||
/**
|
||||
* @brief ToolPointOfContact handler tool pointOfContact.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolPointOfContact(bool checked);
|
||||
/**
|
||||
* @brief ToolDetail handler tool detail.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolDetail(bool checked);
|
||||
/**
|
||||
* @brief ToolHeight handler tool height.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolHeight(bool checked);
|
||||
/**
|
||||
* @brief ToolTriangle handler tool triangle.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolTriangle(bool checked);
|
||||
/**
|
||||
* @brief ToolPointOfIntersection handler tool pointOfIntersection.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolPointOfIntersection(bool checked);
|
||||
/**
|
||||
* @brief ToolUnionDetails handler tool unionDetails.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolUnionDetails(bool checked);
|
||||
/**
|
||||
* @brief ToolCutArc handler tool cutArc.
|
||||
* @param checked true - button checked.
|
||||
*/
|
||||
void ToolCutArc(bool checked);
|
||||
/**
|
||||
* @brief ClosedDialogEndLine actions after closing DialogEndLine.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogEndLine(int result);
|
||||
/** // TODO ISSUE 79 : copy
|
||||
* @brief ApplyDialogEndLine actions after apply in DialogEndLine.
|
||||
*/
|
||||
void ApplyDialogEndLine();
|
||||
/**
|
||||
* @brief ClosedDialogLine actions after closing DialogLine.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogLine(int result);
|
||||
/**
|
||||
* @brief ClosedDialogAlongLine actions after closing DialogAlongLine.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogAlongLine(int result);
|
||||
/**
|
||||
* @brief ClosedDialogShoulderPoint actions after closing DialogShoulderPoint.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogShoulderPoint(int result);
|
||||
/**
|
||||
* @brief ClosedDialogNormal actions after closing DialogNormal.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogNormal(int result);
|
||||
/**
|
||||
* @brief ClosedDialogBisector actions after closing DialogBisector.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogBisector(int result);
|
||||
/**
|
||||
* @brief ClosedDialogLineIntersect actions after closing DialogLineIntersect.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogLineIntersect(int result);
|
||||
/**
|
||||
* @brief ClosedDialogSpline actions after closing DialogSpline.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogSpline(int result);
|
||||
/**
|
||||
* @brief ClosedDialogArc actions after closing DialogArc.
|
||||
* @param result result of dialog working..
|
||||
*/
|
||||
void ClosedDialogArc(int result);
|
||||
/**
|
||||
* @brief ClosedDialogSplinePath actions after closing DialogSplinePath.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogSplinePath(int result);
|
||||
/**
|
||||
* @brief ClosedDialogCutSplinePath actions after closing DialogCutSplinePath.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogCutSplinePath(int result);
|
||||
/**
|
||||
* @brief ClosedDialogPointOfContact actions after closing DialogPointOfContact.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogPointOfContact(int result);
|
||||
/**
|
||||
* @brief ClosedDialogDetail actions after closing DialogDetail.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogDetail(int result);
|
||||
/**
|
||||
* @brief ClosedDialogHeight actions after closing DialogHeight.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogHeight(int result);
|
||||
/**
|
||||
* @brief ClosedDialogTriangle actions after closing DialogTriangle.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogTriangle(int result);
|
||||
/**
|
||||
* @brief ClosedDialogPointOfIntersection actions after closing DialogPointOfIntersection.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogPointOfIntersection(int result);
|
||||
/**
|
||||
* @brief ClosedDialogUnionDetails actions after closing DialogUnionDetails.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogUnionDetails(int result);
|
||||
/**
|
||||
* @brief ClosedDialogCutSpline actions after closing DialogCutSpline.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogCutSpline(int result);
|
||||
/**
|
||||
* @brief ClosedDialogCutArc actions after closing DialogCutArc.
|
||||
* @param result result of dialog working.
|
||||
*/
|
||||
void ClosedDialogCutArc(int result);
|
||||
/**
|
||||
* @brief About show widows about.
|
||||
*/
|
||||
void About();
|
||||
/**
|
||||
* @brief AboutQt show widows aboutQt.
|
||||
*/
|
||||
void AboutQt();
|
||||
/**
|
||||
* @brief ShowTool highlight tool.Tip show tools tooltip.
|
||||
* @param toolTip tooltip text.
|
||||
*/
|
||||
void ShowToolTip(const QString &toolTip);
|
||||
/**
|
||||
* @brief tableClosed handle after close layout window.
|
||||
*/
|
||||
void tableClosed();
|
||||
void OpenRecentFile();
|
||||
void PatternProperties();
|
||||
|
@ -375,24 +128,9 @@ signals:
|
|||
*/
|
||||
void ModelChosen(QVector<VItem*> listDetails, const QString &curFile, const QString &description);
|
||||
protected:
|
||||
/**
|
||||
* @brief keyPressEvent handle key press events.
|
||||
* @param event key event.
|
||||
*/
|
||||
virtual void keyPressEvent ( QKeyEvent * event );
|
||||
/**
|
||||
* @brief showEvent handle after show window.
|
||||
* @param event show event.
|
||||
*/
|
||||
virtual void showEvent( QShowEvent *event );
|
||||
/**
|
||||
* @brief closeEvent handle after close window.
|
||||
* @param event close event.
|
||||
*/
|
||||
virtual void closeEvent( QCloseEvent * event );
|
||||
/**
|
||||
* @brief Clear reset to default window.
|
||||
*/
|
||||
void Clear();
|
||||
private:
|
||||
Q_DISABLE_COPY(MainWindow)
|
||||
|
@ -471,119 +209,36 @@ private:
|
|||
QAction *recentFileActs[MaxRecentFiles];
|
||||
QAction *separatorAct;
|
||||
QTimer *autoSaveTimer;
|
||||
/**
|
||||
* @brief ToolBarOption enable option toolbar.
|
||||
*/
|
||||
void ToolBarOption();
|
||||
/**
|
||||
* @brief ToolBarDraws enable draw toolbar.
|
||||
*/
|
||||
void ToolBarDraws();
|
||||
void InitToolButtons();
|
||||
/**
|
||||
* @brief CanselTool cansel tool.
|
||||
*/
|
||||
void CancelTool();
|
||||
/**
|
||||
* @brief ArrowTool enable arrow tool.
|
||||
*/
|
||||
void ArrowTool();
|
||||
/**
|
||||
* @brief SetEnableWidgets enable action button.
|
||||
* @param enable enable value.
|
||||
*/
|
||||
void SetEnableWidgets(bool enable);
|
||||
/**
|
||||
* @brief SetEnableTool enable button.
|
||||
* @param enable enable value.
|
||||
*/
|
||||
void SetEnableTool(bool enable);
|
||||
/**
|
||||
* @brief SaveCurrentScene save scene options before set another.
|
||||
*/
|
||||
void SaveCurrentScene();
|
||||
/**
|
||||
* @brief RestoreCurrentScene restore scene options after change.
|
||||
*/
|
||||
void RestoreCurrentScene();
|
||||
template <typename Dialog, typename Func>
|
||||
/** // TODO ISSUE 79 : delete
|
||||
* @brief SetToolButton set tool and show dialog.
|
||||
* @param checked true if tool button checked.
|
||||
* @param t tool type.
|
||||
* @param cursor path tool cursor icon.
|
||||
* @param toolTip first tooltipe.
|
||||
* @param closeDialogSlot function what handle after close dialog.
|
||||
*/
|
||||
// TODO ISSUE 79 : delete
|
||||
void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
|
||||
Func closeDialogSlot);
|
||||
/** // TODO ISSUE 79 : copy
|
||||
* @brief SetToolButton set tool and show dialog.
|
||||
* @param checked true if tool button checked.
|
||||
* @param t tool type.
|
||||
* @param cursor path tool cursor icon.
|
||||
* @param toolTip first tooltipe.
|
||||
* @param closeDialogSlot function to handle close of dialog.
|
||||
* @param applyDialogSlot function to handle apply in dialog.
|
||||
*/
|
||||
template <typename Dialog, typename Func, typename Func2>
|
||||
// TODO ISSUE 79 : copy
|
||||
void SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
|
||||
Func closeDialogSlot, Func2 applyDialogSlot);
|
||||
/**
|
||||
* @brief MinimumScrollBar set scroll bar to minimum.
|
||||
*/
|
||||
void MinimumScrollBar();
|
||||
template <typename DrawTool>
|
||||
/** // TODO ISSUE 79 : delete
|
||||
* @brief ClosedDialog handle close dialog
|
||||
* @param result result working dialog.
|
||||
*/
|
||||
void ClosedDialog(int result);
|
||||
template <typename DrawTool>
|
||||
/** // TODO ISSUE 79 : rename
|
||||
* @brief ClosedDialog handle close dialog
|
||||
* @param result result working dialog.
|
||||
*/
|
||||
void ClosedDialog2(int result);
|
||||
/** // TODO ISSUE 79 : copy
|
||||
* @brief ApplyDialog handle apply in dialog
|
||||
*/
|
||||
template <typename DrawTool>
|
||||
void ApplyDialog();
|
||||
/**
|
||||
* @brief SavePattern save pattern file.
|
||||
* @param fileName pattern file name.
|
||||
* @return true if all is good.
|
||||
*/
|
||||
bool SavePattern(const QString &curFile);
|
||||
/**
|
||||
* @brief AutoSavePattern start safe saving.
|
||||
*/
|
||||
void AutoSavePattern();
|
||||
/**
|
||||
* @brief setCurrentFile the function is called to reset the state of a few variables when a file
|
||||
* is loaded or saved, or when the user starts editing a new file (in which case fileName is empty).
|
||||
* @param fileName file name.
|
||||
*/
|
||||
void setCurrentFile(const QString &fileName);
|
||||
/**
|
||||
* @brief strippedName the function call around curFile to exclude the path to the file.
|
||||
* @param fullFileName full path to the file.
|
||||
* @return file name.
|
||||
*/
|
||||
QString strippedName(const QString &fullFileName);
|
||||
/**
|
||||
* @brief ReadSettings read setting for app.
|
||||
*/
|
||||
void ReadSettings();
|
||||
/**
|
||||
* @brief WriteSettings save setting for app.
|
||||
*/
|
||||
void WriteSettings();
|
||||
/**
|
||||
* @brief MaybeSave The function is called to save pending changes.
|
||||
* @return returns true in all cases, except when the user clicks Cancel.
|
||||
*/
|
||||
bool MaybeSave();
|
||||
void UpdateRecentFileActions();
|
||||
void CreateMenus();
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>144</width>
|
||||
<width>150</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -302,7 +302,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>150</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -378,7 +378,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>150</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -579,7 +579,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>150</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -703,6 +703,9 @@
|
|||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Toolbar files</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
|
@ -719,7 +722,7 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
<string>ToolBar modes</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
|
@ -733,7 +736,7 @@
|
|||
</widget>
|
||||
<widget class="QToolBar" name="toolBarDraws">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar_2</string>
|
||||
<string>Toolbar pattern</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
|
@ -745,7 +748,7 @@
|
|||
</widget>
|
||||
<widget class="QToolBar" name="toolBarOption">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar_3</string>
|
||||
<string>Toolbar options</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>BottomToolBarArea</enum>
|
||||
|
|
|
@ -1505,7 +1505,7 @@ void VApplication::InitPostfixOperators()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const QString &token) const
|
||||
bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const
|
||||
{
|
||||
QMap<QString, VTranslation>::const_iterator i = measurements.constBegin();
|
||||
while (i != measurements.constEnd())
|
||||
|
@ -1513,6 +1513,7 @@ bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const
|
|||
if(token == i.value().translate())
|
||||
{
|
||||
newFormula.replace(position, token.length(), i.key());
|
||||
bias = token.length() - i.key().length();
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
|
@ -1521,7 +1522,7 @@ bool VApplication::MeasurementsFromUser(QString &newFormula, int position, const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VApplication::VariablesFromUser(QString &newFormula, int position, const QString &token) const
|
||||
bool VApplication::VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const
|
||||
{
|
||||
QMap<QString, VTranslation>::const_iterator i = variables.constBegin();
|
||||
while (i != variables.constEnd())
|
||||
|
@ -1529,6 +1530,9 @@ bool VApplication::VariablesFromUser(QString &newFormula, int position, const QS
|
|||
if(token.indexOf( i.value().translate() ) == 0)
|
||||
{
|
||||
newFormula.replace(position, i.value().translate().length(), i.key());
|
||||
QString newToken = token;
|
||||
newToken.replace(0, i.value().translate().length(), i.key());
|
||||
bias = token.length() - newToken.length();
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
|
@ -1537,7 +1541,7 @@ bool VApplication::VariablesFromUser(QString &newFormula, int position, const QS
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token) const
|
||||
bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, int &bias) const
|
||||
{
|
||||
QMap<QString, VTranslation>::const_iterator i = postfixOperators.constBegin();
|
||||
while (i != postfixOperators.constEnd())
|
||||
|
@ -1545,6 +1549,7 @@ bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, c
|
|||
if(token == i.value().translate())
|
||||
{
|
||||
newFormula.replace(position, token.length(), i.key());
|
||||
bias = token.length() - i.key().length();
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
|
@ -1553,7 +1558,7 @@ bool VApplication::PostfixOperatorsFromUser(QString &newFormula, int position, c
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QString &token) const
|
||||
bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const
|
||||
{
|
||||
QMap<QString, VTranslation>::const_iterator i = functions.constBegin();
|
||||
while (i != functions.constEnd())
|
||||
|
@ -1561,6 +1566,7 @@ bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QS
|
|||
if(token == i.value().translate())
|
||||
{
|
||||
newFormula.replace(position, token.length(), i.key());
|
||||
bias = token.length() - i.key().length();
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
|
@ -1569,7 +1575,7 @@ bool VApplication::FunctionsFromUser(QString &newFormula, int position, const QS
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VApplication::VariablesToUser(QString &newFormula, int position, const QString &token) const
|
||||
bool VApplication::VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const
|
||||
{
|
||||
QMap<QString, VTranslation>::const_iterator i = variables.constBegin();
|
||||
while (i != variables.constEnd())
|
||||
|
@ -1577,6 +1583,10 @@ bool VApplication::VariablesToUser(QString &newFormula, int position, const QStr
|
|||
if(token.indexOf( i.key() ) == 0)
|
||||
{
|
||||
newFormula.replace(position, i.key().length(), i.value().translate());
|
||||
|
||||
QString newToken = token;
|
||||
newToken.replace(0, i.key().length(), i.value().translate());
|
||||
bias = token.length() - newToken.length();
|
||||
return true;
|
||||
}
|
||||
++i;
|
||||
|
@ -1584,6 +1594,37 @@ bool VApplication::VariablesToUser(QString &newFormula, int position, const QStr
|
|||
return false;
|
||||
}
|
||||
|
||||
void VApplication::CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens,
|
||||
QMap<int, QString> &numbers)
|
||||
{
|
||||
if(bias == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BiasTokens(position, bias, tokens);
|
||||
BiasTokens(position, bias, numbers);
|
||||
}
|
||||
|
||||
void VApplication::BiasTokens(int position, int bias, QMap<int, QString> &tokens) const
|
||||
{
|
||||
QMap<int, QString> newTokens;
|
||||
QMap<int, QString>::const_iterator i = tokens.constBegin();
|
||||
while (i != tokens.constEnd())
|
||||
{
|
||||
if(i.key()<= position)
|
||||
{
|
||||
newTokens.insert(i.key(), i.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
newTokens.insert(i.key()-bias, i.value());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
tokens = newTokens;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VApplication::setPatternUnit(const Valentina::Units &patternUnit)
|
||||
{
|
||||
|
@ -1610,7 +1651,8 @@ QString VApplication::VarToUser(const QString &var) const
|
|||
}
|
||||
|
||||
QString newVar = var;
|
||||
if(VariablesToUser(newVar, 0, var))
|
||||
int bias = 0;
|
||||
if(VariablesToUser(newVar, 0, var, bias))
|
||||
{
|
||||
return newVar;
|
||||
}
|
||||
|
@ -1621,22 +1663,23 @@ QString VApplication::VarToUser(const QString &var) const
|
|||
QString VApplication::VarFromUser(const QString &var) const
|
||||
{
|
||||
QString newVar = var;
|
||||
if(MeasurementsFromUser(newVar, 0, var))
|
||||
int bias = 0;
|
||||
if(MeasurementsFromUser(newVar, 0, var, bias))
|
||||
{
|
||||
return newVar;
|
||||
}
|
||||
|
||||
if(VariablesFromUser(newVar, 0, var))
|
||||
if(VariablesFromUser(newVar, 0, var, bias))
|
||||
{
|
||||
return newVar;
|
||||
}
|
||||
|
||||
if(PostfixOperatorsFromUser(newVar, 0, var))
|
||||
if(PostfixOperatorsFromUser(newVar, 0, var, bias))
|
||||
{
|
||||
return newVar;
|
||||
}
|
||||
|
||||
if(FunctionsFromUser(newVar, 0, var))
|
||||
if(FunctionsFromUser(newVar, 0, var, bias))
|
||||
{
|
||||
return newVar;
|
||||
}
|
||||
|
@ -1696,58 +1739,84 @@ QString VApplication::FormulaFromUser(const QString &formula)
|
|||
return newFormula;
|
||||
}
|
||||
|
||||
QMap<int, QString>::const_iterator i = tokens.constBegin();
|
||||
while (i != tokens.constEnd())
|
||||
QList<int> tKeys = tokens.keys();
|
||||
QList<QString> tValues = tokens.values();
|
||||
for (int i = 0; i < tKeys.size(); ++i)
|
||||
{
|
||||
if(MeasurementsFromUser(newFormula, i.key(), i.value()))
|
||||
int bias = 0;
|
||||
if(MeasurementsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias))
|
||||
{
|
||||
++i;
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(VariablesFromUser(newFormula, i.key(), i.value()))
|
||||
if(VariablesFromUser(newFormula, tKeys.at(i), tValues.at(i), bias))
|
||||
{
|
||||
++i;
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(PostfixOperatorsFromUser(newFormula, i.key(), i.value()))
|
||||
if(PostfixOperatorsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias))
|
||||
{
|
||||
++i;
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(FunctionsFromUser(newFormula, i.key(), i.value()))
|
||||
if(FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias))
|
||||
{
|
||||
++i;
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
QLocale loc = QLocale();
|
||||
QLocale loc = QLocale::system();
|
||||
if(loc != QLocale(QLocale::C))
|
||||
{
|
||||
QMap<int, QString>::const_iterator i = numbers.constBegin();
|
||||
while (i != numbers.constEnd())
|
||||
QList<int> nKeys = numbers.keys();
|
||||
QList<QString> nValues = numbers.values();
|
||||
for (int i = 0; i < tKeys.size(); ++i)
|
||||
{
|
||||
QLocale::setDefault(QLocale::C);
|
||||
bool ok = false;
|
||||
qreal d = QString(i.value()).toDouble(&ok);
|
||||
if(ok == false)
|
||||
qreal d = loc.toDouble(nValues.at(i), &ok);
|
||||
if (ok == false)
|
||||
{
|
||||
qDebug()<<"Can't convert to double token"<<i.value();
|
||||
++i;
|
||||
qDebug()<<"Can't convert to double token"<<nValues.at(i);
|
||||
continue;
|
||||
}
|
||||
if(qFloor (d) < d)
|
||||
if (qFloor (d) < d)
|
||||
{
|
||||
QLocale::setDefault(QLocale::system());
|
||||
QLocale loc = QLocale();
|
||||
QLocale loc = QLocale(QLocale::C);
|
||||
QString dStr = loc.toString(d);
|
||||
newFormula.replace(i.key(), i.value().length(), dStr);
|
||||
newFormula.replace(nKeys.at(i), nValues.at(i).length(), dStr);
|
||||
int bias = nValues.at(i).length() - dStr.length();
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(nKeys.at(i), bias, tokens, numbers);
|
||||
nKeys = numbers.keys();
|
||||
nValues = numbers.values();
|
||||
}
|
||||
}
|
||||
++i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1764,7 +1833,7 @@ QString VApplication::FormulaToUser(const QString &formula)
|
|||
QMap<int, QString> numbers;
|
||||
try
|
||||
{
|
||||
Calculator cal(formula);
|
||||
Calculator cal(formula, false);
|
||||
tokens = cal.GetTokens();
|
||||
numbers = cal.GetNumbers();
|
||||
}
|
||||
|
@ -1778,61 +1847,91 @@ QString VApplication::FormulaToUser(const QString &formula)
|
|||
return newFormula;
|
||||
}
|
||||
|
||||
QMap<int, QString>::const_iterator i = tokens.constBegin();
|
||||
while (i != tokens.constEnd())
|
||||
QList<int> tKeys = tokens.keys();
|
||||
QList<QString> tValues = tokens.values();
|
||||
for (int i = 0; i < tKeys.size(); ++i)
|
||||
{
|
||||
if (measurements.contains(i.value()))
|
||||
if (measurements.contains(tValues.at(i)))
|
||||
{
|
||||
newFormula.replace(i.key(), i.value().length(), measurements.value(i.value()).translate());
|
||||
++i;
|
||||
newFormula.replace(tKeys.at(i), tValues.at(i).length(), measurements.value(tValues.at(i)).translate());
|
||||
int bias = tValues.at(i).length() - measurements.value(tValues.at(i)).translate().length();
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (functions.contains(i.value()))
|
||||
if (functions.contains(tValues.at(i)))
|
||||
{
|
||||
newFormula.replace(i.key(), i.value().length(), functions.value(i.value()).translate());
|
||||
++i;
|
||||
newFormula.replace(tKeys.at(i), tValues.at(i).length(), functions.value(tValues.at(i)).translate());
|
||||
int bias = tValues.at(i).length() - functions.value(tValues.at(i)).translate().length();
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (postfixOperators.contains(i.value()))
|
||||
if (postfixOperators.contains(tValues.at(i)))
|
||||
{
|
||||
newFormula.replace(i.key(), i.value().length(), postfixOperators.value(i.value()).translate());
|
||||
++i;
|
||||
newFormula.replace(tKeys.at(i), tValues.at(i).length(), postfixOperators.value(tValues.at(i)).translate());
|
||||
int bias = tValues.at(i).length() - postfixOperators.value(tValues.at(i)).translate().length();
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(VariablesToUser(newFormula, i.key(), i.value()))
|
||||
int bias = 0;
|
||||
if(VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias))
|
||||
{
|
||||
++i;
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(tKeys.at(i), bias, tokens, numbers);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QLocale loc = QLocale();
|
||||
QLocale loc = QLocale::system();
|
||||
if(loc != QLocale::C)
|
||||
{
|
||||
QMap<int, QString>::const_iterator i = numbers.constBegin();
|
||||
while (i != numbers.constEnd())
|
||||
QList<int> nKeys = numbers.keys();
|
||||
QList<QString> nValues = numbers.values();
|
||||
for (int i = 0; i < tKeys.size(); ++i)
|
||||
{
|
||||
QLocale loc = QLocale(QLocale::C);
|
||||
bool ok = false;
|
||||
qreal d = QString(i.value()).toDouble(&ok);
|
||||
qreal d = loc.toDouble(nValues.at(i), &ok);
|
||||
if(ok == false)
|
||||
{
|
||||
qDebug()<<"Can't convert to double token"<<i.value();
|
||||
++i;
|
||||
qDebug()<<"Can't convert to double token"<<nValues.at(i);
|
||||
continue;
|
||||
}
|
||||
if(qFloor (d) < d)
|
||||
{
|
||||
QLocale::setDefault(QLocale::C);
|
||||
QLocale loc = QLocale();
|
||||
QLocale loc = QLocale::system();
|
||||
QString dStr = loc.toString(d);
|
||||
newFormula.replace(i.key(), i.value().length(), dStr);
|
||||
QLocale::setDefault(QLocale::system());
|
||||
newFormula.replace(nKeys.at(i), nValues.at(i).length(), dStr);
|
||||
int bias = nValues.at(i).length() - dStr.length();
|
||||
|
||||
if (bias != 0)
|
||||
{
|
||||
CorrectionsPositions(nKeys.at(i), bias, tokens, numbers);
|
||||
nKeys = numbers.keys();
|
||||
nValues = numbers.values();
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,11 +97,17 @@ private:
|
|||
void InitVariables();
|
||||
void InitFunctions();
|
||||
void InitPostfixOperators();
|
||||
bool MeasurementsFromUser(QString &newFormula, int position, const QString &token) const;
|
||||
bool VariablesFromUser(QString &newFormula, int position, const QString &token) const;
|
||||
bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token) const;
|
||||
bool FunctionsFromUser(QString &newFormula, int position, const QString &token) const;
|
||||
bool VariablesToUser(QString &newFormula, int position, const QString &token) const;
|
||||
bool MeasurementsFromUser(QString &newFormula, int position, const QString &token,
|
||||
int &bias) const;
|
||||
bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token,
|
||||
int &bias) const;
|
||||
bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
||||
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens,
|
||||
QMap<int, QString> &numbers);
|
||||
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
|
||||
|
||||
};
|
||||
|
||||
inline Valentina::Units VApplication::patternUnit() const
|
||||
|
|
Loading…
Reference in New Issue
Block a user