Prettify dialog to change EditableTexts

This commit is contained in:
WandererFan
2016-05-15 13:59:39 -04:00
committed by wmayer
parent c458760753
commit 845a5d9f4e
5 changed files with 246 additions and 9 deletions

View File

@@ -28,6 +28,7 @@
#endif // #ifndef _PreCmp_
#include "TemplateTextField.h"
#include "DlgTemplateField.h"
//#include<QDebug>
@@ -48,14 +49,15 @@ TemplateTextField::~TemplateTextField()
void TemplateTextField::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
//TODO: Add a command to change template text, and call it from here
bool ok;
QString curStr = QString::fromUtf8(tmplte->EditableTexts[fieldNameStr].c_str());
QString newStr = QInputDialog::getText(NULL, QObject::tr("Change template text"),
QObject::tr("Enter a new value for ") +
QString::fromUtf8(fieldNameStr.c_str()),
QLineEdit::Normal, curStr, &ok);
if (ok && !newStr.isEmpty()) {
tmplte->EditableTexts.setValue(fieldNameStr, newStr.toUtf8().constData());
// ...Interpreter....("App.ActiveDocument().%s.%s.setTextField(%s,%s)",pageName,templateName,fieldName,fieldValue)
DlgTemplateField* ui = new DlgTemplateField(nullptr);
ui->setFieldName(fieldNameStr);
ui->setFieldContent(tmplte->EditableTexts[fieldNameStr]);
int uiCode = ui->exec();
std::string newContent = "";
if(uiCode == QDialog::Accepted) {
std::string newContent = ui->getFieldContent();
tmplte->EditableTexts.setValue(fieldNameStr, newContent);
}
ui->deleteLater();
}