aboutsummaryrefslogtreecommitdiffstats
path: root/src
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 /src
parentce926844d0a5b64abca2f4fd172f8c84aa9ccd54 (diff)
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>
Diffstat (limited to 'src')
-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
4 files changed, 158 insertions, 2 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp
index e8c85bc1b6c..7032a26ef76 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 68b6dbe0268..b71be2268d5 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 00000000000..d628add1ecf
--- /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 00000000000..7e62a0e3882
--- /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