Merge with DialogTools
--HG-- branch : develop
This commit is contained in:
commit
e1797f3033
|
@ -53,7 +53,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);
|
||||
|
||||
|
@ -69,9 +71,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")));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -121,7 +146,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);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -148,11 +178,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);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -183,7 +226,7 @@ void DialogArc::ValChenged(int row)
|
|||
*/
|
||||
void DialogArc::PutRadius()
|
||||
{
|
||||
PutValHere(ui->lineEditRadius, ui->listWidget);
|
||||
PutValHere(ui->plainTextEditFormula, ui->listWidget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -221,7 +264,7 @@ void DialogArc::LineAngles()
|
|||
void DialogArc::RadiusChanged()
|
||||
{
|
||||
labelEditFormula = ui->labelEditRadius;
|
||||
ValFormulaChanged(flagRadius, ui->lineEditRadius, timerRadius);
|
||||
ValFormulaChanged(flagRadius, ui->plainTextEditFormula, timerRadius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -252,6 +295,8 @@ void DialogArc::CheckState()
|
|||
{
|
||||
SCASSERT(bOk != nullptr);
|
||||
bOk->setEnabled(flagRadius && flagF1 && flagF2);
|
||||
SCASSERT(bApply != nullptr);
|
||||
bApply->setEnabled(flagRadius && flagF1 && flagF2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -261,7 +306,7 @@ void DialogArc::CheckState()
|
|||
void DialogArc::EvalRadius()
|
||||
{
|
||||
labelEditFormula = ui->labelEditRadius;
|
||||
Eval(ui->lineEditRadius, flagRadius, timerRadius, ui->labelResultRadius);
|
||||
Eval(ui->plainTextEditFormula, flagRadius, timerRadius, ui->labelResultRadius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "dialogtool.h"
|
||||
|
||||
#define DIALOGARC_MAX_FORMULA_HEIGHT 64
|
||||
namespace Ui
|
||||
{
|
||||
class DialogArc;
|
||||
|
@ -63,7 +64,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();
|
||||
virtual void ValChenged(int row);
|
||||
void PutRadius();
|
||||
void PutF1();
|
||||
|
@ -111,10 +116,17 @@ private:
|
|||
/** @brief f2 formula of second angle */
|
||||
QString f2;
|
||||
|
||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||
int formulaBaseHeight;
|
||||
|
||||
void EvalRadius();
|
||||
void EvalF1();
|
||||
void EvalF2();
|
||||
void ShowLineAngles();
|
||||
/**
|
||||
* @brief SaveData Put dialog data in local variables
|
||||
*/
|
||||
void SaveData();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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><html><head/><body><p>Show full calculation in message box</p></body></html></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>
|
||||
|
|
|
@ -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
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief DialogTool create dialog
|
||||
|
|
|
@ -208,8 +208,8 @@ protected:
|
|||
void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget);
|
||||
void ValFormulaChanged(bool &flag, QLineEdit *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(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label);
|
||||
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,
|
||||
ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline) const;
|
||||
|
|
|
@ -604,8 +604,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>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -615,7 +625,7 @@ void MainWindow::ToolArc(bool checked)
|
|||
*/
|
||||
void MainWindow::ClosedDialogArc(int result)
|
||||
{
|
||||
ClosedDialog<VToolArc>(result);
|
||||
ClosedDialogWithApply<VToolArc>(result);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 ¢er, QString &radius, QString &f1, QString &f2,
|
||||
VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, 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 ¢er, QString &radius,
|
|||
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
doc->AddTool(id, toolArc);
|
||||
doc->IncrementReferens(center);
|
||||
return toolArc;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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 ¢er, QString &radius, QString &f1, QString &f2,
|
||||
static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2,
|
||||
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
|
||||
const Valentina::Sources &typeCreation);
|
||||
static const QString TagName;
|
||||
|
|
Loading…
Reference in New Issue
Block a user