diff options
author | Henning Gruendl <henning.gruendl@qt.io> | 2019-12-20 16:37:08 +0100 |
---|---|---|
committer | Henning Gründl <henning.gruendl@qt.io> | 2020-01-06 14:45:27 +0000 |
commit | 8687d653531bf7646dd480c8576bcb0d86953662 (patch) | |
tree | 43bc73c4bbfb029844931941af12f8678cf79320 | |
parent | 91b491ffb9bb59f8efd6076b64e0e478c12cef71 (diff) | |
download | qt-creator-8687d653531bf7646dd480c8576bcb0d86953662.tar.gz |
QmlDesigner: Remove tooltip dependency Controls 1
Task-number: QDS-619
Change-Id: I4e54ac43cd6d3052620a9e5ca48cf1fbc66c6181
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
7 files changed, 159 insertions, 7 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml index df39546d93..d89ec29747 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ToolTipArea.qml @@ -24,16 +24,18 @@ ****************************************************************************/ import QtQuick 2.1 -import QtQuick.Controls 1.1 as Controls +import HelperWidgets 2.0 import QtQuick.Layouts 1.0 -import QtQuick.Controls.Private 1.0 MouseArea { id: mouseArea - onExited: Tooltip.hideText() - onCanceled: Tooltip.hideText() + Tooltip { + id: myTooltip + } + onExited: myTooltip.hideText() + onCanceled: myTooltip.hideText() onClicked: forceActiveFocus() hoverEnabled: true @@ -43,6 +45,6 @@ MouseArea { Timer { interval: 1000 running: mouseArea.containsMouse && tooltip.length - onTriggered: Tooltip.showText(mouseArea, Qt.point(mouseArea.mouseX, mouseArea.mouseY), tooltip) + onTriggered: myTooltip.showText(mouseArea, Qt.point(mouseArea.mouseX, mouseArea.mouseY), tooltip) } } diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 0a758c135f..5948c7d3b2 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -320,6 +320,7 @@ extend_qtc_plugin(QmlDesigner simplecolorpalette.cpp simplecolorpalette.h simplecolorpalettemodel.cpp simplecolorpalettemodel.h simplecolorpalettesingleton.cpp simplecolorpalettesingleton.h + tooltip.cpp tooltip.h qmlanchorbindingproxy.cpp qmlanchorbindingproxy.h qmlmodelnodeproxy.cpp qmlmodelnodeproxy.h quick2propertyeditorview.cpp quick2propertyeditorview.h diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri index 1fb9a3981f..7516c45c2b 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri @@ -20,7 +20,8 @@ SOURCES += propertyeditorview.cpp \ simplecolorpalettemodel.cpp \ simplecolorpalettesingleton.cpp \ itemfiltermodel.cpp \ - aligndistribute.cpp + aligndistribute.cpp \ + tooltip.cpp HEADERS += propertyeditorview.h \ qmlanchorbindingproxy.h \ @@ -42,6 +43,7 @@ HEADERS += propertyeditorview.h \ simplecolorpalettemodel.h \ simplecolorpalettesingleton.h \ itemfiltermodel.h \ - aligndistribute.h + aligndistribute.h \ + tooltip.h QT += qml quick diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp index 096162490e..131ef0fe8a 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp @@ -37,6 +37,7 @@ #include "qmlanchorbindingproxy.h" #include "theme.h" #include "aligndistribute.h" +#include "tooltip.h" namespace QmlDesigner { @@ -63,6 +64,7 @@ void Quick2PropertyEditorView::registerQmlTypes() BindingEditor::registerDeclarativeType(); ActionEditor::registerDeclarativeType(); AlignDistribute::registerDeclarativeType(); + Tooltip::registerDeclarativeType(); } } diff --git a/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp b/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp new file mode 100644 index 0000000000..7e4e03fa60 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tooltip.h" +#include <qquickwindow.h> +#include <qquickitem.h> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> +#include <QtQuick/QQuickRenderControl> +#include <QtWidgets/qtwidgetsglobal.h> +#include <qtooltip.h> + +Tooltip::Tooltip(QObject *parent) + : QObject(parent) +{} + +void Tooltip::showText(QQuickItem *item, const QPointF &pos, const QString &str) +{ + if (!item || !item->window()) + return; + + if (QGuiApplicationPrivate::platformIntegration()-> + hasCapability(QPlatformIntegration::MultipleWindows) && + QCoreApplication::instance()->inherits("QApplication")) { + QPoint quickWidgetOffsetInTlw; + QWindow *renderWindow = QQuickRenderControl::renderWindowFor(item->window(), &quickWidgetOffsetInTlw); + QWindow *window = renderWindow ? renderWindow : item->window(); + const QPoint offsetInQuickWidget = item->mapToScene(pos).toPoint(); + const QPoint mappedPos = window->mapToGlobal(offsetInQuickWidget + quickWidgetOffsetInTlw); + QToolTip::showText(mappedPos, str); + } +} + +void Tooltip::hideText() +{ + QToolTip::hideText(); +} + +void Tooltip::registerDeclarativeType() +{ + qmlRegisterType<Tooltip>("HelperWidgets", 2, 0, "Tooltip"); +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/tooltip.h b/src/plugins/qmldesigner/components/propertyeditor/tooltip.h new file mode 100644 index 0000000000..8487308d11 --- /dev/null +++ b/src/plugins/qmldesigner/components/propertyeditor/tooltip.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TOOLTIP_H +#define TOOLTIP_H + +#include <QtQml> + +#include <QtCore/qobject.h> + +class QPointF; +class QQuickItem; + +class Tooltip : public QObject +{ + Q_OBJECT + +public: + explicit Tooltip(QObject *parent = nullptr); + + Q_INVOKABLE void showText(QQuickItem *item, const QPointF &pos, const QString &text); + Q_INVOKABLE void hideText(); + + static void registerDeclarativeType(); +}; + +QML_DECLARE_TYPE(Tooltip) + +#endif // TOOLTIP_H diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 67783c7c15..6de6275ae9 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -618,6 +618,8 @@ Project { "propertyeditor/simplecolorpalettemodel.h", "propertyeditor/simplecolorpalettesingleton.cpp", "propertyeditor/simplecolorpalettesingleton.h", + "propertyeditor/tooltip.cpp", + "propertyeditor/tooltip.h", "resources/resources.qrc", "stateseditor/stateseditorimageprovider.cpp", "stateseditor/stateseditorimageprovider.h", |