DialogNormal change
--HG-- branch : DialogTools
This commit is contained in:
parent
094f29492d
commit
0b4f1a21ed
|
@ -39,11 +39,13 @@ DialogNormal::DialogNormal(const VContainer *data, QWidget *parent)
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitVariables(ui);
|
InitVariables(ui);
|
||||||
labelResultCalculation = ui->labelResultCalculation;
|
labelResultCalculation = ui->labelResultCalculation;
|
||||||
lineEditFormula = ui->lineEditFormula;
|
plainTextEditFormula = ui->plainTextEditFormula;
|
||||||
labelEditFormula = ui->labelEditFormula;
|
labelEditFormula = ui->labelEditFormula;
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
labelEditNamePoint = ui->labelEditNamePoint;
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
|
||||||
|
this->formulaBaseHeight=ui->plainTextEditFormula->height();
|
||||||
|
|
||||||
flagFormula = false;
|
flagFormula = false;
|
||||||
flagName = false;
|
flagName = false;
|
||||||
CheckState();
|
CheckState();
|
||||||
|
@ -58,7 +60,36 @@ DialogNormal::DialogNormal(const VContainer *data, QWidget *parent)
|
||||||
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogNormal::PutVal);
|
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogNormal::PutVal);
|
||||||
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogNormal::EvalFormula);
|
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogNormal::EvalFormula);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged);
|
||||||
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged);
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogNormal::FormulaTextChanged);
|
||||||
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit);
|
||||||
|
|
||||||
|
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
|
||||||
|
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogNormal::FormulaTextChanged()
|
||||||
|
{
|
||||||
|
// TODO issue #79 : back to FormulaChanged when full update
|
||||||
|
// Also remove this function if only one function called here
|
||||||
|
this->FormulaChanged2();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogNormal::DeployFormulaTextEdit()
|
||||||
|
{
|
||||||
|
if (ui->plainTextEditFormula->height() < DIALOGNORMAL_MAX_FORMULA_HEIGHT)
|
||||||
|
{
|
||||||
|
ui->plainTextEditFormula->setFixedHeight(DIALOGNORMAL_MAX_FORMULA_HEIGHT);
|
||||||
|
//Set icon from theme (internal for Windows system)
|
||||||
|
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
|
||||||
|
//Set icon from theme (internal for Windows system)
|
||||||
|
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -96,14 +127,27 @@ void DialogNormal::ChoosedObject(quint32 id, const Valentina::Scenes &type)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogNormal::DialogAccepted()
|
void DialogNormal::DialogAccepted()
|
||||||
|
{
|
||||||
|
this->SaveData();
|
||||||
|
emit DialogClosed(QDialog::Accepted);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogNormal::DialogApply()
|
||||||
|
{
|
||||||
|
this->SaveData();
|
||||||
|
emit DialogApplied();
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogNormal::SaveData()
|
||||||
{
|
{
|
||||||
pointName = ui->lineEditNamePoint->text();
|
pointName = ui->lineEditNamePoint->text();
|
||||||
typeLine = GetTypeLine(ui->comboBoxLineType);
|
typeLine = GetTypeLine(ui->comboBoxLineType);
|
||||||
formula = ui->lineEditFormula->text();
|
formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formula.replace("\n"," ");
|
||||||
angle = ui->doubleSpinBoxAngle->value();
|
angle = ui->doubleSpinBoxAngle->value();
|
||||||
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
|
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
|
||||||
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
|
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
|
||||||
emit DialogClosed(QDialog::Accepted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -129,7 +173,12 @@ void DialogNormal::setAngle(const qreal &value)
|
||||||
void DialogNormal::setFormula(const QString &value)
|
void DialogNormal::setFormula(const QString &value)
|
||||||
{
|
{
|
||||||
formula = qApp->FormulaToUser(value);
|
formula = qApp->FormulaToUser(value);
|
||||||
ui->lineEditFormula->setText(formula);
|
// increase height if needed.
|
||||||
|
if (formula.length() > 80)
|
||||||
|
{
|
||||||
|
this->DeployFormulaTextEdit();
|
||||||
|
}
|
||||||
|
ui->plainTextEditFormula->setPlainText(formula);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
|
|
||||||
|
#define DIALOGNORMAL_MAX_FORMULA_HEIGHT 64
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class DialogNormal;
|
class DialogNormal;
|
||||||
|
@ -123,12 +124,24 @@ public slots:
|
||||||
* @brief DialogAccepted save data and emit signal about closed dialog.
|
* @brief DialogAccepted save data and emit signal about closed dialog.
|
||||||
*/
|
*/
|
||||||
virtual void DialogAccepted();
|
virtual void DialogAccepted();
|
||||||
/** TODO ISSUE 79 : create real function
|
/**
|
||||||
* @brief DialogApply apply data and emit signal about applied dialog.
|
* @brief DialogApply apply data and emit signal about applied dialog.
|
||||||
*/
|
*/
|
||||||
virtual void DialogApply(){}
|
virtual void DialogApply();
|
||||||
|
/**
|
||||||
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
|
*/
|
||||||
|
void DeployFormulaTextEdit();
|
||||||
|
/**
|
||||||
|
* @brief FormulaTextChanged when formula text changes for validation and calc
|
||||||
|
*/
|
||||||
|
void FormulaTextChanged();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogNormal)
|
Q_DISABLE_COPY(DialogNormal)
|
||||||
|
/**
|
||||||
|
* @brief SaveData Put dialog data in local variables
|
||||||
|
*/
|
||||||
|
void SaveData();
|
||||||
/**
|
/**
|
||||||
* @brief ui keeps information about user interface
|
* @brief ui keeps information about user interface
|
||||||
*/
|
*/
|
||||||
|
@ -161,6 +174,10 @@ private:
|
||||||
* @brief secondPointId id second point of line
|
* @brief secondPointId id second point of line
|
||||||
*/
|
*/
|
||||||
quint32 secondPointId;
|
quint32 secondPointId;
|
||||||
|
/**
|
||||||
|
* @brief formulaBaseHeight base height defined by dialogui
|
||||||
|
*/
|
||||||
|
int formulaBaseHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QString DialogNormal::getPointName() const
|
inline QString DialogNormal::getPointName() const
|
||||||
|
|
|
@ -74,17 +74,17 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEditFormula">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="sizePolicy">
|
<property name="orientation">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<enum>Qt::Horizontal</enum>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="sizeHint" stdset="0">
|
||||||
<string>Formula for calculation of length of normal</string>
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="toolButtonPutHere">
|
<widget class="QToolButton" name="toolButtonPutHere">
|
||||||
|
@ -150,6 +150,56 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_formula">
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="plainTextEditFormula">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonGrowLength">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>18</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeIncrement">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Show full calculation in message box</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="go-down.png">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
|
@ -601,14 +651,13 @@
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>lineEditFormula</tabstop>
|
|
||||||
<tabstop>lineEditNamePoint</tabstop>
|
<tabstop>lineEditNamePoint</tabstop>
|
||||||
<tabstop>comboBoxFirstPoint</tabstop>
|
<tabstop>comboBoxFirstPoint</tabstop>
|
||||||
<tabstop>comboBoxSecondPoint</tabstop>
|
<tabstop>comboBoxSecondPoint</tabstop>
|
||||||
|
|
|
@ -472,8 +472,18 @@ void MainWindow::ClosedDialogShoulderPoint(int result)
|
||||||
*/
|
*/
|
||||||
void MainWindow::ToolNormal(bool checked)
|
void MainWindow::ToolNormal(bool checked)
|
||||||
{
|
{
|
||||||
SetToolButton<DialogNormal>(checked, Valentina::NormalTool, ":/cursor/normal_cursor.png",
|
SetToolButton2<DialogNormal>(checked, Valentina::NormalTool, ":/cursor/normal_cursor.png",
|
||||||
tr("Select first point of line"), &MainWindow::ClosedDialogNormal);
|
tr("Select first point of line"), &MainWindow::ClosedDialogNormal,
|
||||||
|
&MainWindow::ApplyDialogNormal);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief ApplyDialogNormal actions after apply in ApplyDialogNormal.
|
||||||
|
*/
|
||||||
|
void MainWindow::ApplyDialogNormal()
|
||||||
|
{
|
||||||
|
ApplyDialog<VToolNormal>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -483,7 +493,7 @@ void MainWindow::ToolNormal(bool checked)
|
||||||
*/
|
*/
|
||||||
void MainWindow::ClosedDialogNormal(int result)
|
void MainWindow::ClosedDialogNormal(int result)
|
||||||
{
|
{
|
||||||
ClosedDialog<VToolNormal>(result);
|
ClosedDialog2<VToolNormal>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -109,6 +109,7 @@ public slots:
|
||||||
void ApplyDialogAlongLine();
|
void ApplyDialogAlongLine();
|
||||||
void ClosedDialogShoulderPoint(int result);
|
void ClosedDialogShoulderPoint(int result);
|
||||||
void ClosedDialogNormal(int result);
|
void ClosedDialogNormal(int result);
|
||||||
|
void ApplyDialogNormal();
|
||||||
void ClosedDialogBisector(int result);
|
void ClosedDialogBisector(int result);
|
||||||
void ApplyDialogBisector();
|
void ApplyDialogBisector();
|
||||||
void ClosedDialogLineIntersect(int result);
|
void ClosedDialogLineIntersect(int result);
|
||||||
|
|
|
@ -66,7 +66,7 @@ void VToolNormal::setDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
|
VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
|
||||||
{
|
{
|
||||||
SCASSERT(dialog != nullptr);
|
SCASSERT(dialog != nullptr);
|
||||||
DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog);
|
DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog);
|
||||||
|
@ -77,12 +77,18 @@ void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
|
||||||
const QString typeLine = dialogTool->getTypeLine();
|
const QString typeLine = dialogTool->getTypeLine();
|
||||||
const QString pointName = dialogTool->getPointName();
|
const QString pointName = dialogTool->getPointName();
|
||||||
const qreal angle = dialogTool->getAngle();
|
const qreal angle = dialogTool->getAngle();
|
||||||
Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data,
|
VToolNormal *point = nullptr;
|
||||||
|
point=Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data,
|
||||||
Document::FullParse, Valentina::FromGui);
|
Document::FullParse, Valentina::FromGui);
|
||||||
|
if (point != nullptr)
|
||||||
|
{
|
||||||
|
point->dialog=dialogTool;
|
||||||
|
}
|
||||||
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
||||||
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
|
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
|
||||||
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||||
VPattern *doc, VContainer *data, const Document::Documents &parse,
|
VPattern *doc, VContainer *data, const Document::Documents &parse,
|
||||||
|
@ -121,7 +127,9 @@ void VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &fir
|
||||||
doc->AddTool(id, point);
|
doc->AddTool(id, point);
|
||||||
doc->IncrementReferens(firstPointId);
|
doc->IncrementReferens(firstPointId);
|
||||||
doc->IncrementReferens(secondPointId);
|
doc->IncrementReferens(secondPointId);
|
||||||
|
return point;
|
||||||
}
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
* @param doc dom document container.
|
* @param doc dom document container.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
*/
|
*/
|
||||||
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
* @param parse parser file mode.
|
* @param parse parser file mode.
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
*/
|
*/
|
||||||
static void Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
||||||
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
|
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
|
||||||
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||||
VPattern *doc, VContainer *data, const Document::Documents &parse,
|
VPattern *doc, VContainer *data, const Document::Documents &parse,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user