Merge with DialogTools

--HG--
branch : develop
This commit is contained in:
dismine 2014-06-10 12:23:39 +03:00
commit e1797f3033
9 changed files with 139 additions and 33 deletions

View File

@ -53,7 +53,9 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent)
timerF2 = new QTimer(this); timerF2 = new QTimer(this);
connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF2); connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF2);
InitOkCancel(ui); InitOkCancelApply(ui);
this->formulaBaseHeight=ui->plainTextEditFormula->height();
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);
@ -69,9 +71,32 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent)
connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1); connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1);
connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF2); 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->lineEditF1, &QLineEdit::textChanged, this, &DialogArc::F1Changed);
connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed); 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")));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -121,7 +146,12 @@ void DialogArc::SetF1(const QString &value)
void DialogArc::SetRadius(const QString &value) void DialogArc::SetRadius(const QString &value)
{ {
radius = value; radius = value;
ui->lineEditRadius->setText(radius); // increase height if needed.
if (radius.length() > 80)
{
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(radius);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -148,11 +178,24 @@ void DialogArc::ChoosedObject(quint32 id, const Valentina::Scenes &type)
*/ */
void DialogArc::DialogAccepted() 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(); f1 = ui->lineEditF1->text();
f2 = ui->lineEditF2->text(); f2 = ui->lineEditF2->text();
center = getCurrentObjectId(ui->comboBoxBasePoint); center = getCurrentObjectId(ui->comboBoxBasePoint);
emit DialogClosed(QDialog::Accepted);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -183,7 +226,7 @@ void DialogArc::ValChenged(int row)
*/ */
void DialogArc::PutRadius() void DialogArc::PutRadius()
{ {
PutValHere(ui->lineEditRadius, ui->listWidget); PutValHere(ui->plainTextEditFormula, ui->listWidget);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -221,7 +264,7 @@ void DialogArc::LineAngles()
void DialogArc::RadiusChanged() void DialogArc::RadiusChanged()
{ {
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius); ValFormulaChanged(flagRadius, ui->plainTextEditFormula, timerRadius);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -252,6 +295,8 @@ void DialogArc::CheckState()
{ {
SCASSERT(bOk != nullptr); SCASSERT(bOk != nullptr);
bOk->setEnabled(flagRadius && flagF1 && flagF2); bOk->setEnabled(flagRadius && flagF1 && flagF2);
SCASSERT(bApply != nullptr);
bApply->setEnabled(flagRadius && flagF1 && flagF2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -261,7 +306,7 @@ void DialogArc::CheckState()
void DialogArc::EvalRadius() void DialogArc::EvalRadius()
{ {
labelEditFormula = ui->labelEditRadius; 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" #include "dialogtool.h"
#define DIALOGARC_MAX_FORMULA_HEIGHT 64
namespace Ui namespace Ui
{ {
class DialogArc; class DialogArc;
@ -63,7 +64,11 @@ public slots:
/** TODO ISSUE 79 : create real function /** 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();
virtual void ValChenged(int row); virtual void ValChenged(int row);
void PutRadius(); void PutRadius();
void PutF1(); void PutF1();
@ -111,10 +116,17 @@ private:
/** @brief f2 formula of second angle */ /** @brief f2 formula of second angle */
QString f2; QString f2;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
void EvalRadius(); void EvalRadius();
void EvalF1(); void EvalF1();
void EvalF2(); void EvalF2();
void ShowLineAngles(); void ShowLineAngles();
/**
* @brief SaveData Put dialog data in local variables
*/
void SaveData();
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -23,6 +23,9 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item> <item>
<widget class="QLabel" name="labelEditRadius"> <widget class="QLabel" name="labelEditRadius">
<property name="sizePolicy"> <property name="sizePolicy">
@ -74,15 +77,48 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditRadius"> <widget class="QPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy"> <property name="maximumSize">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <size>
<horstretch>0</horstretch> <width>16777215</width>
<verstretch>0</verstretch> <height>24</height>
</sizepolicy> </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>
<property name="toolTip"> <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> </property>
</widget> </widget>
</item> </item>
@ -580,14 +616,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>lineEditRadius</tabstop>
<tabstop>lineEditF1</tabstop> <tabstop>lineEditF1</tabstop>
<tabstop>lineEditF2</tabstop> <tabstop>lineEditF2</tabstop>
<tabstop>comboBoxBasePoint</tabstop> <tabstop>comboBoxBasePoint</tabstop>

View File

@ -34,11 +34,6 @@
#include <QtWidgets> #include <QtWidgets>
#include "../../../libs/qmuparser/qmuparsererror.h" #include "../../../libs/qmuparser/qmuparsererror.h"
// TODO : for issue #79
// replace lineEditFormula -> plainTextEditFormula
// delete lineEditFormala everywhrer
// delete PutValHere and eval overloaded functions
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief DialogTool create dialog * @brief DialogTool create dialog

View File

@ -208,8 +208,8 @@ protected:
void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget);
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer);
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label);
void Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label); void Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label);
void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label);
void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id) const; void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id) const;
void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, const quint32 &id, void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, const quint32 &id,
ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline) const; ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline) const;

View File

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

View File

@ -116,6 +116,7 @@ public slots:
void ClosedDialogLineIntersect(int result); void ClosedDialogLineIntersect(int result);
void ClosedDialogSpline(int result); void ClosedDialogSpline(int result);
void ClosedDialogArc(int result); void ClosedDialogArc(int result);
void ApplyDialogArc();
void ClosedDialogSplinePath(int result); void ClosedDialogSplinePath(int result);
void ClosedDialogCutSplinePath(int result); void ClosedDialogCutSplinePath(int result);
void ClosedDialogPointOfContact(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); SCASSERT(dialog != nullptr);
DialogArc *dialogTool = qobject_cast<DialogArc*>(dialog); DialogArc *dialogTool = qobject_cast<DialogArc*>(dialog);
@ -82,11 +82,17 @@ void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *d
QString radius = dialogTool->GetRadius(); QString radius = dialogTool->GetRadius();
QString f1 = dialogTool->GetF1(); QString f1 = dialogTool->GetF1();
QString f2 = dialogTool->GetF2(); 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, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
const Valentina::Sources &typeCreation) 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); connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
doc->AddTool(id, toolArc); doc->AddTool(id, toolArc);
doc->IncrementReferens(center); doc->IncrementReferens(center);
return toolArc;
} }
return nullptr;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -61,7 +61,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 VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/** /**
* @brief Create help create tool form GUI. * @brief Create help create tool form GUI.
* @param _id tool id, 0 if tool doesn't exist yet. * @param _id tool id, 0 if tool doesn't exist yet.
@ -75,7 +75,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, 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, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
const Valentina::Sources &typeCreation); const Valentina::Sources &typeCreation);
static const QString TagName; static const QString TagName;