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)
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr),
bOk(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr), listWidget(nullptr),
labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr),
listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), lineStyles(QStringList()), associatedTool(nullptr)
@ -520,6 +520,9 @@ void DialogTool::CheckState()
{
Q_CHECK_PTR(bOk);
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);
virtual ~DialogTool() {}
inline VAbstractTool* GetAssociatedTool() { return this->associatedTool;}
inline void SetAssociatedTool(VAbstractTool* tool) { this->associatedTool=tool;}
inline VAbstractTool* GetAssociatedTool()
{
return this->associatedTool;
}
inline void SetAssociatedTool(VAbstractTool* tool)
{
this->associatedTool=tool;
}
signals:
/**
* @brief DialogClosed signal dialog closed
@ -219,6 +225,10 @@ protected:
* @brief bOk button ok
*/
QPushButton *bOk;
/**
* @brief bApply button apply
*/
QPushButton *bApply;
/**
* @brief spinBoxAngle spinbox for angle
*/
@ -474,10 +484,13 @@ protected:
Q_CHECK_PTR(bCancel);
connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
// TODO issue #79
QPushButton *bApply = ui->buttonBox->button(QDialogButtonBox::Apply);
bApply = ui->buttonBox->button(QDialogButtonBox::Apply);
Q_CHECK_PTR(bApply);
connect(bApply, &QPushButton::clicked, this, &DialogTool::DialogApply);
}
/**
* @brief associatedTool vdrawtool associated with opened dialog.
*/
VAbstractTool* associatedTool;
private:
/**

View file

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

View file

@ -534,11 +534,17 @@ private:
*/
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
*/

View file

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

View file

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

View file

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