forked from qt-creator/qt-creator
QmlDesigner: Remove tooltip dependency Controls 1
Task-number: QDS-619 Change-Id: I4e54ac43cd6d3052620a9e5ca48cf1fbc66c6181 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
91b491ffb9
commit
8687d65353
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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");
|
||||
}
|
65
src/plugins/qmldesigner/components/propertyeditor/tooltip.h
Normal file
65
src/plugins/qmldesigner/components/propertyeditor/tooltip.h
Normal file
@@ -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
|
@@ -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",
|
||||
|
Reference in New Issue
Block a user