summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Ornatek <lukasz.ornatek@qt.io>2020-07-20 12:09:18 +0200
committerƁukasz Ornatek <lukasz.ornatek@qt.io>2020-07-21 16:23:09 +0000
commita7c14b54931c3efa4cac255670f9fc9528891e0b (patch)
tree5fd869fa7a568b1d26023fcefb45d93fc3bac88d
parentce926844d0a5b64abca2f4fd172f8c84aa9ccd54 (diff)
downloadqt-creator-a7c14b54931c3efa4cac255670f9fc9528891e0b.tar.gz
Support multiline text
Use rich text editor widget as dialog for multiline text input Change-Id: I13147e776867032fe1145d6a8a37fcd6976399e4 Task-number: QDS-2229 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml62
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp2
-rw-r--r--src/plugins/qmldesigner/components/richtexteditor/richtexteditor.pri6
-rw-r--r--src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.cpp87
-rw-r--r--src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.h65
5 files changed, 217 insertions, 5 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml
index 6c5e6fde86..777fb0adc4 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml
@@ -26,6 +26,8 @@
import QtQuick 2.1
import HelperWidgets 2.0
import QtQuick.Layouts 1.0
+import StudioControls 1.0 as StudioControls
+import StudioTheme 1.0 as StudioTheme
Section {
anchors.left: parent.left
@@ -46,9 +48,29 @@ Section {
Label {
text: qsTr("Text")
}
- LineEdit {
- backendValue: backendValues.text
- Layout.fillWidth: true
+
+ RowLayout {
+ LineEdit {
+ backendValue: backendValues.text
+ Layout.fillWidth: true
+ }
+
+ StudioControls.AbstractButton {
+ id: richTextEditorButton
+ buttonIcon: StudioTheme.Constants.textAlignTop
+ onClicked: {
+ richTextDialogLoader.show()
+ }
+ }
+
+ RichTextEditor{
+ onRejected: {
+ hideWidget()
+ }
+ onAccepted: {
+ hideWidget()
+ }
+ }
}
Label {
@@ -219,4 +241,38 @@ Section {
Layout.fillWidth: true
}
}
+
+ Loader {
+ id: richTextDialogLoader
+
+ visible: false
+ active: visible
+
+ function show() {
+ richTextDialogLoader.visible = true
+ }
+
+ sourceComponent: Item {
+ id: richTextEditorParent
+
+ Component.onCompleted: {
+ richTextEditor.showWidget()
+ richTextEditor.richText = backendValues.text.value
+ }
+
+ RichTextEditor {
+ id: richTextEditor
+
+ onRejected: {
+ hideWidget()
+ richTextDialogLoader.visible = false
+ }
+ onAccepted: {
+ backendValues.text.value = richTextEditor.richText
+ hideWidget()
+ richTextDialogLoader.visible = false
+ }
+ }
+ }
+ }
}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp
index e8c85bc1b6..7032a26ef7 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp
@@ -40,6 +40,7 @@
#include "aligndistribute.h"
#include "propertyeditorcontextobject.h"
#include "tooltip.h"
+#include "richtexteditor/richtexteditorproxy.h"
namespace QmlDesigner {
@@ -69,6 +70,7 @@ void Quick2PropertyEditorView::registerQmlTypes()
AlignDistribute::registerDeclarativeType();
Tooltip::registerDeclarativeType();
EasingCurveEditor::registerDeclarativeType();
+ RichTextEditorProxy::registerDeclarativeType();
}
}
diff --git a/src/plugins/qmldesigner/components/richtexteditor/richtexteditor.pri b/src/plugins/qmldesigner/components/richtexteditor/richtexteditor.pri
index 68b6dbe026..b71be2268d 100644
--- a/src/plugins/qmldesigner/components/richtexteditor/richtexteditor.pri
+++ b/src/plugins/qmldesigner/components/richtexteditor/richtexteditor.pri
@@ -1,7 +1,9 @@
-HEADERS += $$PWD/richtexteditor.h
+HEADERS += $$PWD/richtexteditor.h \
+ $$PWD/richtexteditorproxy.h
HEADERS += $$PWD/hyperlinkdialog.h
-SOURCES += $$PWD/richtexteditor.cpp
+SOURCES += $$PWD/richtexteditor.cpp \
+ $$PWD/richtexteditorproxy.cpp
SOURCES += $$PWD/hyperlinkdialog.cpp
FORMS += $$PWD/richtexteditor.ui
diff --git a/src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.cpp b/src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.cpp
new file mode 100644
index 0000000000..d628add1ec
--- /dev/null
+++ b/src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "richtexteditorproxy.h"
+
+#include <QDialog>
+#include <QDialogButtonBox>
+
+#include "richtexteditor.h"
+
+namespace QmlDesigner {
+
+RichTextEditorProxy::RichTextEditorProxy(QObject *parent)
+ : QObject(parent)
+ , m_dialog(new QDialog{})
+ , m_widget(new RichTextEditor{})
+{
+ QGridLayout *layout = new QGridLayout{};
+
+ layout->addWidget(m_widget);
+ QDialogButtonBox *standardButtons = new QDialogButtonBox{QDialogButtonBox::Ok
+ | QDialogButtonBox::Cancel};
+
+ connect(standardButtons, &QDialogButtonBox::accepted, m_dialog, &QDialog::accept);
+ connect(standardButtons, &QDialogButtonBox::rejected, m_dialog, &QDialog::reject);
+
+ layout->addWidget(standardButtons);
+
+ m_dialog->setLayout(layout);
+
+ connect(m_dialog, &QDialog::accepted, [this]() { emit accepted(); });
+ connect(m_dialog, &QDialog::rejected, [this]() { emit rejected(); });
+}
+
+RichTextEditorProxy::~RichTextEditorProxy()
+{
+ delete m_dialog;
+}
+
+void RichTextEditorProxy::registerDeclarativeType()
+{
+ qmlRegisterType<RichTextEditorProxy>("HelperWidgets", 2, 0, "RichTextEditor");
+}
+
+void RichTextEditorProxy::showWidget()
+{
+ m_dialog->show();
+}
+
+void RichTextEditorProxy::hideWidget()
+{
+ m_dialog->hide();
+}
+
+QString RichTextEditorProxy::richText() const
+{
+ return m_widget->richText();
+}
+
+void RichTextEditorProxy::setRichText(const QString &text)
+{
+ m_widget->setRichText(text);
+}
+
+} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.h b/src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.h
new file mode 100644
index 0000000000..7e62a0e388
--- /dev/null
+++ b/src/plugins/qmldesigner/components/richtexteditor/richtexteditorproxy.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include <QObject>
+#include <QQuickItem>
+
+QT_BEGIN_NAMESPACE
+class QDialog;
+QT_END_NAMESPACE
+
+namespace QmlDesigner {
+
+class RichTextEditor;
+
+class RichTextEditorProxy : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString richText READ richText WRITE setRichText)
+public:
+ explicit RichTextEditorProxy(QObject *parent = nullptr);
+ ~RichTextEditorProxy();
+
+ static void registerDeclarativeType();
+
+ Q_INVOKABLE void showWidget();
+ Q_INVOKABLE void hideWidget();
+
+ QString richText() const;
+ void setRichText(const QString &text);
+
+signals:
+ void accepted();
+ void rejected();
+
+private:
+ QDialog *m_dialog;
+ RichTextEditor *m_widget;
+};
+
+} // namespace QmlDesigner