Apply button works like ok button in first dialog.

Still needs more code to be able to update on first dialog

--HG--
branch : DialogTools
This commit is contained in:
Patrick Proy 2014-05-25 23:50:21 +02:00
parent aa2eda12ee
commit 2913e55024
2 changed files with 76 additions and 3 deletions

View File

@ -202,6 +202,7 @@ void MainWindow::OptionDraw()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// TODO Issue 79 : remove function
template <typename Dialog, typename Func> template <typename Dialog, typename Func>
void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot) Func closeDialogSlot)
@ -230,6 +231,36 @@ void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &
} }
} }
//---------------------------------------------------------------------------------------------------------------------
// TODO Issue 79 : rename to SetToolButton
template <typename Dialog, typename Func, typename Func2>
void MainWindow::SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot, Func2 applyDialogSlot)
{
if (checked)
{
CancelTool();
tool = t;
QPixmap pixmap(cursor);
QCursor cur(pixmap, 2, 3);
view->setCursor(cur);
helpLabel->setText(toolTip);
dialogTool = new Dialog(pattern, this);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChoosedObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
connect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList);
}
else
{
if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender()))
{
Q_CHECK_PTR(tButton);
tButton->setChecked(true);
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename DrawTool> template <typename DrawTool>
void MainWindow::ClosedDialog(int result) void MainWindow::ClosedDialog(int result)
@ -242,11 +273,32 @@ void MainWindow::ClosedDialog(int result)
ArrowTool(); ArrowTool();
} }
//---------------------------------------------------------------------------------------------------------------------
template <typename DrawTool>
void MainWindow::ApplyDialog()
{// TODO ISSUE 79 : copy
Q_CHECK_PTR(dialogTool);
// TODO ISSUE 79 : Only create on first apply for now,
// for updating : VDataTool * stored in DialogTool ?
DrawTool::Create(dialogTool, currentScene, doc, pattern);
ArrowTool();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolEndLine(bool checked) void MainWindow::ToolEndLine(bool checked)
{ {
SetToolButton<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), // SetToolButton<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
&MainWindow::ClosedDialogEndLine); // &MainWindow::ClosedDialogEndLine);
SetToolButton2<DialogEndLine>(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
&MainWindow::ClosedDialogEndLine,&MainWindow::ApplyDialogEndLine);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ApplyDialogEndLine()
{ // TODO ISSUE 79 : copy
ApplyDialog<VToolEndLine>();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -254,6 +254,10 @@ public slots:
* @param result result of dialog working. * @param result result of dialog working.
*/ */
void ClosedDialogEndLine(int result); void ClosedDialogEndLine(int result);
/** // TODO ISSUE 79 : copy
* @brief ApplyDialogEndLine actions after apply in DialogEndLine.
*/
void ApplyDialogEndLine();
/** /**
* @brief ClosedDialogLine actions after closing DialogLine. * @brief ClosedDialogLine actions after closing DialogLine.
* @param result result of dialog working. * @param result result of dialog working.
@ -503,7 +507,7 @@ private:
*/ */
void RestoreCurrentScene(); void RestoreCurrentScene();
template <typename Dialog, typename Func> template <typename Dialog, typename Func>
/** /** // TODO ISSUE 79 : delete
* @brief SetToolButton set tool and show dialog. * @brief SetToolButton set tool and show dialog.
* @param checked true if tool button checked. * @param checked true if tool button checked.
* @param t tool type. * @param t tool type.
@ -513,6 +517,18 @@ private:
*/ */
void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot); Func closeDialogSlot);
/** // TODO ISSUE 79 : copy
* @brief SetToolButton set tool and show dialog.
* @param checked true if tool button checked.
* @param t tool type.
* @param cursor path tool cursor icon.
* @param toolTip first tooltipe.
* @param closeDialogSlot function to handle close of dialog.
* @param applyDialogSlot function to handle apply in dialog.
*/
template <typename Dialog, typename Func, typename Func2>
void SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot, Func2 applyDialogSlot);
/** /**
* @brief MinimumScrollBar set scroll bar to minimum. * @brief MinimumScrollBar set scroll bar to minimum.
*/ */
@ -523,6 +539,11 @@ private:
* @param result result working dialog. * @param result result working dialog.
*/ */
void ClosedDialog(int result); void ClosedDialog(int result);
/** // TODO ISSUE 79 : copy
* @brief ApplyDialog handle apply in dialog
*/
template <typename DrawTool>
void ApplyDialog();
/** /**
* @brief SavePattern save pattern file. * @brief SavePattern save pattern file.
* @param fileName pattern file name. * @param fileName pattern file name.