DialogPointOfContact + DialogLine (no changes)

Also renamed specific functions in mainwindow

--HG--
branch : DialogTools
This commit is contained in:
Patrick Proy 2014-06-09 15:00:26 +02:00
parent a167cda90c
commit be8b8c9c95
9 changed files with 226 additions and 87 deletions

View File

@ -43,7 +43,6 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent)
labelEditFormula = ui->labelEditFormula; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
// TODO : auto extend height on first value length.
this->formulaBaseHeight=ui->plainTextEditFormula->height(); this->formulaBaseHeight=ui->plainTextEditFormula->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);

View File

@ -36,7 +36,7 @@ DialogLine::DialogLine(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0), typeLine(QString()) :DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0), typeLine(QString())
{ {
ui->setupUi(this); ui->setupUi(this);
InitOkCancelApply(ui); InitOkCancel(ui);
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);

View File

@ -32,60 +32,95 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent) DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0), :DialogTool(data, parent), ui(new Ui::DialogPointOfContact), number(0), pointName(QString()), radius(QString()), center(0),
firstPoint(0), secondPoint(0) firstPoint(0), secondPoint(0)
{ {
ui.setupUi(this); ui->setupUi(this);
listWidget = ui.listWidget; InitVariables(ui);
labelResultCalculation = ui.labelResultCalculation; listWidget = ui->listWidget;
labelDescription = ui.labelDescription; labelResultCalculation = ui->labelResultCalculation;
radioButtonSizeGrowth = ui.radioButtonSizeGrowth; labelDescription = ui->labelDescription;
radioButtonStandardTable = ui.radioButtonStandardTable; radioButtonSizeGrowth = ui->radioButtonSizeGrowth;
radioButtonIncrements = ui.radioButtonIncrements; radioButtonStandardTable = ui->radioButtonStandardTable;
radioButtonLengthLine = ui.radioButtonLengthLine; radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthArc = ui.radioButtonLengthArc; radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthCurve = ui.radioButtonLengthSpline; radioButtonLengthArc = ui->radioButtonLengthArc;
lineEditFormula = ui.lineEditFormula; radioButtonLengthCurve = ui->radioButtonLengthSpline;
labelEditFormula = ui.labelEditFormula; plainTextEditFormula = ui->plainTextEditFormula;
labelEditNamePoint = ui.labelEditNamePoint; labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui.buttonBox->button(QDialogButtonBox::Ok); InitOkCancelApply(ui);
/* bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr); SCASSERT(bOk != nullptr);
connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted);
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
SCASSERT(bCansel != nullptr); SCASSERT(bCansel != nullptr);
connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected); connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
*/
flagFormula = false; flagFormula = false;
flagName = false; flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui.comboBoxCenter); FillComboBoxPoints(ui->comboBoxCenter);
FillComboBoxPoints(ui.comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui.comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere);
connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal);
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged);
if (qApp->patternType() == Pattern::Standard) if (qApp->patternType() == Pattern::Standard)
{ {
SizeHeight(); SizeHeight();
connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight); connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight);
} }
else else
{ {
radioButtonSizeGrowth->setVisible(false); radioButtonSizeGrowth->setVisible(false);
Measurements(); Measurements();
} }
connect(ui.radioButtonStandardTable, &QRadioButton::clicked, this, &DialogPointOfContact::Measurements); connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, &DialogPointOfContact::Measurements);
connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments);
connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines); connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines);
connect(ui.radioButtonLengthArc, &QRadioButton::clicked, this, &DialogPointOfContact::LengthArcs); connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogPointOfContact::LengthArcs);
connect(ui.radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogPointOfContact::LengthCurves); connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogPointOfContact::LengthCurves);
connect(ui.toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula);
connect(ui.lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged);
connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogPointOfContact::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogPointOfContact::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::FormulaTextChanged()
{
// TODO issue #79 : back to FormulaChanged when full update
// Also remove this function if only one function called here
this->FormulaChanged2();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::DeployFormulaTextEdit()
{
if (ui->plainTextEditFormula->height() < DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT)
{
ui->plainTextEditFormula->setFixedHeight(DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight);
//Set icon from theme (internal for Windows system)
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -96,10 +131,10 @@ void DialogPointOfContact::ChoosedObject(quint32 id, const Valentina::Scenes &ty
const VPointF *point = data->GeometricObject<const VPointF *>(id); const VPointF *point = data->GeometricObject<const VPointF *>(id);
if (number == 0) if (number == 0)
{ {
qint32 index = ui.comboBoxFirstPoint->findText(point->name()); qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 ) if ( index != -1 )
{ // -1 for not found { // -1 for not found
ui.comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point of line")); emit ToolTip(tr("Select second point of line"));
return; return;
@ -107,10 +142,10 @@ void DialogPointOfContact::ChoosedObject(quint32 id, const Valentina::Scenes &ty
} }
if (number == 1) if (number == 1)
{ {
qint32 index = ui.comboBoxSecondPoint->findText(point->name()); qint32 index = ui->comboBoxSecondPoint->findText(point->name());
if ( index != -1 ) if ( index != -1 )
{ // -1 for not found { // -1 for not found
ui.comboBoxSecondPoint->setCurrentIndex(index); ui->comboBoxSecondPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select point of center of arc")); emit ToolTip(tr("Select point of center of arc"));
return; return;
@ -118,10 +153,10 @@ void DialogPointOfContact::ChoosedObject(quint32 id, const Valentina::Scenes &ty
} }
if (number == 2) if (number == 2)
{ {
qint32 index = ui.comboBoxCenter->findText(point->name()); qint32 index = ui->comboBoxCenter->findText(point->name());
if ( index != -1 ) if ( index != -1 )
{ // -1 for not found { // -1 for not found
ui.comboBoxCenter->setCurrentIndex(index); ui->comboBoxCenter->setCurrentIndex(index);
number = 0; number = 0;
emit ToolTip(""); emit ToolTip("");
} }
@ -136,30 +171,43 @@ void DialogPointOfContact::ChoosedObject(quint32 id, const Valentina::Scenes &ty
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::DialogAccepted() void DialogPointOfContact::DialogAccepted()
{ {
pointName = ui.lineEditNamePoint->text(); this->SaveData();
radius = ui.lineEditFormula->text();
center = getCurrentObjectId(ui.comboBoxCenter);
firstPoint = getCurrentObjectId(ui.comboBoxFirstPoint);
secondPoint = getCurrentObjectId(ui.comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::DialogApply()
{
this->SaveData();
emit DialogApplied();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::SaveData()
{
pointName = ui->lineEditNamePoint->text();
radius = ui->plainTextEditFormula->toPlainText();
radius.replace("\n"," ");
center = getCurrentObjectId(ui->comboBoxCenter);
firstPoint = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPoint = getCurrentObjectId(ui->comboBoxSecondPoint);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::setSecondPoint(const quint32 &value, const quint32 &id) void DialogPointOfContact::setSecondPoint(const quint32 &value, const quint32 &id)
{ {
setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id); setCurrentPointId(ui->comboBoxSecondPoint, secondPoint, value, id);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::setFirstPoint(const quint32 &value, const quint32 &id) void DialogPointOfContact::setFirstPoint(const quint32 &value, const quint32 &id)
{ {
setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id); setCurrentPointId(ui->comboBoxFirstPoint, firstPoint, value, id);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::setCenter(const quint32 &value, const quint32 &id) void DialogPointOfContact::setCenter(const quint32 &value, const quint32 &id)
{ {
setCurrentPointId(ui.comboBoxCenter, center, value, id); setCurrentPointId(ui->comboBoxCenter, center, value, id);
center = value; center = value;
} }
@ -167,12 +215,17 @@ void DialogPointOfContact::setCenter(const quint32 &value, const quint32 &id)
void DialogPointOfContact::setRadius(const QString &value) void DialogPointOfContact::setRadius(const QString &value)
{ {
radius = value; radius = value;
ui.lineEditFormula->setText(radius); // increase height if needed.
if (radius.length() > 80)
{
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(radius);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::setPointName(const QString &value) void DialogPointOfContact::setPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui.lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }

View File

@ -32,6 +32,11 @@
#include "ui_dialogpointofcontact.h" #include "ui_dialogpointofcontact.h"
#include "dialogtool.h" #include "dialogtool.h"
#define DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT 64
namespace Ui
{
class DialogPointOfContact;
}
/** /**
* @brief The DialogPointOfContact class dialog for ToolPointOfContact. Help create point and edit option. * @brief The DialogPointOfContact class dialog for ToolPointOfContact. Help create point and edit option.
*/ */
@ -109,16 +114,28 @@ 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(DialogPointOfContact) Q_DISABLE_COPY(DialogPointOfContact)
/**
* @brief SaveData Put dialog data in local variables
*/
void SaveData();
/** /**
* @brief ui keeps information about user interface * @brief ui keeps information about user interface
*/ */
Ui::DialogPointOfContact ui; Ui::DialogPointOfContact *ui;
/** /**
* @brief number number of handled objects * @brief number number of handled objects
*/ */
@ -143,6 +160,10 @@ private:
* @brief secondPoint id second point of line * @brief secondPoint id second point of line
*/ */
quint32 secondPoint; quint32 secondPoint;
/**
* @brief formulaBaseHeight base height defined by dialogui
*/
int formulaBaseHeight;
}; };
inline QString DialogPointOfContact::getPointName() const inline QString DialogPointOfContact::getPointName() const

View File

@ -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 radius of arc</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
@ -441,14 +491,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>comboBoxCenter</tabstop> <tabstop>comboBoxCenter</tabstop>
<tabstop>comboBoxFirstPoint</tabstop> <tabstop>comboBoxFirstPoint</tabstop>

View File

@ -264,7 +264,7 @@ template <typename Dialog, typename Func, typename Func2>
* @param closeDialogSlot function to handle close of dialog. * @param closeDialogSlot function to handle close of dialog.
* @param applyDialogSlot function to handle apply in dialog. * @param applyDialogSlot function to handle apply in dialog.
*/ */
void MainWindow::SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, void MainWindow::SetToolButtonWithApply(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot, Func2 applyDialogSlot) Func closeDialogSlot, Func2 applyDialogSlot)
{ {
if (checked) if (checked)
@ -314,7 +314,7 @@ void MainWindow::ClosedDialog(int result)
*/ */
// TODO ISSUE 79 : rename // TODO ISSUE 79 : rename
template <typename DrawTool> template <typename DrawTool>
void MainWindow::ClosedDialog2(int result) void MainWindow::ClosedDialogWithApply(int result)
{ {
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
@ -370,7 +370,7 @@ void MainWindow::ToolEndLine(bool checked)
{// TODO ISSUE 79 : copy {// TODO ISSUE 79 : copy
// SetToolButton<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), // SetToolButton<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
// &MainWindow::ClosedDialogEndLine); // &MainWindow::ClosedDialogEndLine);
SetToolButton2<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), SetToolButtonWithApply<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
&MainWindow::ClosedDialogEndLine,&MainWindow::ApplyDialogEndLine); &MainWindow::ClosedDialogEndLine,&MainWindow::ApplyDialogEndLine);
} }
@ -390,7 +390,7 @@ void MainWindow::ApplyDialogEndLine()
*/ */
void MainWindow::ClosedDialogEndLine(int result) void MainWindow::ClosedDialogEndLine(int result)
{ {
ClosedDialog2<VToolEndLine>(result); ClosedDialogWithApply<VToolEndLine>(result);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -421,7 +421,7 @@ void MainWindow::ClosedDialogLine(int result)
*/ */
void MainWindow::ToolAlongLine(bool checked) void MainWindow::ToolAlongLine(bool checked)
{ {
SetToolButton2<DialogAlongLine>(checked, Valentina::AlongLineTool, ":/cursor/alongline_cursor.png", SetToolButtonWithApply<DialogAlongLine>(checked, Valentina::AlongLineTool, ":/cursor/alongline_cursor.png",
tr("Select point"), &MainWindow::ClosedDialogAlongLine, &MainWindow::ApplyDialogAlongLine); tr("Select point"), &MainWindow::ClosedDialogAlongLine, &MainWindow::ApplyDialogAlongLine);
} }
@ -441,7 +441,7 @@ void MainWindow::ApplyDialogAlongLine()
*/ */
void MainWindow::ClosedDialogAlongLine(int result) void MainWindow::ClosedDialogAlongLine(int result)
{ {
ClosedDialog2<VToolAlongLine>(result); ClosedDialogWithApply<VToolAlongLine>(result);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -451,7 +451,7 @@ void MainWindow::ClosedDialogAlongLine(int result)
*/ */
void MainWindow::ToolShoulderPoint(bool checked) void MainWindow::ToolShoulderPoint(bool checked)
{ {
SetToolButton2<DialogShoulderPoint>(checked, Valentina::ShoulderPointTool, ":/cursor/shoulder_cursor.png", SetToolButtonWithApply<DialogShoulderPoint>(checked, Valentina::ShoulderPointTool, ":/cursor/shoulder_cursor.png",
tr("Select first point of line"), &MainWindow::ClosedDialogShoulderPoint, tr("Select first point of line"), &MainWindow::ClosedDialogShoulderPoint,
&MainWindow::ApplyDialogShoulderPoint); &MainWindow::ApplyDialogShoulderPoint);
} }
@ -472,7 +472,7 @@ void MainWindow::ApplyDialogShoulderPoint()
*/ */
void MainWindow::ClosedDialogShoulderPoint(int result) void MainWindow::ClosedDialogShoulderPoint(int result)
{ {
ClosedDialog2<VToolShoulderPoint>(result); ClosedDialogWithApply<VToolShoulderPoint>(result);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -482,7 +482,7 @@ void MainWindow::ClosedDialogShoulderPoint(int result)
*/ */
void MainWindow::ToolNormal(bool checked) void MainWindow::ToolNormal(bool checked)
{ {
SetToolButton2<DialogNormal>(checked, Valentina::NormalTool, ":/cursor/normal_cursor.png", SetToolButtonWithApply<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); &MainWindow::ApplyDialogNormal);
} }
@ -503,7 +503,7 @@ void MainWindow::ApplyDialogNormal()
*/ */
void MainWindow::ClosedDialogNormal(int result) void MainWindow::ClosedDialogNormal(int result)
{ {
ClosedDialog2<VToolNormal>(result); ClosedDialogWithApply<VToolNormal>(result);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -513,7 +513,7 @@ void MainWindow::ClosedDialogNormal(int result)
*/ */
void MainWindow::ToolBisector(bool checked) void MainWindow::ToolBisector(bool checked)
{ {
SetToolButton2<DialogBisector>(checked, Valentina::BisectorTool, ":/cursor/bisector_cursor.png", SetToolButtonWithApply<DialogBisector>(checked, Valentina::BisectorTool, ":/cursor/bisector_cursor.png",
tr("Select first point of angle"), &MainWindow::ClosedDialogBisector, tr("Select first point of angle"), &MainWindow::ClosedDialogBisector,
&MainWindow::ApplyDialogBisector); &MainWindow::ApplyDialogBisector);
} }
@ -534,7 +534,7 @@ void MainWindow::ApplyDialogBisector()
*/ */
void MainWindow::ClosedDialogBisector(int result) void MainWindow::ClosedDialogBisector(int result)
{ {
ClosedDialog2<VToolBisector>(result); ClosedDialogWithApply<VToolBisector>(result);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -671,8 +671,18 @@ void MainWindow::ClosedDialogCutSplinePath(int result)
*/ */
void MainWindow::ToolPointOfContact(bool checked) void MainWindow::ToolPointOfContact(bool checked)
{ {
SetToolButton<DialogPointOfContact>(checked, Valentina::PointOfContact, ":/cursor/pointcontact_cursor.png", SetToolButtonWithApply<DialogPointOfContact>(checked, Valentina::PointOfContact, ":/cursor/pointcontact_cursor.png",
tr("Select first point of line"), &MainWindow::ClosedDialogPointOfContact); tr("Select first point of line"), &MainWindow::ClosedDialogPointOfContact,
&MainWindow::ApplyDialogPointOfContact);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ApplyDialogPointOfContact actions after apply in DialogPointOfContact.
*/
void MainWindow::ApplyDialogPointOfContact()
{
ApplyDialog<VToolPointOfContact>();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -682,7 +692,7 @@ void MainWindow::ToolPointOfContact(bool checked)
*/ */
void MainWindow::ClosedDialogPointOfContact(int result) void MainWindow::ClosedDialogPointOfContact(int result)
{ {
ClosedDialog<VToolPointOfContact>(result); ClosedDialogWithApply<VToolPointOfContact>(result);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -119,6 +119,7 @@ public slots:
void ClosedDialogSplinePath(int result); void ClosedDialogSplinePath(int result);
void ClosedDialogCutSplinePath(int result); void ClosedDialogCutSplinePath(int result);
void ClosedDialogPointOfContact(int result); void ClosedDialogPointOfContact(int result);
void ApplyDialogPointOfContact();
void ClosedDialogDetail(int result); void ClosedDialogDetail(int result);
void ClosedDialogHeight(int result); void ClosedDialogHeight(int result);
void ClosedDialogTriangle(int result); void ClosedDialogTriangle(int result);
@ -218,17 +219,15 @@ private:
void MinimumScrollBar(); void MinimumScrollBar();
template <typename Dialog, typename Func> template <typename Dialog, typename Func>
// TODO ISSUE 79 : delete
void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot); Func closeDialogSlot);
template <typename Dialog, typename Func, typename Func2> template <typename Dialog, typename Func, typename Func2>
// TODO ISSUE 79 : copy void SetToolButtonWithApply(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
void SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot, Func2 applyDialogSlot); Func closeDialogSlot, Func2 applyDialogSlot);
template <typename DrawTool> template <typename DrawTool>
void ClosedDialog(int result); void ClosedDialog(int result);
template <typename DrawTool> template <typename DrawTool>
void ClosedDialog2(int result); void ClosedDialogWithApply(int result);
template <typename DrawTool> template <typename DrawTool>
void ApplyDialog(); void ApplyDialog();
bool SavePattern(const QString &curFile); bool SavePattern(const QString &curFile);

View File

@ -92,7 +92,7 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF &cente
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{ {
SCASSERT(dialog != nullptr); SCASSERT(dialog != nullptr);
DialogPointOfContact *dialogTool = qobject_cast<DialogPointOfContact*>(dialog); DialogPointOfContact *dialogTool = qobject_cast<DialogPointOfContact*>(dialog);
@ -102,12 +102,18 @@ void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene,
const quint32 firstPointId = dialogTool->getFirstPoint(); const quint32 firstPointId = dialogTool->getFirstPoint();
const quint32 secondPointId = dialogTool->getSecondPoint(); const quint32 secondPointId = dialogTool->getSecondPoint();
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data, VToolPointOfContact *point = nullptr;
point=Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui); Document::FullParse, Valentina::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 &center, const quint32 &firstPointId, VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 &center, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &pointName, const qreal &mx, const quint32 &secondPointId, const QString &pointName, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation) const Document::Documents &parse, const Valentina::Sources &typeCreation)
@ -151,7 +157,9 @@ void VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint
doc->IncrementReferens(center); doc->IncrementReferens(center);
doc->IncrementReferens(firstPointId); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId); doc->IncrementReferens(secondPointId);
return point;
} }
return nullptr;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -74,7 +74,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 VToolPointOfContact* 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.
@ -91,7 +91,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 &arcRadius, const quint32 &center, static VToolPointOfContact* Create(const quint32 _id, QString &arcRadius, const quint32 &center,
const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName, const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation);