Fix several bugs in dialogs.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-29 16:29:09 +02:00
parent 3677a0484f
commit 8bb3377a60
3 changed files with 24 additions and 21 deletions

View File

@ -37,8 +37,7 @@
DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogPiecePath),
m_showMode(false),
m_saWidth(0)
m_showMode(false)
{
ui->setupUi(this);
InitOkCancel(ui);
@ -88,15 +87,7 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
connect(ui->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPiecePath::NodeAngleChanged);
if (not m_showMode)
{
vis = new VisToolPiecePath(data);
}
else
{
ui->comboBoxType->setDisabled(true);
ui->comboBoxPiece->setDisabled(true);
}
vis = new VisToolPiecePath(data);
ui->tabWidget->removeTab(1);
}
@ -111,6 +102,8 @@ DialogPiecePath::~DialogPiecePath()
void DialogPiecePath::EnbleShowMode(bool disable)
{
m_showMode = disable;
ui->comboBoxType->setDisabled(m_showMode);
ui->comboBoxPiece->setDisabled(m_showMode);
}
//---------------------------------------------------------------------------------------------------------------------
@ -308,7 +301,7 @@ void DialogPiecePath::NodeChanged(int index)
qreal w1 = node.GetSABefore();
if (w1 < 0)
{
w1 = m_saWidth;
w1 = ui->doubleSpinBoxSeams->value();
}
else
{
@ -319,7 +312,7 @@ void DialogPiecePath::NodeChanged(int index)
qreal w2 = node.GetSAAfter();
if (w2 < 0)
{
w2 = m_saWidth;
w2 = ui->doubleSpinBoxSeams->value();
}
else
{
@ -588,6 +581,8 @@ void DialogPiecePath::SetPieceId(quint32 id)
ui->comboBoxType->setCurrentIndex(index);
}
}
ValidObjects(PathIsValid());
}
//---------------------------------------------------------------------------------------------------------------------
@ -595,8 +590,8 @@ void DialogPiecePath::SetSAWidth(qreal width)
{
if (width >=0)
{
m_saWidth = width;
ui->tabWidget->addTab(ui->tabSeamAllowance, QString());
ui->tabWidget->addTab(ui->tabSeamAllowance, tr("Seam allowance"));
ui->doubleSpinBoxSeams->setValue(width);
}
else
{

View File

@ -78,7 +78,6 @@ private:
Q_DISABLE_COPY(DialogPiecePath)
Ui::DialogPiecePath *ui;
bool m_showMode;
qreal m_saWidth;
void InitPathTypes();
void InitListPieces();

View File

@ -641,12 +641,21 @@ void DialogSeamAllowance::PathDialogClosed(int result)
SCASSERT(not m_dialog.isNull());
DialogPiecePath *dialogTool = qobject_cast<DialogPiecePath*>(m_dialog.data());
SCASSERT(dialogTool != nullptr);
const VPiecePath newPath = dialogTool->GetPiecePath();
const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetPieceId());
try
{
const VPiecePath newPath = dialogTool->GetPiecePath();
const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetToolId());
SavePiecePathOptions *saveCommand = new SavePiecePathOptions(newPath, oldPath, qApp->getCurrentDocument(),
const_cast<VContainer *>(data), toolId);
qApp->getUndoStack()->push(saveCommand);
SavePiecePathOptions *saveCommand = new SavePiecePathOptions(oldPath, newPath, qApp->getCurrentDocument(),
const_cast<VContainer *>(data),
dialogTool->GetToolId());
qApp->getUndoStack()->push(saveCommand);
}
catch (const VExceptionBadId &e)
{
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Error. Can't save piece path.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
}
}
delete m_dialog;
}