Multi lines for formula and apply button are now working for DialogEndLine

--HG--
branch : DialogTools
This commit is contained in:
Patrick Proy 2014-05-26 13:48:42 +02:00
parent e645e671de
commit 5cb0a5cf96
7 changed files with 81 additions and 17 deletions

View File

@ -41,8 +41,8 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogTool::DialogTool(const VContainer *data, QWidget *parent) DialogTool::DialogTool(const VContainer *data, QWidget *parent)
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr), :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr),
bOk(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr), listWidget(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr),
labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr), listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr), labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), lineStyles(QStringList()), associatedTool(nullptr) radioButtonLengthCurve(nullptr), lineStyles(QStringList()), associatedTool(nullptr)
@ -520,6 +520,9 @@ void DialogTool::CheckState()
{ {
Q_CHECK_PTR(bOk); Q_CHECK_PTR(bOk);
bOk->setEnabled(flagFormula && flagName); bOk->setEnabled(flagFormula && flagName);
Q_CHECK_PTR(bApply);
bApply->setEnabled(flagFormula && flagName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -70,8 +70,14 @@ public:
*/ */
DialogTool(const VContainer *data, QWidget *parent = nullptr); DialogTool(const VContainer *data, QWidget *parent = nullptr);
virtual ~DialogTool() {} virtual ~DialogTool() {}
inline VAbstractTool* GetAssociatedTool() { return this->associatedTool;} inline VAbstractTool* GetAssociatedTool()
inline void SetAssociatedTool(VAbstractTool* tool) { this->associatedTool=tool;} {
return this->associatedTool;
}
inline void SetAssociatedTool(VAbstractTool* tool)
{
this->associatedTool=tool;
}
signals: signals:
/** /**
* @brief DialogClosed signal dialog closed * @brief DialogClosed signal dialog closed
@ -219,6 +225,10 @@ protected:
* @brief bOk button ok * @brief bOk button ok
*/ */
QPushButton *bOk; QPushButton *bOk;
/**
* @brief bApply button apply
*/
QPushButton *bApply;
/** /**
* @brief spinBoxAngle spinbox for angle * @brief spinBoxAngle spinbox for angle
*/ */
@ -474,10 +484,13 @@ protected:
Q_CHECK_PTR(bCancel); Q_CHECK_PTR(bCancel);
connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected); connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
// TODO issue #79 // TODO issue #79
QPushButton *bApply = ui->buttonBox->button(QDialogButtonBox::Apply); bApply = ui->buttonBox->button(QDialogButtonBox::Apply);
Q_CHECK_PTR(bApply); Q_CHECK_PTR(bApply);
connect(bApply, &QPushButton::clicked, this, &DialogTool::DialogApply); connect(bApply, &QPushButton::clicked, this, &DialogTool::DialogApply);
} }
/**
* @brief associatedTool vdrawtool associated with opened dialog.
*/
VAbstractTool* associatedTool; VAbstractTool* associatedTool;
private: private:
/** /**

View File

@ -264,14 +264,38 @@ void MainWindow::SetToolButton2(bool checked, Valentina::Tools t, const QString
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename DrawTool> template <typename DrawTool>
void MainWindow::ClosedDialog(int result) void MainWindow::ClosedDialog(int result)
{ {// TODO ISSUE 79 : delete
Q_CHECK_PTR(dialogTool); Q_CHECK_PTR(dialogTool);
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
{
if (dialogTool->GetAssociatedTool() == nullptr)
{ {
DrawTool::Create(dialogTool, currentScene, doc, pattern); DrawTool::Create(dialogTool, currentScene, doc, pattern);
} }
ArrowTool();
}
//---------------------------------------------------------------------------------------------------------------------
template <typename DrawTool>
void MainWindow::ClosedDialog2(int result)
{ // TODO ISSUE 79 : rename
Q_CHECK_PTR(dialogTool);
if (result == QDialog::Accepted)
{
// Only create tool if not already created with apply
if (dialogTool->GetAssociatedTool() == nullptr)
{
dialogTool->SetAssociatedTool(
dynamic_cast<VAbstractTool * > (DrawTool::Create(dialogTool, currentScene, doc, pattern)));
}
else
{ // Or update associated tool with data
VDrawTool * vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
vtool->FullUpdateFromGuiApply();
}
}
if (dialogTool->GetAssociatedTool() != nullptr)
{
VDrawTool * vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
vtool->DialogLinkDestroy();
} }
ArrowTool(); ArrowTool();
} }
@ -282,20 +306,22 @@ void MainWindow::ApplyDialog()
{// TODO ISSUE 79 : copy {// TODO ISSUE 79 : copy
Q_CHECK_PTR(dialogTool); Q_CHECK_PTR(dialogTool);
// TODO ISSUE 79 : Only create on first apply for now, // Only create tool if not already created with apply
// need function for updating in dialogtools or drawtool
if (dialogTool->GetAssociatedTool() == nullptr) if (dialogTool->GetAssociatedTool() == nullptr)
{ {
dialogTool->SetAssociatedTool( dialogTool->SetAssociatedTool(
dynamic_cast<VAbstractTool * > (DrawTool::Create(dialogTool, currentScene, doc, pattern))); static_cast<VAbstractTool * > (DrawTool::Create(dialogTool, currentScene, doc, pattern)));
}
else
{ // Or update associated tool with data
VDrawTool * vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
vtool->FullUpdateFromGuiApply();
} }
//ArrowTool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolEndLine(bool checked) void MainWindow::ToolEndLine(bool checked)
{ {// 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"), SetToolButton2<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
@ -311,7 +337,7 @@ void MainWindow::ApplyDialogEndLine()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ClosedDialogEndLine(int result) void MainWindow::ClosedDialogEndLine(int result)
{ {
ClosedDialog<VToolEndLine>(result); ClosedDialog2<VToolEndLine>(result);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -534,11 +534,17 @@ private:
*/ */
void MinimumScrollBar(); void MinimumScrollBar();
template <typename DrawTool> template <typename DrawTool>
/** /** // TODO ISSUE 79 : delete
* @brief ClosedDialog handle close dialog * @brief ClosedDialog handle close dialog
* @param result result working dialog. * @param result result working dialog.
*/ */
void ClosedDialog(int result); 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 /** // TODO ISSUE 79 : copy
* @brief ApplyDialog handle apply in dialog * @brief ApplyDialog handle apply in dialog
*/ */

