Remember cursor position and return focus to the formula field.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-05 17:12:36 +03:00
parent 55421d196b
commit 8aea332cda
2 changed files with 14 additions and 2 deletions

View File

@ -638,7 +638,10 @@ void DialogIncrements::SaveIncrFormula()
void DialogIncrements::DeployFormula()
{
SCASSERT(ui->plainTextEditFormula != nullptr);
SCASSERT(ui->pushButtonGrow != nullptr)
SCASSERT(ui->pushButtonGrow != nullptr);
const QTextCursor cursor = ui->plainTextEditFormula->textCursor();
if (ui->plainTextEditFormula->height() < DIALOG_MAX_FORMULA_HEIGHT)
{
ui->plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
@ -659,6 +662,9 @@ void DialogIncrements::DeployFormula()
setUpdatesEnabled(false);
repaint();
setUpdatesEnabled(true);
ui->plainTextEditFormula->setFocus();
ui->plainTextEditFormula->setTextCursor(cursor);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -535,7 +535,10 @@ bool DialogTool::SetObject(const quint32 &id, QComboBox *box, const QString &too
void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight)
{
SCASSERT(formula != nullptr);
SCASSERT(buttonGrowLength != nullptr)
SCASSERT(buttonGrowLength != nullptr);
const QTextCursor cursor = formula->textCursor();
if (formula->height() < DIALOG_MAX_FORMULA_HEIGHT)
{
formula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
@ -556,6 +559,9 @@ void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowL
setUpdatesEnabled(false);
repaint();
setUpdatesEnabled(true);
formula->setFocus();
formula->setTextCursor(cursor);
}
//---------------------------------------------------------------------------------------------------------------------