From a6112ffc4eade522800db96adaca781c4fa0f60a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 11 Apr 2013 10:10:14 +0200 Subject: [PATCH] Custom wizard: Introduce acceptRichText-property for QTextEdit. Defaults to false (as opposed to QTextEdit's default) to suppress formatting when pasting code from bugtrackers, etc. Change-Id: Ib3dddd1424e56edef48bc63fb13d6c22e18a815c Reviewed-by: Eike Ziller --- doc/src/projects/creator-projects-custom-wizards.qdoc | 5 +++++ .../projectexplorer/customwizard/customwizardpage.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/doc/src/projects/creator-projects-custom-wizards.qdoc b/doc/src/projects/creator-projects-custom-wizards.qdoc index 09021ab7dde..591c85a25fc 100644 --- a/doc/src/projects/creator-projects-custom-wizards.qdoc +++ b/doc/src/projects/creator-projects-custom-wizards.qdoc @@ -466,6 +466,11 @@ The \c defaulttext attribute specifies text that appears in the field by default. + The property QTextEdit::acceptRichText can be set by using the boolean + attribute \c acceptRichText. It is disabled by default (as opposed to the default + value of QTextEdit::acceptRichText) to prevent pasting of rich text with formatting, + which is not desireable for code templates. + \section1 Processing Template Files When processing a template source file, placeholders specifying the field diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index 5e4f2217854..11da62e991c 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -301,6 +301,10 @@ QWidget *CustomWizardFieldPage::registerTextEdit(const QString &fieldName, const CustomWizardField &field) { QTextEdit *textEdit = new QTextEdit; + // Suppress formatting by default (inverting QTextEdit's default value) when + // pasting from Bug tracker, etc. + const bool acceptRichText = field.controlAttributes.value(QLatin1String("acceptRichText")) == QLatin1String("true"); + textEdit->setAcceptRichText(acceptRichText); registerField(fieldName, textEdit, "plainText", SIGNAL(textChanged(QString))); const QString defaultText = field.controlAttributes.value(QLatin1String("defaulttext")); m_textEdits.push_back(TextEditData(textEdit, defaultText));