View File

@ -107,6 +107,12 @@ void VDrawTool::FullUpdateFromGuiApply()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::DialogLinkDestroy()
{
this->dialog=nullptr;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDrawTool::SetFactor(qreal factor) void VDrawTool::SetFactor(qreal factor)
{ {

View File

@ -55,6 +55,10 @@ public:
* @brief setDialog set dialog when user want change tool option. * @brief setDialog set dialog when user want change tool option.
*/ */
virtual void setDialog() {} virtual void setDialog() {}
/**
* @brief DialogLinkDestroy removes dialog pointer
*/
virtual void DialogLinkDestroy();
/** /**
* @brief ignoreContextMenu set ignore contect menu tool. * @brief ignoreContextMenu set ignore contect menu tool.
* @param enable true - ignore. * @param enable true - ignore.

View File

@ -76,8 +76,14 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene
QString formula = dialogTool->getFormula(); QString formula = dialogTool->getFormula();
qreal angle = dialogTool->getAngle(); qreal angle = dialogTool->getAngle();
quint32 basePointId = dialogTool->getBasePointId(); quint32 basePointId = dialogTool->getBasePointId();
return Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
VToolEndLine *point;
point=Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
Valentina::FromGui); Valentina::FromGui);
if (point != nullptr) {
point->dialog=dialogTool;
}
return point;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------