DialogArc change... Seems the end at last !!!

--HG--
branch : DialogTools
This commit is contained in:
Patrick Proy 2014-06-09 22:38:10 +02:00
parent 26067c3636
commit b300bfb8f8
9 changed files with 152 additions and 32 deletions

View File

@ -48,7 +48,9 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent)
timerF2 = new QTimer(this);
connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF2);
InitOkCancel(ui);
InitOkCancelApply(ui);
this->formulaBaseHeight=ui->plainTextEditFormula->height();
FillComboBoxPoints(ui->comboBoxBasePoint);
@ -64,9 +66,32 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent)
connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1);
connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF2);
connect(ui->lineEditRadius, &QLineEdit::textChanged, this, &DialogArc::RadiusChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogArc::RadiusChanged);
connect(ui->lineEditF1, &QLineEdit::textChanged, this, &DialogArc::F1Changed);
connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit);
ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down",
QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png")));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::DeployFormulaTextEdit()
{
if (ui->plainTextEditFormula->height() < DIALOGARC_MAX_FORMULA_HEIGHT)
{
ui->plainTextEditFormula->setFixedHeight(DIALOGARC_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")));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -100,7 +125,12 @@ void DialogArc::SetF1(const QString &value)
void DialogArc::SetRadius(const QString &value)
{
radius = value;
ui->lineEditRadius->setText(radius);
// increase height if needed.
if (radius.length() > 80)
{
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(radius);
}
//---------------------------------------------------------------------------------------------------------------------
@ -119,11 +149,24 @@ void DialogArc::ChoosedObject(quint32 id, const Valentina::Scenes &type)
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::DialogAccepted()
{
radius = ui->lineEditRadius->text();
this->SaveData();
emit DialogClosed(QDialog::Accepted);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::DialogApply()
{
this->SaveData();
emit DialogApplied();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::SaveData()
{
radius = ui->plainTextEditFormula->toPlainText();
radius.replace("\n"," ");
f1 = ui->lineEditF1->text();
f2 = ui->lineEditF2->text();
center = getCurrentObjectId(ui->comboBoxBasePoint);
emit DialogClosed(QDialog::Accepted);
}
//---------------------------------------------------------------------------------------------------------------------
@ -147,7 +190,7 @@ void DialogArc::ValChenged(int row)
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::PutRadius()
{
PutValHere(ui->lineEditRadius, ui->listWidget);
PutValHere(ui->plainTextEditFormula, ui->listWidget);
}
//---------------------------------------------------------------------------------------------------------------------
@ -173,7 +216,7 @@ void DialogArc::LineAngles()
void DialogArc::RadiusChanged()
{
labelEditFormula = ui->labelEditRadius;
ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius);
ValFormulaChanged(flagRadius, ui->plainTextEditFormula, timerRadius);
}
//---------------------------------------------------------------------------------------------------------------------
@ -195,13 +238,15 @@ void DialogArc::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagRadius && flagF1 && flagF2);
SCASSERT(bApply != nullptr);
bApply->setEnabled(flagRadius && flagF1 && flagF2);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::EvalRadius()
{
labelEditFormula = ui->labelEditRadius;
Eval(ui->lineEditRadius, flagRadius, timerRadius, ui->labelResultRadius);
Eval(ui->plainTextEditFormula, flagRadius, timerRadius, ui->labelResultRadius);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -31,6 +31,7 @@
#include "dialogtool.h"
#define DIALOGARC_MAX_FORMULA_HEIGHT 64
namespace Ui
{
class DialogArc;
@ -104,7 +105,11 @@ public slots:
/** TODO ISSUE 79 : create real function
* @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 ValChenged show description angles of lines
* @param row number of row
@ -146,6 +151,10 @@ protected:
virtual void CheckState();
private:
Q_DISABLE_COPY(DialogArc)
/**
* @brief SaveData Put dialog data in local variables
*/
void SaveData();
/**
* @brief ui keeps information about user interface
*/
@ -206,6 +215,10 @@ private:
* @brief ShowLineAngles show varibles angles of lines
*/
void ShowLineAngles();
/**
* @brief formulaBaseHeight base height defined by dialogui
*/
int formulaBaseHeight;
};
inline quint32 DialogArc::GetCenter() const

View File

@ -23,6 +23,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="labelEditRadius">
<property name="sizePolicy">
@ -74,15 +77,48 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditRadius">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<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>Formula for the calculation of radius of arc</string>
<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>
@ -580,14 +616,13 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEditRadius</tabstop>
<tabstop>lineEditF1</tabstop>
<tabstop>lineEditF2</tabstop>
<tabstop>comboBoxBasePoint</tabstop>

View File

@ -34,11 +34,6 @@
#include <QtWidgets>
#include "../../../libs/qmuparser/qmuparsererror.h"
// TODO : for issue #79
// replace lineEditFormula -> plainTextEditFormula
// delete lineEditFormala everywhrer
// delete PutValHere and eval overloaded functions
//---------------------------------------------------------------------------------------------------------------------
DialogTool::DialogTool(const VContainer *data, QWidget *parent)
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr),

View File

@ -376,7 +376,21 @@ protected:
* @param timer timer of formula
*/
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer);
/**
* @brief ValFormulaChanged handle change formula
* @param flag flag state of formula
* @param edit PlainTextEdit
* @param timer timer of formula
*/
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
/**
* @brief Eval evaluate formula and show result
* @param edit PlainTextEdit of formula
* @param flag flag state of formula
* @param timer timer of formula
* @param label label for signal error
*/
void Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label);
/**
* @brief Eval evaluate formula and show result
* @param edit lineEdit of formula
@ -384,7 +398,6 @@ protected:
* @param timer timer of formula
* @param label label for signal error
*/
void Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label);
void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label);
/**
* @brief setCurrentPointId set current point id in combobox

View File

@ -602,8 +602,18 @@ void MainWindow::ClosedDialogCutSpline(int result)
*/
void MainWindow::ToolArc(bool checked)
{
SetToolButton<DialogArc>(checked, Valentina::ArcTool, ":/cursor/arc_cursor.png",
tr("Select point of center of arc"), &MainWindow::ClosedDialogArc);
SetToolButtonWithApply<DialogArc>(checked, Valentina::ArcTool, ":/cursor/arc_cursor.png",
tr("Select point of center of arc"), &MainWindow::ClosedDialogArc,
&MainWindow::ApplyDialogArc);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ApplyDialogArc actions after apply in DialogArc.
*/
void MainWindow::ApplyDialogArc()
{
ApplyDialog<VToolArc>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -613,7 +623,7 @@ void MainWindow::ToolArc(bool checked)
*/
void MainWindow::ClosedDialogArc(int result)
{
ClosedDialog<VToolArc>(result);
ClosedDialogWithApply<VToolArc>(result);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -116,6 +116,7 @@ public slots:
void ClosedDialogLineIntersect(int result);
void ClosedDialogSpline(int result);
void ClosedDialogArc(int result);
void ApplyDialogArc();
void ClosedDialogSplinePath(int result);
void ClosedDialogCutSplinePath(int result);
void ClosedDialogPointOfContact(int result);

View File

@ -73,7 +73,7 @@ void VToolArc::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogArc *dialogTool = qobject_cast<DialogArc*>(dialog);
@ -82,11 +82,17 @@ void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *d
QString radius = dialogTool->GetRadius();
QString f1 = dialogTool->GetF1();
QString f2 = dialogTool->GetF2();
Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Valentina::FromGui);
VToolArc* point = nullptr;
point=Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Valentina::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
const Valentina::Sources &typeCreation)
{
@ -121,7 +127,9 @@ void VToolArc::Create(const quint32 _id, const quint32 &center, QString &radius,
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
doc->AddTool(id, toolArc);
doc->IncrementReferens(center);
return toolArc;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -61,7 +61,7 @@ public:
* @param doc dom document container
* @param data container with variables
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool form GUI.
* @param _id tool id, 0 if tool doesn't exist yet.
@ -75,7 +75,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
static VToolArc* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
const Valentina::Sources &typeCreation);
static const QString TagName;