forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.14' into master
Change-Id: Id7ad82997873da828456a15c441620d93c6fc7e7
This commit is contained in:
@@ -386,7 +386,7 @@ endfunction()
|
||||
function(extend_qtc_target target_name)
|
||||
cmake_parse_arguments(_arg
|
||||
""
|
||||
"SOURCES_PREFIX;FEATURE_INFO"
|
||||
"SOURCES_PREFIX;SOURCES_PREFIX_FROM_TARGET;FEATURE_INFO"
|
||||
"CONDITION;DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;EXTRA_TRANSLATIONS;PROPERTIES"
|
||||
${ARGN}
|
||||
)
|
||||
@@ -411,6 +411,14 @@ function(extend_qtc_target target_name)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (_arg_SOURCES_PREFIX_FROM_TARGET)
|
||||
if (NOT TARGET ${_arg_SOURCES_PREFIX_FROM_TARGET})
|
||||
return()
|
||||
else()
|
||||
get_target_property(_arg_SOURCES_PREFIX ${_arg_SOURCES_PREFIX_FROM_TARGET} SOURCES_DIR)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_qtc_depends(${target_name}
|
||||
PRIVATE ${_arg_DEPENDS}
|
||||
PUBLIC ${_arg_PUBLIC_DEPENDS}
|
||||
|
13
dist/changes-4.14.0.md
vendored
13
dist/changes-4.14.0.md
vendored
@@ -14,6 +14,7 @@ General
|
||||
-------
|
||||
|
||||
* Added option for asking for confirmation before closing (QTCREATORBUG-7637)
|
||||
* Improved visibility of controls in dark themes (QTCREATORBUG-23505)
|
||||
|
||||
Help
|
||||
----
|
||||
@@ -23,8 +24,6 @@ Help
|
||||
Editing
|
||||
-------
|
||||
|
||||
* Added option to adjust line spacing (QTCREATORBUG-13727)
|
||||
|
||||
### C++
|
||||
|
||||
* Added refactoring action that creates getters and setters for all class members
|
||||
@@ -39,6 +38,7 @@ Editing
|
||||
* Added action for showing function arguments hint (QTCREATORBUG-19394)
|
||||
* Added option for after how many characters auto-completion may trigger (QTCREATORBUG-19920)
|
||||
* Restricted completion for second argument of `connect` calls to signals (QTCREATORBUG-13558)
|
||||
* Fixed crash of backend with multiline `Q_PROPERTY` declarations (QTCREATORBUG-24746)
|
||||
* Fixed duplicate items appearing in include completion (QTCREATORBUG-24515)
|
||||
* Fixed missing namespace when generating getters and setters (QTCREATORBUG-14886)
|
||||
* Fixed missing `inline` when generating method definitions in header files
|
||||
@@ -49,6 +49,7 @@ Editing
|
||||
* Fixed that `Insert virtual functions of base class` refactoring action added already
|
||||
implemented operators (QTCREATORBUG-12218)
|
||||
* Fixed that `Complete switch statement` indents unrelated code (QTCREATORBUG-12445)
|
||||
* Fixed `Complete switch statement` with templates (QTCREATORBUG-24752)
|
||||
* Fixed that `Apply function signature change` removed return values from `std::function`
|
||||
arguments (QTCREATORBUG-13698)
|
||||
* Fixed handling of multiple inheritance in `Insert Virtual Functions` (QTCREATORBUG-12223)
|
||||
@@ -81,6 +82,10 @@ Projects
|
||||
* Fixed `Embedding of the UI Class` option for widget applications (QTCREATORBUG-24422)
|
||||
* Fixed shell used for console applications (QTCREATORBUG-24659)
|
||||
|
||||
### qmake
|
||||
|
||||
* Added option to not execute `system` directives (QTCREATORBUG-24551)
|
||||
|
||||
### Wizards
|
||||
|
||||
* Fixed creation of form editor class with namespace (QTCREATORBUG-24723)
|
||||
@@ -99,6 +104,10 @@ Debugging
|
||||
|
||||
* Fixed disabling and enabling breakpoints (QTCREATORBUG-24669)
|
||||
|
||||
### GDB
|
||||
|
||||
* Fixed loading of symbol files with `Load Core File` (QTCREATORBUG-24541)
|
||||
|
||||
Analyzer
|
||||
--------
|
||||
|
||||
|
@@ -109,7 +109,11 @@ QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command)
|
||||
++keyCounter;
|
||||
command.m_keyNumber = keyCounter;
|
||||
QByteArray outDataStreamByteArray;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream temporaryOutDataStream(&outDataStreamByteArray, QIODevice::WriteOnly);
|
||||
#else
|
||||
QDataStream temporaryOutDataStream(&outDataStreamByteArray, QDataStream::WriteOnly);
|
||||
#endif
|
||||
temporaryOutDataStream.setVersion(QDataStream::Qt_4_8);
|
||||
|
||||
temporaryOutDataStream << propertyValueContainer;
|
||||
|
@@ -25,8 +25,6 @@
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick3D 1.15
|
||||
import QtQuick.Controls 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Item {
|
||||
@@ -100,6 +98,7 @@ Item {
|
||||
if (editView) {
|
||||
// Destroy is async, so make sure we don't get any more updates for the old editView
|
||||
_generalHelper.enableItemUpdate(editView, false);
|
||||
editView.visible = false;
|
||||
editView.destroy();
|
||||
}
|
||||
|
||||
@@ -299,15 +298,23 @@ Item {
|
||||
|
||||
function addLightGizmo(scene, obj)
|
||||
{
|
||||
// Insert into first available gizmo
|
||||
// Insert into first available gizmo if we don't already have gizmo for this object
|
||||
var slotFound = -1;
|
||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
||||
if (!lightIconGizmos[i].targetNode) {
|
||||
slotFound = i;
|
||||
} else if (lightIconGizmos[i].targetNode === obj) {
|
||||
lightIconGizmos[i].scene = scene;
|
||||
lightIconGizmos[i].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotFound !== -1) {
|
||||
lightIconGizmos[slotFound].scene = scene;
|
||||
lightIconGizmos[slotFound].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
|
||||
// No free gizmos available, create a new one
|
||||
var gizmoComponent = Qt.createComponent("LightIconGizmo.qml");
|
||||
if (gizmoComponent.status === Component.Ready) {
|
||||
@@ -324,14 +331,23 @@ Item {
|
||||
|
||||
function addCameraGizmo(scene, obj)
|
||||
{
|
||||
// Insert into first available gizmo
|
||||
// Insert into first available gizmo if we don't already have gizmo for this object
|
||||
var slotFound = -1;
|
||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
||||
if (!cameraGizmos[i].targetNode) {
|
||||
slotFound = i;
|
||||
} else if (cameraGizmos[i].targetNode === obj) {
|
||||
cameraGizmos[i].scene = scene;
|
||||
cameraGizmos[i].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotFound !== -1) {
|
||||
cameraGizmos[slotFound].scene = scene;
|
||||
cameraGizmos[slotFound].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
|
||||
// No free gizmos available, create a new one
|
||||
var gizmoComponent = Qt.createComponent("CameraGizmo.qml");
|
||||
var frustumComponent = Qt.createComponent("CameraFrustum.qml");
|
||||
|
@@ -26,7 +26,7 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
import LightGeometry 1.0
|
||||
import LightUtils 1.0
|
||||
|
||||
Node {
|
||||
id: lightGizmo
|
||||
@@ -35,7 +35,6 @@ Node {
|
||||
property Node targetNode: null
|
||||
property MouseArea3D dragHelper: null
|
||||
property color color: Qt.rgba(1, 1, 0, 1)
|
||||
property real brightnessScale: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness) : 100
|
||||
property real fadeScale: {
|
||||
// Value indicates area where intensity is above certain percent of total brightness.
|
||||
if (lightGizmo.targetNode instanceof SpotLight || lightGizmo.targetNode instanceof PointLight) {
|
||||
@@ -64,6 +63,8 @@ Node {
|
||||
|| pointLightFadeHandle.dragging
|
||||
property point currentMousePos
|
||||
property string currentLabel
|
||||
property int brightnessDecimals: _generalHelper.brightnessScaler() > 10. ? 0 : 2;
|
||||
property real brightnessMultiplier: Math.pow(10, brightnessDecimals);
|
||||
|
||||
signal propertyValueCommit(string propName)
|
||||
signal propertyValueChange(string propName)
|
||||
@@ -226,7 +227,6 @@ Node {
|
||||
onValueCommit: lightGizmo.propertyValueCommit(propName)
|
||||
}
|
||||
}
|
||||
|
||||
Node {
|
||||
id: areaParts
|
||||
visible: lightGizmo.targetNode instanceof AreaLight
|
||||
@@ -305,15 +305,19 @@ Node {
|
||||
active: lightGizmo.visible
|
||||
dragHelper: lightGizmo.dragHelper
|
||||
scale: autoScaler.getScale(Qt.vector3d(5, 5, 5))
|
||||
length: (lightGizmo.brightnessScale / 10) + 3
|
||||
length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness / _generalHelper.brightnessScaler() * 10.0) + 3 : 10
|
||||
|
||||
property real _startBrightness
|
||||
|
||||
function updateBrightness(relativeDistance, screenPos)
|
||||
{
|
||||
var currentValue = Math.round(Math.max(0, _startBrightness + relativeDistance * 10));
|
||||
var currentValue = Math.max(0, (_startBrightness + relativeDistance * _generalHelper.brightnessScaler() / 10.0));
|
||||
currentValue *= brightnessMultiplier;
|
||||
currentValue = Math.round(currentValue);
|
||||
currentValue /= brightnessMultiplier;
|
||||
|
||||
var l = Qt.locale();
|
||||
lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', 0);
|
||||
lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', brightnessDecimals);
|
||||
lightGizmo.currentMousePos = screenPos;
|
||||
targetNode.brightness = currentValue;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.15
|
||||
import LightUtils 1.0
|
||||
|
||||
IconGizmo {
|
||||
id: lightIconGizmo
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.15
|
||||
import LightGeometry 1.0
|
||||
import LightUtils 1.0
|
||||
|
||||
Model {
|
||||
id: lightModel
|
||||
|
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick3D 1.15
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -32,8 +33,12 @@ Item {
|
||||
|
||||
property alias contentItem: contentItem
|
||||
|
||||
View3D {
|
||||
// Dummy view to hold the context in case View3D items are used in the component
|
||||
// TODO remove when QTBUG-87678 is fixed
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentItem
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
|
@@ -122,6 +122,11 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
View3D {
|
||||
// Dummy view to hold the context
|
||||
// TODO remove when QTBUG-87678 is fixed
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentItem
|
||||
anchors.fill: parent
|
||||
|
@@ -51,6 +51,19 @@ CameraGeometry::~CameraGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString CameraGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void CameraGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
QQuick3DCamera *CameraGeometry::camera() const
|
||||
{
|
||||
return m_camera;
|
||||
@@ -173,13 +186,16 @@ void CameraGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexDat
|
||||
QMatrix4x4 m;
|
||||
QSSGRenderCamera *camera = m_camera->cameraNode();
|
||||
if (camera) {
|
||||
QRectF rect = m_viewPortRect;
|
||||
if (rect.isNull())
|
||||
rect = QRectF(0, 0, 1000, 1000); // Let's have some visualization for null viewports
|
||||
if (qobject_cast<QQuick3DOrthographicCamera *>(m_camera)) {
|
||||
// For some reason ortho cameras show double what projection suggests,
|
||||
// so give them doubled viewport to match visualization to actual camera view
|
||||
camera->calculateGlobalVariables(QRectF(0, 0, m_viewPortRect.width() * 2.0,
|
||||
m_viewPortRect.height() * 2.0));
|
||||
camera->calculateGlobalVariables(QRectF(0, 0, rect.width() * 2.0,
|
||||
rect.height() * 2.0));
|
||||
} else {
|
||||
camera->calculateGlobalVariables(m_viewPortRect);
|
||||
camera->calculateGlobalVariables(rect);
|
||||
}
|
||||
m = camera->projection.inverted();
|
||||
}
|
||||
|
@@ -39,6 +39,17 @@ class CameraGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(QQuick3DCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged)
|
||||
Q_PROPERTY(QRectF viewPortRect READ viewPortRect WRITE setViewPortRect NOTIFY viewPortRectChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
CameraGeometry();
|
||||
~CameraGeometry() override;
|
||||
@@ -46,12 +57,12 @@ public:
|
||||
QQuick3DCamera *camera() const;
|
||||
QRectF viewPortRect() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setCamera(QQuick3DCamera *camera);
|
||||
void setViewPortRect(const QRectF &rect);
|
||||
void handleCameraPropertyChange();
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void cameraChanged();
|
||||
void viewPortRectChanged();
|
||||
|
||||
|
@@ -15,3 +15,8 @@ SOURCES += $$PWD/generalhelper.cpp \
|
||||
$$PWD/selectionboxgeometry.cpp \
|
||||
$$PWD/linegeometry.cpp \
|
||||
$$PWD/icongizmoimageprovider.cpp
|
||||
|
||||
versionAtLeast(QT_VERSION, 6.0.0) {
|
||||
HEADERS += $$PWD/qt5compat/qquick3darealight_p.h
|
||||
SOURCES += $$PWD/qt5compat/qquick3darealight.cpp
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <QtQuick3D/private/qquick3dmodel_p.h>
|
||||
#include <QtQuick3D/private/qquick3dviewport_p.h>
|
||||
#include <QtQuick3D/private/qquick3ddefaultmaterial_p.h>
|
||||
#include <QtQuick3D/private/qquick3dscenemanager_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h>
|
||||
@@ -166,7 +167,12 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau
|
||||
if (auto renderModel = static_cast<QSSGRenderModel *>(targetPriv->spatialNode)) {
|
||||
QWindow *window = static_cast<QWindow *>(viewPort->window());
|
||||
if (window) {
|
||||
auto context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
||||
QSSGRef<QSSGRenderContextInterface> context;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
||||
#else
|
||||
context = targetPriv->sceneManager->rci;
|
||||
#endif
|
||||
if (!context.isNull()) {
|
||||
QSSGBounds3 bounds;
|
||||
auto geometry = qobject_cast<SelectionBoxGeometry *>(modelNode->geometry());
|
||||
@@ -297,6 +303,16 @@ QString GeneralHelper::rootSizeKey() const
|
||||
return _rootSizeKey;
|
||||
}
|
||||
|
||||
double GeneralHelper::brightnessScaler() const
|
||||
{
|
||||
// Light brightness was rescaled in Qt6 from 100 -> 1.
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
return 100.;
|
||||
#else
|
||||
return 1.;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GeneralHelper::isMacOS() const
|
||||
{
|
||||
#ifdef Q_OS_MACOS
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <QtCore/qtimer.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtGui/qvector3d.h>
|
||||
#include <QtGui/qmatrix4x4.h>
|
||||
|
||||
@@ -82,6 +83,8 @@ public:
|
||||
QString lastSceneIdKey() const;
|
||||
QString rootSizeKey() const;
|
||||
|
||||
Q_INVOKABLE double brightnessScaler() const;
|
||||
|
||||
bool isMacOS() const;
|
||||
|
||||
signals:
|
||||
|
@@ -41,6 +41,19 @@ GridGeometry::~GridGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString GridGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void GridGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
int GridGeometry::lines() const
|
||||
{
|
||||
return m_lines;
|
||||
|
@@ -41,6 +41,17 @@ class GridGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(bool isCenterLine READ isCenterLine WRITE setIsCenterLine NOTIFY isCenterLineChanged)
|
||||
Q_PROPERTY(bool isSubdivision MEMBER m_isSubdivision)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
GridGeometry();
|
||||
~GridGeometry() override;
|
||||
@@ -49,12 +60,12 @@ public:
|
||||
float step() const;
|
||||
bool isCenterLine() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setLines(int count);
|
||||
void setStep(float step);
|
||||
void setIsCenterLine(bool enabled);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void linesChanged();
|
||||
void stepChanged();
|
||||
void isCenterLineChanged();
|
||||
|
@@ -45,6 +45,19 @@ LightGeometry::~LightGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString LightGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void LightGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
LightGeometry::LightType LightGeometry::lightType() const
|
||||
{
|
||||
return m_lightType;
|
||||
|
@@ -37,6 +37,17 @@ class LightGeometry : public QQuick3DGeometry
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(LightType lightType READ lightType WRITE setLightType NOTIFY lightTypeChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
enum class LightType {
|
||||
Invalid,
|
||||
@@ -52,10 +63,10 @@ public:
|
||||
|
||||
LightType lightType() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setLightType(LightType lightType);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void lightTypeChanged();
|
||||
|
||||
protected:
|
||||
|
@@ -41,6 +41,19 @@ LineGeometry::~LineGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString LineGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void LineGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
QVector3D LineGeometry::startPos() const
|
||||
{
|
||||
return m_startPos;
|
||||
|
@@ -39,6 +39,17 @@ class LineGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(QVector3D startPos READ startPos WRITE setStartPos NOTIFY startPosChanged)
|
||||
Q_PROPERTY(QVector3D endPos READ endPos WRITE setEndPos NOTIFY endPosChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
LineGeometry();
|
||||
~LineGeometry() override;
|
||||
@@ -46,11 +57,11 @@ public:
|
||||
QVector3D startPos() const;
|
||||
QVector3D endPos() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setStartPos(const QVector3D &pos);
|
||||
void setEndPos(const QVector3D &pos);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void startPosChanged();
|
||||
void endPosChanged();
|
||||
|
||||
|
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
|
||||
#include "qquick3darealight_p.h"
|
||||
#include <QtQuick3D/private/qquick3dobject_p.h>
|
||||
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
|
||||
|
||||
namespace QmlDesigner::Internal {
|
||||
|
||||
float QQuick3DAreaLight::width() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
float QQuick3DAreaLight::height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void QQuick3DAreaLight::setWidth(float width)
|
||||
{
|
||||
m_width = width;
|
||||
emit widthChanged();
|
||||
}
|
||||
|
||||
void QQuick3DAreaLight::setHeight(float height)
|
||||
{
|
||||
m_height = height;
|
||||
emit heightChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
@@ -25,39 +25,42 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#ifdef QUICK3D_MODULE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTabBar;
|
||||
class QSplitter;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
// This is a dummy class for Qt 5 compatibility purposes only
|
||||
|
||||
namespace QmlDesigner {
|
||||
class SwitchSplitTabWidget : public QWidget
|
||||
#include <QtQuick3D/private/qquick3dabstractlight_p.h>
|
||||
|
||||
namespace QmlDesigner::Internal {
|
||||
|
||||
class QQuick3DAreaLight : public QQuick3DAbstractLight
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum Mode { SplitMode, TabMode };
|
||||
Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged)
|
||||
Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged)
|
||||
|
||||
public:
|
||||
explicit SwitchSplitTabWidget(QWidget *parent = nullptr);
|
||||
int count() const;
|
||||
QWidget *currentWidget() const;
|
||||
QQuick3DAreaLight() : QQuick3DAbstractLight() {}
|
||||
~QQuick3DAreaLight() override {}
|
||||
|
||||
int addTab(QWidget *widget, const QString &label);
|
||||
QWidget *takeTabWidget(const int index);
|
||||
void switchTo(QWidget *widget);
|
||||
float width() const;
|
||||
float height() const;
|
||||
|
||||
public slots:
|
||||
void setWidth(float width);
|
||||
void setHeight(float height);
|
||||
|
||||
signals:
|
||||
void widthChanged();
|
||||
void heightChanged();
|
||||
|
||||
private:
|
||||
void updateSplitterSizes(int index = -1);
|
||||
void updateSplitButtons();
|
||||
void selectFakeTab();
|
||||
Mode mode() const;
|
||||
|
||||
QSplitter *m_splitter = nullptr;
|
||||
QTabBar *m_tabBar = nullptr;
|
||||
QWidget *m_tabBarBackground = nullptr;
|
||||
const int fakeTab = 1;
|
||||
float m_width = 100.0f;
|
||||
float m_height = 100.0f;
|
||||
};
|
||||
} // namespace QmlDesigner
|
||||
|
||||
}
|
||||
|
||||
QML_DECLARE_TYPE(QmlDesigner::Internal::QQuick3DAreaLight)
|
||||
|
||||
#endif
|
@@ -32,6 +32,7 @@
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
|
||||
#include <QtQuick3D/private/qquick3dmodel_p.h>
|
||||
#include <QtQuick3D/private/qquick3dscenemanager_p.h>
|
||||
#include <QtQuick3D/qquick3dobject.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtCore/qvector.h>
|
||||
@@ -59,6 +60,19 @@ SelectionBoxGeometry::~SelectionBoxGeometry()
|
||||
m_connections.clear();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString SelectionBoxGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void SelectionBoxGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
QQuick3DNode *SelectionBoxGeometry::targetNode() const
|
||||
{
|
||||
return m_targetNode;
|
||||
@@ -291,8 +305,12 @@ void SelectionBoxGeometry::getBounds(
|
||||
if (auto renderModel = static_cast<QSSGRenderModel *>(renderNode)) {
|
||||
QWindow *window = static_cast<QWindow *>(m_view3D->window());
|
||||
if (window) {
|
||||
auto context = QSSGRenderContextInterface::getRenderContextInterface(
|
||||
quintptr(window));
|
||||
QSSGRef<QSSGRenderContextInterface> context;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
||||
#else
|
||||
context = QQuick3DObjectPrivate::get(this)->sceneManager->rci;
|
||||
#endif
|
||||
if (!context.isNull()) {
|
||||
auto bufferManager = context->bufferManager();
|
||||
QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager);
|
||||
|
@@ -43,6 +43,17 @@ class SelectionBoxGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(QQuick3DViewport *view3D READ view3D WRITE setView3D NOTIFY view3DChanged)
|
||||
Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
SelectionBoxGeometry();
|
||||
~SelectionBoxGeometry() override;
|
||||
@@ -54,12 +65,12 @@ public:
|
||||
|
||||
QSSGBounds3 bounds() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setTargetNode(QQuick3DNode *targetNode);
|
||||
void setRootNode(QQuick3DNode *rootNode);
|
||||
void setView3D(QQuick3DViewport *view);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void targetNodeChanged();
|
||||
void rootNodeChanged();
|
||||
void view3DChanged();
|
||||
|
@@ -58,75 +58,103 @@ IconRenderer::IconRenderer(int size, const QString &filePath, const QString &sou
|
||||
void IconRenderer::setupRender()
|
||||
{
|
||||
DesignerSupport::activateDesignerMode();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
DesignerSupport::activateDesignerWindowManager();
|
||||
#endif
|
||||
|
||||
m_quickView = new QQuickView;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSurfaceFormat surfaceFormat = m_quickView->requestedFormat();
|
||||
surfaceFormat.setVersion(4, 1);
|
||||
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
|
||||
m_quickView->setFormat(surfaceFormat);
|
||||
|
||||
DesignerSupport::createOpenGLContext(m_quickView);
|
||||
#else
|
||||
m_quickView->setDefaultAlphaBuffer(true);
|
||||
m_quickView->setColor(Qt::transparent);
|
||||
m_ratio = m_quickView->devicePixelRatio();
|
||||
m_quickView->installEventFilter(this);
|
||||
#endif
|
||||
|
||||
QQmlComponent component(m_quickView->engine());
|
||||
component.loadUrl(QUrl::fromLocalFile(m_source));
|
||||
QObject *iconItem = component.create();
|
||||
|
||||
if (iconItem) {
|
||||
QQuickItem *containerItem = nullptr;
|
||||
bool is3D = false;
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (auto scene = qobject_cast<QQuick3DNode *>(iconItem)) {
|
||||
qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
|
||||
QQmlComponent component(m_quickView->engine());
|
||||
component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/IconRenderer3D.qml"));
|
||||
containerItem = qobject_cast<QQuickItem *>(component.create());
|
||||
DesignerSupport::setRootItem(m_quickView, containerItem);
|
||||
m_containerItem = qobject_cast<QQuickItem *>(component.create());
|
||||
DesignerSupport::setRootItem(m_quickView, m_containerItem);
|
||||
|
||||
auto helper = new QmlDesigner::Internal::GeneralHelper();
|
||||
m_quickView->engine()->rootContext()->setContextProperty("_generalHelper", helper);
|
||||
|
||||
m_contentItem = QQmlProperty::read(containerItem, "view3D").value<QQuickItem *>();
|
||||
m_contentItem = QQmlProperty::read(m_containerItem, "view3D").value<QQuickItem *>();
|
||||
auto view3D = qobject_cast<QQuick3DViewport *>(m_contentItem);
|
||||
view3D->setImportScene(scene);
|
||||
is3D = true;
|
||||
m_is3D = true;
|
||||
} else
|
||||
#endif
|
||||
if (auto scene = qobject_cast<QQuickItem *>(iconItem)) {
|
||||
m_contentItem = scene;
|
||||
containerItem = new QQuickItem();
|
||||
containerItem->setSize(QSizeF(1024, 1024));
|
||||
DesignerSupport::setRootItem(m_quickView, containerItem);
|
||||
m_contentItem->setParentItem(containerItem);
|
||||
m_containerItem = new QQuickItem();
|
||||
m_containerItem->setSize(QSizeF(1024, 1024));
|
||||
DesignerSupport::setRootItem(m_quickView, m_containerItem);
|
||||
m_contentItem->setParentItem(m_containerItem);
|
||||
}
|
||||
|
||||
if (containerItem && m_contentItem) {
|
||||
m_contentItem->setSize(QSizeF(m_size, m_size));
|
||||
if (m_contentItem->width() > containerItem->width())
|
||||
containerItem->setWidth(m_contentItem->width());
|
||||
if (m_contentItem->height() > containerItem->height())
|
||||
containerItem->setHeight(m_contentItem->height());
|
||||
if (m_containerItem && m_contentItem) {
|
||||
resizeContent(m_size);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QTimer::singleShot(0, this, &IconRenderer::createIcon);
|
||||
#else
|
||||
m_quickView->show();
|
||||
m_quickView->lower();
|
||||
|
||||
QTimer::singleShot(0, this, [this, is3D, containerItem]() {
|
||||
// Failsafe to exit eventually if window fails to expose
|
||||
QTimer::singleShot(10000, qGuiApp, &QGuiApplication::quit);
|
||||
#endif
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
}
|
||||
|
||||
bool IconRenderer::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (watched == m_quickView && event->type() == QEvent::Expose)
|
||||
QTimer::singleShot(0, this, &IconRenderer::createIcon);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void IconRenderer::createIcon()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
m_designerSupport.refFromEffectItem(m_quickView->rootObject(), false);
|
||||
#endif
|
||||
QQuickDesignerSupportItems::disableNativeTextRendering(m_quickView->rootObject());
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (is3D) {
|
||||
if (m_is3D) {
|
||||
// Render once to make sure scene is up to date before we set up the selection box
|
||||
render({});
|
||||
QMetaObject::invokeMethod(containerItem, "setSceneToBox");
|
||||
QMetaObject::invokeMethod(m_containerItem, "setSceneToBox");
|
||||
int tries = 0;
|
||||
while (tries < 10) {
|
||||
++tries;
|
||||
render({});
|
||||
QMetaObject::invokeMethod(containerItem, "fitAndHideBox");
|
||||
QMetaObject::invokeMethod(m_containerItem, "fitAndHideBox");
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(is3D)
|
||||
Q_UNUSED(containerItem)
|
||||
#endif
|
||||
QFileInfo fi(m_filePath);
|
||||
|
||||
@@ -134,7 +162,7 @@ void IconRenderer::setupRender()
|
||||
render(fi.absoluteFilePath());
|
||||
|
||||
// Render @2x image
|
||||
m_contentItem->setSize(QSizeF(m_size * 2, m_size * 2));
|
||||
resizeContent(m_size * 2);
|
||||
|
||||
QString saveFile;
|
||||
saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x";
|
||||
@@ -147,13 +175,6 @@ void IconRenderer::setupRender()
|
||||
|
||||
// Allow little time for file operations to finish
|
||||
QTimer::singleShot(1000, qGuiApp, &QGuiApplication::quit);
|
||||
});
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
}
|
||||
|
||||
void IconRenderer::render(const QString &fileName)
|
||||
@@ -163,14 +184,30 @@ void IconRenderer::render(const QString &fileName)
|
||||
const auto childItems = item->childItems();
|
||||
for (QQuickItem *childItem : childItems)
|
||||
updateNodesRecursive(childItem);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
DesignerSupport::updateDirtyNode(item);
|
||||
#else
|
||||
if (item->flags() & QQuickItem::ItemHasContents)
|
||||
item->update();
|
||||
#endif
|
||||
};
|
||||
updateNodesRecursive(m_quickView->rootObject());
|
||||
|
||||
QRect rect(QPoint(), m_contentItem->size().toSize());
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QImage renderImage = m_designerSupport.renderImageForItem(m_quickView->rootObject(),
|
||||
rect, rect.size());
|
||||
#else
|
||||
QImage renderImage = m_quickView->grabWindow();
|
||||
#endif
|
||||
if (!fileName.isEmpty()) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (m_ratio != 1.) {
|
||||
rect.setWidth(qRound(rect.size().width() * m_ratio));
|
||||
rect.setHeight(qRound(rect.size().height() * m_ratio));
|
||||
}
|
||||
renderImage = renderImage.copy(rect);
|
||||
#endif
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.suffix().isEmpty())
|
||||
renderImage.save(fileName, "PNG");
|
||||
@@ -178,3 +215,17 @@ void IconRenderer::render(const QString &fileName)
|
||||
renderImage.save(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void IconRenderer::resizeContent(int size)
|
||||
{
|
||||
int theSize = size;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (m_ratio != 1.)
|
||||
theSize = qRound(qreal(size) / m_quickView->devicePixelRatio());
|
||||
#endif
|
||||
m_contentItem->setSize(QSizeF(theSize, theSize));
|
||||
if (m_contentItem->width() > m_containerItem->width())
|
||||
m_containerItem->setWidth(m_contentItem->width());
|
||||
if (m_contentItem->height() > m_containerItem->height())
|
||||
m_containerItem->setHeight(m_contentItem->height());
|
||||
}
|
||||
|
@@ -44,13 +44,21 @@ public:
|
||||
|
||||
void setupRender();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void createIcon();
|
||||
void render(const QString &fileName);
|
||||
void resizeContent(int size);
|
||||
|
||||
int m_size = 16;
|
||||
double m_ratio = 1.;
|
||||
QString m_filePath;
|
||||
QString m_source;
|
||||
QQuickView *m_quickView = nullptr;
|
||||
QQuickItem *m_contentItem = nullptr;
|
||||
QQuickItem *m_containerItem = nullptr;
|
||||
DesignerSupport m_designerSupport;
|
||||
bool m_is3D = false;
|
||||
};
|
||||
|
@@ -78,7 +78,6 @@
|
||||
#include <QDir>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QMetaType>
|
||||
#include <QMutableVectorIterator>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlContext>
|
||||
@@ -1477,4 +1476,8 @@ void NodeInstanceServer::sheduleRootItemRender()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeInstanceServer::initializeAuxiliaryViews()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -253,6 +253,7 @@ protected:
|
||||
void setSlowRenderTimerInterval(int timerInterval);
|
||||
|
||||
virtual void initializeView() = 0;
|
||||
virtual void initializeAuxiliaryViews();
|
||||
virtual void setupScene(const CreateSceneCommand &command) = 0;
|
||||
void setTranslationLanguage(const QString &language);
|
||||
void loadDummyDataFiles(const QString& directory);
|
||||
|
@@ -76,6 +76,7 @@
|
||||
|
||||
#include <designersupportdelegate.h>
|
||||
#include <qmlprivategate.h>
|
||||
#include <quickitemnodeinstance.h>
|
||||
|
||||
#include <QVector3D>
|
||||
#include <QQmlProperty>
|
||||
@@ -92,6 +93,9 @@
|
||||
#include <QtQuick3D/private/qquick3dabstractlight_p.h>
|
||||
#include <QtQuick3D/private/qquick3dviewport_p.h>
|
||||
#include <QtQuick3D/private/qquick3dscenerootnode_p.h>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include "../editor3d/qt5compat/qquick3darealight_p.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -128,9 +132,14 @@ static bool imageHasContent(const QImage &image)
|
||||
QQuickView *Qt5InformationNodeInstanceServer::createAuxiliaryQuickView(const QUrl &url,
|
||||
QQuickItem *&rootItem)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
auto view = new QQuickView(quickView()->engine(), quickView());
|
||||
view->setFormat(quickView()->format());
|
||||
DesignerSupport::createOpenGLContext(view);
|
||||
#else
|
||||
auto view = new QQuickView(quickView()->engine(), nullptr);
|
||||
view->setFormat(quickView()->format());
|
||||
#endif
|
||||
QQmlComponent component(engine());
|
||||
component.loadUrl(url);
|
||||
rootItem = qobject_cast<QQuickItem *>(component.create());
|
||||
@@ -151,10 +160,13 @@ void Qt5InformationNodeInstanceServer::createEditView3D()
|
||||
qmlRegisterRevision<QQuick3DNode, 1>("MouseArea3D", 1, 0);
|
||||
qmlRegisterType<QmlDesigner::Internal::MouseArea3D>("MouseArea3D", 1, 0, "MouseArea3D");
|
||||
qmlRegisterType<QmlDesigner::Internal::CameraGeometry>("CameraGeometry", 1, 0, "CameraGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::LightGeometry>("LightGeometry", 1, 0, "LightGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::LightGeometry>("LightUtils", 1, 0, "LightGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::GridGeometry>("GridGeometry", 1, 0, "GridGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::LineGeometry>("LineGeometry", 1, 0, "LineGeometry");
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
qmlRegisterType<QmlDesigner::Internal::QQuick3DAreaLight>("LightUtils", 1, 0, "AreaLight");
|
||||
#endif
|
||||
|
||||
auto helper = new QmlDesigner::Internal::GeneralHelper();
|
||||
QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged,
|
||||
@@ -166,24 +178,8 @@ void Qt5InformationNodeInstanceServer::createEditView3D()
|
||||
|
||||
m_editView3D = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/EditView3D.qml"), m_editView3DRootItem);
|
||||
|
||||
if (m_editView3DRootItem) {
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(selectionChanged(QVariant)),
|
||||
this, SLOT(handleSelectionChanged(QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyCommit(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyChange(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(notifyActiveSceneChange()),
|
||||
this, SLOT(handleActiveSceneChange()));
|
||||
QObject::connect(&m_propertyChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout);
|
||||
QObject::connect(&m_selectionChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout);
|
||||
QObject::connect(&m_render3DEditViewTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::doRender3DEditView);
|
||||
|
||||
if (m_editView3DRootItem)
|
||||
helper->setParent(m_editView3DRootItem);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -380,6 +376,9 @@ void Qt5InformationNodeInstanceServer::updateView3DRect(QObject *view3D)
|
||||
void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D()
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
// Active scene change handling on qml side is async, so a deleted importScene would crash
|
||||
// editView when it updates next. Disable/enable edit view update synchronously to avoid this.
|
||||
QVariant activeSceneVar = objectToVariant(m_active3DScene);
|
||||
@@ -431,6 +430,9 @@ void Qt5InformationNodeInstanceServer::removeNode3D(QObject *node)
|
||||
void Qt5InformationNodeInstanceServer::resolveSceneRoots()
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
const auto oldMap = m_3DSceneMap;
|
||||
m_3DSceneMap.clear();
|
||||
auto it = oldMap.begin();
|
||||
@@ -477,15 +479,22 @@ ServerNodeInstance Qt5InformationNodeInstanceServer::active3DSceneInstance() con
|
||||
|
||||
void Qt5InformationNodeInstanceServer::updateNodesRecursive(QQuickItem *item)
|
||||
{
|
||||
for (QQuickItem *childItem : item->childItems())
|
||||
const auto childItems = item->childItems();
|
||||
for (QQuickItem *childItem : childItems)
|
||||
updateNodesRecursive(childItem);
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
if (item->flags() & QQuickItem::ItemHasContents)
|
||||
item->update();
|
||||
} else {
|
||||
DesignerSupport::updateDirtyNode(item);
|
||||
}
|
||||
}
|
||||
|
||||
QQuickItem *Qt5InformationNodeInstanceServer::getContentItemForRendering(QQuickItem *rootItem)
|
||||
{
|
||||
QQuickItem *contentItem = QQmlProperty::read(rootItem, "contentItem").value<QQuickItem *>();
|
||||
if (contentItem) {
|
||||
if (!Internal::QuickItemNodeInstance::unifiedRenderPath())
|
||||
designerSupport()->refFromEffectItem(contentItem, false);
|
||||
QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(contentItem);
|
||||
}
|
||||
@@ -502,22 +511,32 @@ void Qt5InformationNodeInstanceServer::render3DEditView(int count)
|
||||
// render the 3D edit view and send the result to creator process
|
||||
void Qt5InformationNodeInstanceServer::doRender3DEditView()
|
||||
{
|
||||
if (m_editView3DRootItem) {
|
||||
if (m_editView3DSetupDone) {
|
||||
if (!m_editView3DContentItem)
|
||||
m_editView3DContentItem = getContentItemForRendering(m_editView3DRootItem);
|
||||
|
||||
QImage renderImage;
|
||||
|
||||
updateNodesRecursive(m_editView3DContentItem);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
renderImage = m_editView3D->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
m_editView3D->beforeSynchronizing();
|
||||
m_editView3D->beforeRendering();
|
||||
|
||||
QSizeF size = qobject_cast<QQuickItem *>(m_editView3DContentItem)->size();
|
||||
QRectF renderRect(QPointF(0., 0.), size);
|
||||
QImage renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem,
|
||||
renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem,
|
||||
renderRect, size.toSize());
|
||||
|
||||
m_editView3D->afterRendering();
|
||||
}
|
||||
#else
|
||||
renderImage = m_editView3D->grabWindow();
|
||||
#endif
|
||||
|
||||
// There's no instance related to image, so instance id is -1.
|
||||
// Key number is selected so that it is unlikely to conflict other ImageContainer use.
|
||||
@@ -581,17 +600,28 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView()
|
||||
instanceObj = instance.internalObject();
|
||||
}
|
||||
QSize renderSize = m_modelNodePreviewImageCommand.size();
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
// Requested size is already adjusted for target pixel ratio, so we have to adjust
|
||||
// back if ratio is not default for our window.
|
||||
double ratio = m_ModelNode3DImageView->devicePixelRatio();
|
||||
renderSize.setWidth(qRound(qreal(renderSize.width()) / ratio));
|
||||
renderSize.setHeight(qRound(qreal(renderSize.height()) / ratio));
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(m_ModelNode3DImageViewRootItem, "createViewForObject",
|
||||
Q_ARG(QVariant, objectToVariant(instanceObj)),
|
||||
Q_ARG(QVariant, QVariant::fromValue(renderSize.width())),
|
||||
Q_ARG(QVariant, QVariant::fromValue(renderSize.height())));
|
||||
|
||||
|
||||
bool ready = false;
|
||||
int count = 0; // Ensure we don't ever get stuck in an infinite loop
|
||||
while (!ready && ++count < 10) {
|
||||
updateNodesRecursive(m_ModelNode3DImageViewContentItem);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
renderImage = m_ModelNode3DImageView->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
m_ModelNode3DImageView->beforeSynchronizing();
|
||||
m_ModelNode3DImageView->beforeRendering();
|
||||
@@ -600,8 +630,12 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView()
|
||||
QRectF renderRect(QPointF(0., 0.), size);
|
||||
renderImage = designerSupport()->renderImageForItem(m_ModelNode3DImageViewContentItem,
|
||||
renderRect, size.toSize());
|
||||
m_ModelNode3DImageView->afterRendering();
|
||||
|
||||
m_ModelNode3DImageView->afterRendering();
|
||||
}
|
||||
#else
|
||||
renderImage = m_ModelNode3DImageView->grabWindow();
|
||||
#endif
|
||||
QMetaObject::invokeMethod(m_ModelNode3DImageViewRootItem, "afterRender");
|
||||
ready = QQmlProperty::read(m_ModelNode3DImageViewRootItem, "ready").value<bool>();
|
||||
}
|
||||
@@ -682,12 +716,23 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode2DImageView()
|
||||
if (renderSize.isEmpty()) {
|
||||
renderSize = finalSize;
|
||||
renderRect = QRectF(QPointF(0., 0.), QSizeF(renderSize));
|
||||
instanceItem->setSize(renderSize);
|
||||
}
|
||||
m_ModelNode2DImageView->resize(renderSize);
|
||||
m_ModelNode2DImageViewRootItem->setSize(renderSize);
|
||||
m_ModelNode2DImageViewContentItem->setPosition(QPointF(-renderRect.x(), -renderRect.y()));
|
||||
|
||||
updateNodesRecursive(m_ModelNode2DImageViewContentItem);
|
||||
|
||||
renderImage = designerSupport()->renderImageForItem(m_ModelNode2DImageViewContentItem, renderRect, renderSize);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
renderImage = m_ModelNode2DImageView->grabWindow();
|
||||
} else {
|
||||
renderImage = designerSupport()->renderImageForItem(m_ModelNode2DImageViewContentItem,
|
||||
renderRect, renderSize);
|
||||
}
|
||||
#else
|
||||
renderImage = m_ModelNode2DImageView->grabWindow();
|
||||
#endif
|
||||
|
||||
if (!imageHasContent(renderImage))
|
||||
renderImage = nonVisualComponentPreviewImage();
|
||||
@@ -721,6 +766,12 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC
|
||||
m_renderModelNodeImageViewTimer.setSingleShot(true);
|
||||
}
|
||||
|
||||
Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer()
|
||||
{
|
||||
for (auto view : qAsConst(m_view3Ds))
|
||||
QObject::disconnect(view, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::sendTokenBack()
|
||||
{
|
||||
foreach (const TokenCommand &command, m_tokenList)
|
||||
@@ -795,7 +846,7 @@ QList<ServerNodeInstance> Qt5InformationNodeInstanceServer::createInstances(
|
||||
{
|
||||
const auto createdInstances = NodeInstanceServer::createInstances(container);
|
||||
|
||||
if (m_editView3DRootItem) {
|
||||
if (m_editView3DSetupDone) {
|
||||
add3DViewPorts(createdInstances);
|
||||
add3DScenes(createdInstances);
|
||||
createCameraAndLightGizmos(createdInstances);
|
||||
@@ -806,6 +857,37 @@ QList<ServerNodeInstance> Qt5InformationNodeInstanceServer::createInstances(
|
||||
return createdInstances;
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::initializeAuxiliaryViews()
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")) {
|
||||
createEditView3D();
|
||||
m_ModelNode3DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode3DImageView.qml"),
|
||||
m_ModelNode3DImageViewRootItem);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_ModelNode2DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode2DImageView.qml"),
|
||||
m_ModelNode2DImageViewRootItem);
|
||||
m_ModelNode2DImageView->setDefaultAlphaBuffer(true);
|
||||
m_ModelNode2DImageView->setColor(Qt::transparent);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (!m_editView3D.isNull()) {
|
||||
m_editView3D->show();
|
||||
m_editView3D->lower();
|
||||
}
|
||||
if (!m_ModelNode3DImageView.isNull()) {
|
||||
m_ModelNode3DImageView->show();
|
||||
m_ModelNode3DImageView->lower();
|
||||
}
|
||||
if (!m_ModelNode2DImageView.isNull()) {
|
||||
m_ModelNode2DImageView->show();
|
||||
m_ModelNode2DImageView->lower();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout()
|
||||
{
|
||||
modifyVariantValue(m_changedNode, m_changedProperty,
|
||||
@@ -1028,14 +1110,28 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
|
||||
const QHash<QString, QVariantMap> &toolStates)
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (!m_editView3DRootItem)
|
||||
return;
|
||||
|
||||
ServerNodeInstance root = rootNodeInstance();
|
||||
|
||||
add3DViewPorts(instanceList);
|
||||
add3DScenes(instanceList);
|
||||
|
||||
createEditView3D();
|
||||
m_ModelNode3DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode3DImageView.qml"),
|
||||
m_ModelNode3DImageViewRootItem);
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(selectionChanged(QVariant)),
|
||||
this, SLOT(handleSelectionChanged(QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyCommit(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyChange(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(notifyActiveSceneChange()),
|
||||
this, SLOT(handleActiveSceneChange()));
|
||||
QObject::connect(&m_propertyChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout);
|
||||
QObject::connect(&m_selectionChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout);
|
||||
QObject::connect(&m_render3DEditViewTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::doRender3DEditView);
|
||||
|
||||
QString lastSceneId;
|
||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||
@@ -1056,7 +1152,7 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
|
||||
// Find a scene to show
|
||||
m_active3DScene = nullptr;
|
||||
m_active3DView = nullptr;
|
||||
if (m_editView3DRootItem && !m_3DSceneMap.isEmpty()) {
|
||||
if (!m_3DSceneMap.isEmpty()) {
|
||||
// Restore the previous scene if possible
|
||||
if (!lastSceneId.isEmpty()) {
|
||||
const auto keys = m_3DSceneMap.uniqueKeys();
|
||||
@@ -1073,6 +1169,8 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
|
||||
}
|
||||
}
|
||||
|
||||
m_editView3DSetupDone = true;
|
||||
|
||||
if (toolStates.contains({})) {
|
||||
// Update tool state to an existing no-scene state before updating the active scene to
|
||||
// ensure the previous state is inherited properly in all cases.
|
||||
@@ -1175,7 +1273,7 @@ void Qt5InformationNodeInstanceServer::reparentInstances(const ReparentInstances
|
||||
|
||||
Qt5NodeInstanceServer::reparentInstances(command);
|
||||
|
||||
if (m_editView3DRootItem)
|
||||
if (m_editView3DSetupDone)
|
||||
resolveSceneRoots();
|
||||
|
||||
// Make sure selection is in sync after all reparentings are done
|
||||
@@ -1195,14 +1293,14 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com
|
||||
Qt5NodeInstanceServer::createScene(command);
|
||||
|
||||
QList<ServerNodeInstance> instanceList;
|
||||
foreach (const InstanceContainer &container, command.instances()) {
|
||||
const auto instances = command.instances();
|
||||
for (const InstanceContainer &container : instances) {
|
||||
if (hasInstanceForId(container.instanceId())) {
|
||||
ServerNodeInstance instance = instanceForId(container.instanceId());
|
||||
if (instance.isValid()) {
|
||||
if (instance.isValid())
|
||||
instanceList.append(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(instanceList, true));
|
||||
nodeInstanceClient()->valuesChanged(createValuesChangedCommand(instanceList));
|
||||
@@ -1212,8 +1310,6 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com
|
||||
if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE"))
|
||||
setup3DEditView(instanceList, command.edit3dToolStates());
|
||||
|
||||
m_ModelNode2DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode2DImageView.qml"),
|
||||
m_ModelNode2DImageViewRootItem);
|
||||
QObject::connect(&m_renderModelNodeImageViewTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::doRenderModelNodeImageView);
|
||||
}
|
||||
@@ -1274,7 +1370,7 @@ void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const Qml
|
||||
|
||||
void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command)
|
||||
{
|
||||
if (!m_editView3DRootItem)
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
m_lastSelectionChangeCommand = command;
|
||||
@@ -1380,7 +1476,7 @@ void Qt5InformationNodeInstanceServer::removeInstances(const RemoveInstancesComm
|
||||
resolveSceneRoots();
|
||||
}
|
||||
|
||||
if (m_editView3DRootItem && (!m_active3DScene || !m_active3DView)) {
|
||||
if (m_editView3DSetupDone && (!m_active3DScene || !m_active3DView)) {
|
||||
if (!m_active3DScene && !m_3DSceneMap.isEmpty())
|
||||
m_active3DScene = m_3DSceneMap.begin().key();
|
||||
m_active3DView = findView3DForSceneRoot(m_active3DScene);
|
||||
@@ -1417,6 +1513,9 @@ void Qt5InformationNodeInstanceServer::inputEvent(const InputEventCommand &comma
|
||||
|
||||
void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &command)
|
||||
{
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
QVariantMap updatedState;
|
||||
int renderCount = 1;
|
||||
|
||||
@@ -1486,6 +1585,7 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command
|
||||
Qt5NodeInstanceServer::changeIds(command);
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (m_editView3DSetupDone) {
|
||||
ServerNodeInstance sceneInstance = active3DSceneInstance();
|
||||
if (m_active3DSceneUpdatePending) {
|
||||
const QString sceneId = sceneInstance.id();
|
||||
@@ -1503,6 +1603,7 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1525,7 +1626,7 @@ void Qt5InformationNodeInstanceServer::update3DViewState(const Update3dViewState
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (command.type() == Update3dViewStateCommand::SizeChange) {
|
||||
if (m_editView3DRootItem) {
|
||||
if (m_editView3DSetupDone) {
|
||||
m_editView3DRootItem->setSize(command.size());
|
||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||
if (helper)
|
||||
|
@@ -49,6 +49,7 @@ class Qt5InformationNodeInstanceServer : public Qt5NodeInstanceServer
|
||||
|
||||
public:
|
||||
explicit Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
|
||||
~Qt5InformationNodeInstanceServer() override;
|
||||
|
||||
void reparentInstances(const ReparentInstancesCommand &command) override;
|
||||
void clearScene(const ClearSceneCommand &command) override;
|
||||
@@ -89,6 +90,7 @@ protected:
|
||||
void selectInstances(const QList<ServerNodeInstance> &instanceList);
|
||||
void modifyProperties(const QVector<InstancePropertyValueTriple> &properties);
|
||||
QList<ServerNodeInstance> createInstances(const QVector<InstanceContainer> &container) override;
|
||||
void initializeAuxiliaryViews() override;
|
||||
|
||||
private:
|
||||
void handleObjectPropertyChangeTimeout();
|
||||
@@ -129,6 +131,7 @@ private:
|
||||
QPointer<QQuickView> m_editView3D;
|
||||
QQuickItem *m_editView3DRootItem = nullptr;
|
||||
QQuickItem *m_editView3DContentItem = nullptr;
|
||||
bool m_editView3DSetupDone = false;
|
||||
QPointer<QQuickView> m_ModelNode3DImageView;
|
||||
QQuickItem *m_ModelNode3DImageViewRootItem = nullptr;
|
||||
QQuickItem *m_ModelNode3DImageViewContentItem = nullptr;
|
||||
|
@@ -81,6 +81,14 @@ void Qt5NodeInstanceServer::initializeView()
|
||||
QStringList customSelectors = QString::fromUtf8(qgetenv("QML_FILE_SELECTORS")).split(',');
|
||||
fileSelector->setExtraSelectors(customSelectors);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// View needs to be shown for all puppets before any instances are created in case there is a View3D
|
||||
quickView()->show();
|
||||
quickView()->lower();
|
||||
#endif
|
||||
|
||||
initializeAuxiliaryViews();
|
||||
}
|
||||
|
||||
QQmlView *Qt5NodeInstanceServer::declarativeView() const
|
||||
|
@@ -147,11 +147,6 @@ void Qt5RenderNodeInstanceServer::createScene(const CreateSceneCommand &command)
|
||||
}
|
||||
|
||||
nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList));
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#else
|
||||
quickView()->show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Qt5RenderNodeInstanceServer::clearScene(const ClearSceneCommand &command)
|
||||
|
@@ -262,10 +262,8 @@ QStringList QuickItemNodeInstance::allStates() const
|
||||
|
||||
void QuickItemNodeInstance::updateDirtyNode(QQuickItem *item)
|
||||
{
|
||||
if (s_unifiedRenderPath) {
|
||||
item->update();
|
||||
if (s_unifiedRenderPath)
|
||||
return;
|
||||
}
|
||||
DesignerSupport::updateDirtyNode(item);
|
||||
}
|
||||
|
||||
@@ -417,23 +415,24 @@ QImage QuickItemNodeInstance::renderImage() const
|
||||
static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble();
|
||||
size *= devicePixelRatio;
|
||||
|
||||
QImage renderImage;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath) {
|
||||
renderImage = nodeInstanceServer()->quickView()->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
nodeInstanceServer()->quickView()->beforeSynchronizing();
|
||||
nodeInstanceServer()->quickView()->beforeRendering();
|
||||
|
||||
QImage renderImage;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath)
|
||||
renderImage = nodeInstanceServer()->quickView()->grabWindow();
|
||||
else
|
||||
renderImage = designerSupport()->renderImageForItem(quickItem(), renderBoundingRect, size);
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
}
|
||||
#else
|
||||
renderImage = nodeInstanceServer()->quickView()->grabWindow();
|
||||
#endif
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
|
||||
renderImage.setDevicePixelRatio(devicePixelRatio);
|
||||
|
||||
return renderImage;
|
||||
@@ -447,27 +446,27 @@ QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize)
|
||||
static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble();
|
||||
const QSize size = previewImageSize * devicePixelRatio;
|
||||
if (quickItem()->isVisible()) {
|
||||
QImage image;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath) {
|
||||
image = nodeInstanceServer()->quickView()->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
nodeInstanceServer()->quickView()->beforeSynchronizing();
|
||||
nodeInstanceServer()->quickView()->beforeRendering();
|
||||
|
||||
QImage image;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath)
|
||||
image = nodeInstanceServer()->quickView()->grabWindow();
|
||||
else
|
||||
image = designerSupport()->renderImageForItem(quickItem(),
|
||||
previewItemBoundingRect,
|
||||
size);
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
}
|
||||
#else
|
||||
image = nodeInstanceServer()->quickView()->grabWindow();
|
||||
#endif
|
||||
|
||||
image = image.scaledToWidth(size.width());
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
|
||||
return image;
|
||||
} else {
|
||||
QImage transparentImage(size, QImage::Format_ARGB32_Premultiplied);
|
||||
@@ -686,7 +685,8 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen
|
||||
|
||||
if (quickItem()->parentItem()) {
|
||||
refresh();
|
||||
DesignerSupport::updateDirtyNode(quickItem());
|
||||
|
||||
updateDirtyNode(quickItem());
|
||||
|
||||
if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty))
|
||||
oldParentInstance->refreshLayoutable();
|
||||
|
@@ -31,8 +31,11 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <qt5nodeinstanceclientproxy.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "iconrenderer/iconrenderer.h"
|
||||
#include <qt5nodeinstanceclientproxy.h>
|
||||
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
@@ -46,6 +49,54 @@
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
fprintf(stderr,
|
||||
"Debug: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
fprintf(stderr,
|
||||
"Info: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
fprintf(stderr,
|
||||
"Warning: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
fprintf(stderr,
|
||||
"Critical: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
fprintf(stderr,
|
||||
"Fatal: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int internalMain(QGuiApplication *application)
|
||||
{
|
||||
@@ -144,6 +195,9 @@ int internalMain(QGuiApplication *application)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
qInstallMessageHandler(myMessageOutput);
|
||||
#endif
|
||||
// Since we always render text into an FBO, we need to globally disable
|
||||
// subpixel antialiasing and instead use gray.
|
||||
qputenv("QSG_DISTANCEFIELD_ANTIALIASING", "gray");
|
||||
|
@@ -62,11 +62,11 @@ jobs:
|
||||
if ("${{ runner.os }}" STREQUAL "Windows")
|
||||
set(url_os "windows_x86")
|
||||
if ("${{ matrix.config.environment_script }}" MATCHES "vcvars64.bat")
|
||||
set(qt_package_name "qt.qt5.${qt_version_dotless}.win64_msvc2017_64")
|
||||
set(qt_dir_prefix "${qt_version}/msvc2017_64")
|
||||
set(qt_package_name "qt.qt5.${qt_version_dotless}.win64_msvc2019_64")
|
||||
set(qt_dir_prefix "${qt_version}/msvc2019_64")
|
||||
elseif ("${{ matrix.config.environment_script }}" MATCHES "vcvars32.bat")
|
||||
set(qt_package_name "qt.qt5.${qt_version_dotless}.win32_msvc2017")
|
||||
set(qt_dir_prefix "${qt_version}/msvc2017")
|
||||
set(qt_package_name "qt.qt5.${qt_version_dotless}.win32_msvc2019")
|
||||
set(qt_dir_prefix "${qt_version}/msvc2019")
|
||||
else()
|
||||
endif()
|
||||
elseif ("${{ runner.os }}" STREQUAL "Linux")
|
||||
@@ -131,14 +131,14 @@ jobs:
|
||||
set(qtc_output_directory "qtcreator/lib/qtcreator/plugins")
|
||||
set(qtc_binary_name "$ENV{PLUGIN_NAME}4.dll")
|
||||
if ("${{ matrix.config.environment_script }}" MATCHES "vcvars64.bat")
|
||||
set(qtc_platform "windows_msvc2017_x64")
|
||||
set(qtc_platform "windows_x64")
|
||||
elseif ("${{ matrix.config.environment_script }}" MATCHES "vcvars32.bat")
|
||||
set(qtc_platform "windows_msvc2017_x86")
|
||||
set(qtc_platform "windows_x86")
|
||||
endif()
|
||||
elseif ("${{ runner.os }}" STREQUAL "Linux")
|
||||
set(qtc_output_directory "qtcreator/lib/qtcreator/plugins")
|
||||
set(qtc_binary_name "lib$ENV{PLUGIN_NAME}.so")
|
||||
set(qtc_platform "linux_gcc_64_rhel72")
|
||||
set(qtc_platform "linux_x64")
|
||||
elseif ("${{ runner.os }}" STREQUAL "macOS")
|
||||
set(qtc_output_directory "qtcreator/bin/Qt Creator.app/Contents/PlugIns")
|
||||
set(qtc_binary_name "lib$ENV{PLUGIN_NAME}.dylib")
|
||||
@@ -167,7 +167,7 @@ jobs:
|
||||
)
|
||||
endif()
|
||||
|
||||
- name: Configure
|
||||
- name: Build
|
||||
shell: cmake -P {0}
|
||||
run: |
|
||||
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
|
||||
@@ -179,9 +179,6 @@ jobs:
|
||||
foreach(line IN LISTS output_lines)
|
||||
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
|
||||
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
|
||||
|
||||
# Set for other steps
|
||||
message("::set-env name=${CMAKE_MATCH_1}::${CMAKE_MATCH_2}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
@@ -200,9 +197,6 @@ jobs:
|
||||
message(FATAL_ERROR "Bad exit status")
|
||||
endif()
|
||||
|
||||
- name: Build
|
||||
shell: cmake -P {0}
|
||||
run: |
|
||||
if ("${{ runner.os }}" STREQUAL "Windows")
|
||||
set(ENV{PATH} "${{ steps.qt.outputs.qt_dir }}/bin/;$ENV{PATH}")
|
||||
else()
|
@@ -11,8 +11,8 @@ HEADERS += \\
|
||||
%{ConstantsHdrFileName}
|
||||
|
||||
DISTFILES += \\
|
||||
.github/workflow/build_qmake.yml \\
|
||||
.github/workflow/README.md
|
||||
.github/workflows/build_qmake.yml \\
|
||||
.github/workflows/README.md
|
||||
|
||||
# Qt Creator linking
|
||||
|
||||
|
@@ -190,12 +190,12 @@
|
||||
"openAsProject": true
|
||||
},
|
||||
{
|
||||
"source": "github_workflow_build_qmake.yml",
|
||||
"target": ".github/workflow/build_qmake.yml"
|
||||
"source": "github_workflows_build_qmake.yml",
|
||||
"target": ".github/workflows/build_qmake.yml"
|
||||
},
|
||||
{
|
||||
"source": "github_workflow_README.md",
|
||||
"target": ".github/workflow/README.md"
|
||||
"source": "github_workflows_README.md",
|
||||
"target": ".github/workflows/README.md"
|
||||
},
|
||||
{
|
||||
"source": "myplugin.cpp",
|
||||
|
@@ -2554,13 +2554,6 @@ To hide a sticky splash screen, invoke QtAndroid::hideSplashScreen().</source>
|
||||
<translation>Анимируемые свойства.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AnnotationToolAction</name>
|
||||
<message>
|
||||
<source>Edit Annotation</source>
|
||||
<translation>Изменить аннотацию</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Application</name>
|
||||
<message>
|
||||
@@ -39440,13 +39433,6 @@ Neither the path to the library nor the path to its includes is added to the .pr
|
||||
<translation>Аннотация</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QmlDesigner::AnnotationTool</name>
|
||||
<message>
|
||||
<source>Annotation Tool</source>
|
||||
<translation>Аннотация</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QmlDesigner::AssetExportDialog</name>
|
||||
<message>
|
||||
|
@@ -90,8 +90,8 @@ public:
|
||||
};
|
||||
|
||||
using ResponseHandler = std::function<void(const QByteArray &, QTextCodec *)>;
|
||||
using ResponseHandlers = std::function<void(MessageId, const QByteArray &, QTextCodec *)>;
|
||||
using MethodHandler = std::function<void(const QString, MessageId, const IContent *)>;
|
||||
using ResponseHandlers = std::function<void(const MessageId &, const QByteArray &, QTextCodec *)>;
|
||||
using MethodHandler = std::function<void(const QString &, const MessageId &, const IContent *)>;
|
||||
|
||||
inline uint qHash(const LanguageServerProtocol::MessageId &id)
|
||||
{
|
||||
|
@@ -85,8 +85,8 @@ void JsonRpcMessageHandler::registerMessageProvider(
|
||||
void JsonRpcMessageHandler::parseContent(const QByteArray &content,
|
||||
QTextCodec *codec,
|
||||
QString &parseError,
|
||||
ResponseHandlers responseHandlers,
|
||||
MethodHandler methodHandler)
|
||||
const ResponseHandlers &responseHandlers,
|
||||
const MethodHandler &methodHandler)
|
||||
{
|
||||
const QJsonObject &jsonObject = toJsonObject(content, codec, parseError);
|
||||
if (jsonObject.isEmpty())
|
||||
|
@@ -76,8 +76,8 @@ public:
|
||||
}
|
||||
static QByteArray jsonRpcMimeType();
|
||||
static void parseContent(const QByteArray &content, QTextCodec *codec, QString &errorMessage,
|
||||
ResponseHandlers responseHandlers,
|
||||
MethodHandler methodHandler);
|
||||
const ResponseHandlers &responseHandlers,
|
||||
const MethodHandler &methodHandler);
|
||||
static QJsonObject toJsonObject(const QByteArray &content, QTextCodec *codec, QString &parseError);
|
||||
|
||||
private:
|
||||
|
@@ -399,6 +399,9 @@ QString formatElapsedTime(qint64 elapsed)
|
||||
*/
|
||||
QString wildcardToRegularExpression(const QString &original)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
using qsizetype = int;
|
||||
#endif
|
||||
const qsizetype wclen = original.size();
|
||||
QString rx;
|
||||
rx.reserve(wclen + wclen / 16);
|
||||
@@ -455,6 +458,10 @@ QString wildcardToRegularExpression(const QString &original)
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
|
||||
return QRegularExpression::anchoredPattern(rx);
|
||||
#else
|
||||
return "\\A" + rx + "\\z";
|
||||
#endif
|
||||
}
|
||||
} // namespace Utils
|
||||
|
@@ -1414,6 +1414,39 @@ void CppEditorPlugin::test_quickfix_data()
|
||||
<< CppQuickFixFactoryPtr(new InsertQtPropertyMembers)
|
||||
<< _("class C { @Q_PROPERTY(typeid foo READ foo) };\n")
|
||||
<< _();
|
||||
|
||||
QTest::newRow("convert to camel case: normal")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void @lower_case_function();\n")
|
||||
<< _("void lowerCaseFunction();\n");
|
||||
QTest::newRow("convert to camel case: already camel case")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void @camelCaseFunction();\n")
|
||||
<< _();
|
||||
QTest::newRow("convert to camel case: no underscores (lower case)")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void @lowercasefunction();\n")
|
||||
<< _();
|
||||
QTest::newRow("convert to camel case: no underscores (upper case)")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void @UPPERCASEFUNCTION();\n")
|
||||
<< _();
|
||||
QTest::newRow("convert to camel case: non-applicable underscore")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void @m_a_member;\n")
|
||||
<< _("void m_aMember;\n");
|
||||
QTest::newRow("convert to camel case: upper case")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void @UPPER_CASE_FUNCTION();\n")
|
||||
<< _("void upperCaseFunction();\n");
|
||||
QTest::newRow("convert to camel case: partially camel case already")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void mixed@_andCamelCase();\n")
|
||||
<< _("void mixedAndCamelCase();\n");
|
||||
QTest::newRow("convert to camel case: wild mix")
|
||||
<< CppQuickFixFactoryPtr(new ConvertToCamelCase(true))
|
||||
<< _("void @WhAt_TODO_hErE();\n")
|
||||
<< _("void WhAtTODOHErE();\n");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix()
|
||||
|
@@ -2010,9 +2010,13 @@ namespace {
|
||||
class ConvertToCamelCaseOp: public CppQuickFixOperation
|
||||
{
|
||||
public:
|
||||
ConvertToCamelCaseOp(const CppQuickFixInterface &interface, const QString &newName)
|
||||
ConvertToCamelCaseOp(const CppQuickFixInterface &interface, const QString &name,
|
||||
const AST *nameAst, bool test)
|
||||
: CppQuickFixOperation(interface, -1)
|
||||
, m_name(newName)
|
||||
, m_name(name)
|
||||
, m_nameAst(nameAst)
|
||||
, m_isAllUpper(name.isUpper())
|
||||
, m_test(test)
|
||||
{
|
||||
setDescription(QApplication::translate("CppTools::QuickFix", "Convert to Camel Case"));
|
||||
}
|
||||
@@ -2022,17 +2026,24 @@ public:
|
||||
CppRefactoringChanges refactoring(snapshot());
|
||||
CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
|
||||
|
||||
for (int i = 1; i < m_name.length(); ++i) {
|
||||
const QChar c = m_name.at(i);
|
||||
if (c.isUpper()) {
|
||||
m_name[i] = c.toLower();
|
||||
} else if (i < m_name.length() - 1
|
||||
&& isConvertibleUnderscore(m_name, i)) {
|
||||
m_name.remove(i, 1);
|
||||
m_name[i] = m_name.at(i).toUpper();
|
||||
QString newName = m_isAllUpper ? m_name.toLower() : m_name;
|
||||
for (int i = 1; i < newName.length(); ++i) {
|
||||
const QChar c = newName.at(i);
|
||||
if (c.isUpper() && m_isAllUpper) {
|
||||
newName[i] = c.toLower();
|
||||
} else if (i < newName.length() - 1 && isConvertibleUnderscore(newName, i)) {
|
||||
newName.remove(i, 1);
|
||||
newName[i] = newName.at(i).toUpper();
|
||||
}
|
||||
}
|
||||
editor()->renameUsages(m_name);
|
||||
if (m_test) {
|
||||
ChangeSet changeSet;
|
||||
changeSet.replace(currentFile->range(m_nameAst), newName);
|
||||
currentFile->setChangeSet(changeSet);
|
||||
currentFile->apply();
|
||||
} else {
|
||||
editor()->renameUsages(newName);
|
||||
}
|
||||
}
|
||||
|
||||
static bool isConvertibleUnderscore(const QString &name, int pos)
|
||||
@@ -2042,7 +2053,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
const QString m_name;
|
||||
const AST * const m_nameAst;
|
||||
const bool m_isAllUpper;
|
||||
const bool m_test;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
@@ -2056,22 +2070,26 @@ void ConvertToCamelCase::match(const CppQuickFixInterface &interface, QuickFixOp
|
||||
|
||||
AST * const ast = path.last();
|
||||
const Name *name = nullptr;
|
||||
const AST *astForName = nullptr;
|
||||
if (const NameAST * const nameAst = ast->asName()) {
|
||||
if (nameAst->name && nameAst->name->asNameId())
|
||||
if (nameAst->name && nameAst->name->asNameId()) {
|
||||
astForName = nameAst;
|
||||
name = nameAst->name;
|
||||
}
|
||||
} else if (const NamespaceAST * const namespaceAst = ast->asNamespace()) {
|
||||
astForName = namespaceAst;
|
||||
name = namespaceAst->symbol->name();
|
||||
}
|
||||
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
QString newName = QString::fromUtf8(name->identifier()->chars());
|
||||
if (newName.length() < 3)
|
||||
QString nameString = QString::fromUtf8(name->identifier()->chars());
|
||||
if (nameString.length() < 3)
|
||||
return;
|
||||
for (int i = 1; i < newName.length() - 1; ++i) {
|
||||
if (ConvertToCamelCaseOp::isConvertibleUnderscore(newName, i)) {
|
||||
result << new ConvertToCamelCaseOp(interface, newName);
|
||||
for (int i = 1; i < nameString.length() - 1; ++i) {
|
||||
if (ConvertToCamelCaseOp::isConvertibleUnderscore(nameString, i)) {
|
||||
result << new ConvertToCamelCaseOp(interface, nameString, astForName, m_test);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -221,7 +221,12 @@ public:
|
||||
class ConvertToCamelCase : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
ConvertToCamelCase(bool test = false) : CppQuickFixFactory(), m_test(test) {}
|
||||
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
|
||||
private:
|
||||
const bool m_test;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@@ -213,7 +213,7 @@ Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
|
||||
return {start, start + token.utf16chars()};
|
||||
}
|
||||
|
||||
Utils::ChangeSet::Range CppRefactoringFile::range(AST *ast) const
|
||||
Utils::ChangeSet::Range CppRefactoringFile::range(const AST *ast) const
|
||||
{
|
||||
return {startOf(ast), endOf(ast)};
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
Range range(int start, int end) const;
|
||||
Range range(unsigned tokenIndex) const;
|
||||
Range range(CPlusPlus::AST *ast) const;
|
||||
Range range(const CPlusPlus::AST *ast) const;
|
||||
|
||||
const CPlusPlus::Token &tokenAt(unsigned index) const;
|
||||
|
||||
|
@@ -324,7 +324,7 @@ private:
|
||||
{
|
||||
QTextCursor tc = m_editor->textCursor();
|
||||
m_currentPos = tc.position();
|
||||
m_lineSpacing = m_editor->document()->documentLayout()->blockBoundingRect(tc.block()).height();
|
||||
m_lineSpacing = m_editor->cursorRect(tc).height();
|
||||
setFont(m_editor->extraArea()->font());
|
||||
|
||||
// Follow geometry of normal line numbers if visible,
|
||||
|
@@ -938,10 +938,10 @@ void Client::handleMessage(const BaseMessage &message)
|
||||
if (auto handler = m_contentHandler[message.mimeType]) {
|
||||
QString parseError;
|
||||
handler(message.content, message.codec, parseError,
|
||||
[this](MessageId id, const QByteArray &content, QTextCodec *codec){
|
||||
[this](const MessageId &id, const QByteArray &content, QTextCodec *codec){
|
||||
this->handleResponse(id, content, codec);
|
||||
},
|
||||
[this](const QString &method, MessageId id, const IContent *content){
|
||||
[this](const QString &method, const MessageId &id, const IContent *content){
|
||||
this->handleMethod(method, id, content);
|
||||
});
|
||||
if (!parseError.isEmpty())
|
||||
@@ -1072,7 +1072,7 @@ void Client::handleResponse(const MessageId &id, const QByteArray &content, QTex
|
||||
handler(content, codec);
|
||||
}
|
||||
|
||||
void Client::handleMethod(const QString &method, MessageId id, const IContent *content)
|
||||
void Client::handleMethod(const QString &method, const MessageId &id, const IContent *content)
|
||||
{
|
||||
ErrorHierarchy error;
|
||||
auto logError = [&](const JsonObject &content) {
|
||||
|
@@ -189,7 +189,7 @@ protected:
|
||||
private:
|
||||
void handleResponse(const LanguageServerProtocol::MessageId &id, const QByteArray &content,
|
||||
QTextCodec *codec);
|
||||
void handleMethod(const QString &method, LanguageServerProtocol::MessageId id,
|
||||
void handleMethod(const QString &method, const LanguageServerProtocol::MessageId &id,
|
||||
const LanguageServerProtocol::IContent *content);
|
||||
|
||||
void handleDiagnostics(const LanguageServerProtocol::PublishDiagnosticsParams ¶ms);
|
||||
|
@@ -183,10 +183,18 @@ void SessionModel::sort(int column, Qt::SortOrder order)
|
||||
beginResetModel();
|
||||
const auto cmp = [column, order](const QString &s1, const QString &s2) {
|
||||
bool isLess;
|
||||
if (column == 0)
|
||||
if (column == 0) {
|
||||
if (s1 == s2)
|
||||
return false;
|
||||
isLess = s1 < s2;
|
||||
else
|
||||
isLess = SessionManager::sessionDateTime(s1) < SessionManager::sessionDateTime(s2);
|
||||
}
|
||||
else {
|
||||
const auto s1time = SessionManager::sessionDateTime(s1);
|
||||
const auto s2time = SessionManager::sessionDateTime(s2);
|
||||
if (s1time == s2time)
|
||||
return false;
|
||||
isLess = s1time < s2time;
|
||||
}
|
||||
if (order == Qt::DescendingOrder)
|
||||
isLess = !isLess;
|
||||
return isLess;
|
||||
|
@@ -29,7 +29,6 @@ add_qtc_plugin(QmlDesigner
|
||||
qmldesignerplugin.cpp qmldesignerplugin.h
|
||||
settingspage.cpp settingspage.h settingspage.ui
|
||||
shortcutmanager.cpp shortcutmanager.h
|
||||
switchsplittabwidget.cpp switchsplittabwidget.h
|
||||
designermcumanager.cpp designermcumanager.h
|
||||
EXPLICIT_MOC
|
||||
components/propertyeditor/propertyeditorvalue.h
|
||||
@@ -627,7 +626,6 @@ extend_qtc_plugin(QmlDesigner
|
||||
annotationeditordialog.cpp annotationeditordialog.h annotationeditordialog.ui
|
||||
globalannotationeditordialog.cpp globalannotationeditordialog.h globalannotationeditordialog.ui
|
||||
annotationeditor.cpp annotationeditor.h
|
||||
annotationtool.cpp annotationtool.h
|
||||
globalannotationeditor.cpp globalannotationeditor.h
|
||||
)
|
||||
|
||||
|
@@ -1,11 +1,9 @@
|
||||
HEADERS += $$PWD/annotationtool.h
|
||||
HEADERS += $$PWD/annotationcommenttab.h
|
||||
HEADERS += $$PWD/annotationeditordialog.h
|
||||
HEADERS += $$PWD/annotationeditor.h
|
||||
HEADERS += $$PWD/globalannotationeditor.h
|
||||
HEADERS += $$PWD/globalannotationeditordialog.h
|
||||
|
||||
SOURCES += $$PWD/annotationtool.cpp
|
||||
SOURCES += $$PWD/annotationcommenttab.cpp
|
||||
SOURCES += $$PWD/annotationeditordialog.cpp
|
||||
SOURCES += $$PWD/annotationeditor.cpp
|
||||
|
@@ -1,259 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "annotationtool.h"
|
||||
|
||||
#include "formeditorscene.h"
|
||||
#include "formeditorview.h"
|
||||
#include "formeditorwidget.h"
|
||||
#include "itemutilfunctions.h"
|
||||
#include "formeditoritem.h"
|
||||
|
||||
#include "nodemetainfo.h"
|
||||
#include "qmlitemnode.h"
|
||||
#include <qmldesignerplugin.h>
|
||||
#include <abstractaction.h>
|
||||
#include <designeractionmanager.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QPair>
|
||||
#include <QUrl>
|
||||
#include <QMetaType>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class AnnotationToolAction : public AbstractAction
|
||||
{
|
||||
public:
|
||||
AnnotationToolAction() : AbstractAction(QCoreApplication::translate("AnnotationToolAction","Edit Annotation"))
|
||||
{
|
||||
}
|
||||
|
||||
QByteArray category() const override
|
||||
{
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QByteArray menuId() const override
|
||||
{
|
||||
return "AnnotationTool";
|
||||
}
|
||||
|
||||
int priority() const override
|
||||
{
|
||||
return CustomActionsPriority + 5;
|
||||
}
|
||||
|
||||
Type type() const override
|
||||
{
|
||||
return FormEditorAction;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool isVisible(const SelectionContext &selectionContext) const override
|
||||
{
|
||||
return selectionContext.singleNodeIsSelected();
|
||||
}
|
||||
|
||||
bool isEnabled(const SelectionContext &selectionContext) const override
|
||||
{
|
||||
return isVisible(selectionContext);
|
||||
}
|
||||
};
|
||||
|
||||
AnnotationTool::AnnotationTool()
|
||||
{
|
||||
auto annotationToolAction = new AnnotationToolAction;
|
||||
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(annotationToolAction);
|
||||
connect(annotationToolAction->action(), &QAction::triggered, [=]() {
|
||||
view()->changeCurrentToolTo(this);
|
||||
});
|
||||
}
|
||||
|
||||
AnnotationTool::~AnnotationTool() = default;
|
||||
|
||||
void AnnotationTool::clear()
|
||||
{
|
||||
if (m_annotationEditor)
|
||||
m_annotationEditor->deleteLater();
|
||||
|
||||
AbstractFormEditorTool::clear();
|
||||
}
|
||||
|
||||
void AnnotationTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
AbstractFormEditorTool::mousePressEvent(itemList, event);
|
||||
}
|
||||
|
||||
void AnnotationTool::mouseMoveEvent(const QList<QGraphicsItem*> & /*itemList*/,
|
||||
QGraphicsSceneMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::hoverMoveEvent(const QList<QGraphicsItem*> & /*itemList*/,
|
||||
QGraphicsSceneMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::keyPressEvent(QKeyEvent * /*keyEvent*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::dragLeaveEvent(const QList<QGraphicsItem*> &/*itemList*/, QGraphicsSceneDragDropEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::dragMoveEvent(const QList<QGraphicsItem*> &/*itemList*/, QGraphicsSceneDragDropEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
AbstractFormEditorTool::mouseReleaseEvent(itemList, event);
|
||||
}
|
||||
|
||||
|
||||
void AnnotationTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList, QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
AbstractFormEditorTool::mouseDoubleClickEvent(itemList, event);
|
||||
}
|
||||
|
||||
void AnnotationTool::itemsAboutToRemoved(const QList<FormEditorItem*> &removedItemList)
|
||||
{
|
||||
if (m_annotationEditor.isNull())
|
||||
return;
|
||||
|
||||
if (removedItemList.contains(m_formEditorItem))
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
|
||||
void AnnotationTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
|
||||
{
|
||||
if (!itemList.isEmpty()) {
|
||||
m_formEditorItem = itemList.constFirst();
|
||||
|
||||
ModelNode itemModelNode = m_formEditorItem->qmlItemNode().modelNode();
|
||||
m_oldCustomId = itemModelNode.customId();
|
||||
m_oldAnnotation = itemModelNode.annotation();
|
||||
|
||||
if (m_annotationEditor.isNull()) {
|
||||
m_annotationEditor = new AnnotationEditorDialog(view()->formEditorWidget()->parentWidget(),
|
||||
itemModelNode.displayName(),
|
||||
m_oldCustomId, m_oldAnnotation);
|
||||
|
||||
connect(m_annotationEditor, &AnnotationEditorDialog::accepted, this, &AnnotationTool::annotationDialogAccepted);
|
||||
connect(m_annotationEditor, &QDialog::rejected, this, &AnnotationTool::annotationDialogRejected);
|
||||
|
||||
m_annotationEditor->show();
|
||||
m_annotationEditor->raise();
|
||||
}
|
||||
} else {
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
}
|
||||
|
||||
void AnnotationTool::instancesCompleted(const QList<FormEditorItem*> & /*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::instancesParentChanged(const QList<FormEditorItem *> & /*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > & /*propertyList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnnotationTool::formEditorItemsChanged(const QList<FormEditorItem*> & /*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
int AnnotationTool::wantHandleItem(const ModelNode & /*modelNode*/) const
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
QString AnnotationTool::name() const
|
||||
{
|
||||
return tr("Annotation Tool");
|
||||
}
|
||||
|
||||
void AnnotationTool::annotationDialogAccepted()
|
||||
{
|
||||
if (m_annotationEditor) {
|
||||
saveNewCustomId(m_annotationEditor->customId());
|
||||
saveNewAnnotation(m_annotationEditor->annotation());
|
||||
|
||||
m_annotationEditor->close();
|
||||
m_annotationEditor->deleteLater();
|
||||
}
|
||||
|
||||
m_annotationEditor = nullptr;
|
||||
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
|
||||
void AnnotationTool::saveNewCustomId(const QString &customId)
|
||||
{
|
||||
if (m_formEditorItem) {
|
||||
m_oldCustomId = customId;
|
||||
m_formEditorItem->qmlItemNode().modelNode().setCustomId(customId);
|
||||
}
|
||||
}
|
||||
|
||||
void AnnotationTool::saveNewAnnotation(const Annotation &annotation)
|
||||
{
|
||||
if (m_formEditorItem) {
|
||||
if (annotation.comments().isEmpty())
|
||||
m_formEditorItem->qmlItemNode().modelNode().removeAnnotation();
|
||||
else
|
||||
m_formEditorItem->qmlItemNode().modelNode().setAnnotation(annotation);
|
||||
|
||||
m_oldAnnotation = annotation;
|
||||
}
|
||||
}
|
||||
|
||||
void AnnotationTool::annotationDialogRejected()
|
||||
{
|
||||
if (m_annotationEditor) {
|
||||
m_annotationEditor->close();
|
||||
m_annotationEditor->deleteLater();
|
||||
}
|
||||
|
||||
m_annotationEditor = nullptr;
|
||||
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "annotation.h"
|
||||
#include "annotationeditordialog.h"
|
||||
#include "abstractcustomtool.h"
|
||||
#include "selectionindicator.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QPointer>
|
||||
#include <QDialog>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class AnnotationTool : public QObject, public AbstractCustomTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AnnotationTool();
|
||||
~AnnotationTool() override;
|
||||
|
||||
void mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent) override;
|
||||
|
||||
void dragLeaveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneDragDropEvent * event) override;
|
||||
void dragMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneDragDropEvent * event) override;
|
||||
|
||||
void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList) override;
|
||||
|
||||
void selectedItemsChanged(const QList<FormEditorItem*> &itemList) override; //impl needed
|
||||
|
||||
void instancesCompleted(const QList<FormEditorItem*> &itemList) override;
|
||||
void instancesParentChanged(const QList<FormEditorItem *> &itemList) override;
|
||||
void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) override;
|
||||
|
||||
void clear() override;
|
||||
|
||||
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) override;
|
||||
|
||||
int wantHandleItem(const ModelNode &modelNode) const override;
|
||||
|
||||
QString name() const override;
|
||||
|
||||
private:
|
||||
void annotationDialogAccepted();
|
||||
void annotationDialogRejected();
|
||||
void saveNewCustomId(const QString &customId);
|
||||
void saveNewAnnotation(const Annotation &annotation);
|
||||
|
||||
private:
|
||||
FormEditorItem *m_formEditorItem = nullptr;
|
||||
QString m_oldCustomId;
|
||||
Annotation m_oldAnnotation;
|
||||
QPointer<AnnotationEditorDialog> m_annotationEditor;
|
||||
};
|
||||
|
||||
}
|
@@ -39,10 +39,10 @@
|
||||
|
||||
namespace DesignTools {
|
||||
|
||||
CurveEditorModel::CurveEditorModel(double minTime, double maxTime, QObject *parent)
|
||||
CurveEditorModel::CurveEditorModel(QObject *parent)
|
||||
: TreeModel(parent)
|
||||
, m_minTime(minTime)
|
||||
, m_maxTime(maxTime)
|
||||
, m_minTime(CurveEditorStyle::defaultTimeMin)
|
||||
, m_maxTime(CurveEditorStyle::defaultTimeMax)
|
||||
{}
|
||||
|
||||
CurveEditorModel::~CurveEditorModel() {}
|
||||
|
@@ -57,7 +57,7 @@ signals:
|
||||
void curveChanged(PropertyTreeItem *item);
|
||||
|
||||
public:
|
||||
CurveEditorModel(double minTime, double maxTime, QObject *parent = nullptr);
|
||||
CurveEditorModel(QObject *parent = nullptr);
|
||||
|
||||
~CurveEditorModel() override;
|
||||
|
||||
|
@@ -36,6 +36,8 @@
|
||||
#include <QIcon>
|
||||
#include <QKeySequence>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace DesignTools {
|
||||
|
||||
struct TreeItemStyleOption
|
||||
@@ -105,6 +107,13 @@ struct Shortcuts
|
||||
|
||||
struct CurveEditorStyle
|
||||
{
|
||||
static constexpr double defaultTimeMin = 0.0;
|
||||
static constexpr double defaultTimeMax = 100.0;
|
||||
static constexpr double defaultValueMin = -1.0;
|
||||
static constexpr double defaultValueMax = 1.0;
|
||||
|
||||
static double defaultValueRange() { return std::fabs(defaultValueMin - defaultValueMax); }
|
||||
|
||||
Shortcuts shortcuts;
|
||||
|
||||
QBrush backgroundBrush = QBrush(QColor(5, 0, 100));
|
||||
@@ -124,7 +133,7 @@ struct CurveEditorStyle
|
||||
double valueAxisWidth = 60.0;
|
||||
double valueOffsetTop = 10.0;
|
||||
double valueOffsetBottom = 10.0;
|
||||
double labelDensityY = 1.5;
|
||||
double labelDensityY = 2.0;
|
||||
|
||||
HandleItemStyleOption handleStyle;
|
||||
KeyframeItemStyleOption keyframeStyle;
|
||||
|
@@ -42,7 +42,7 @@ namespace QmlDesigner {
|
||||
CurveEditorView::CurveEditorView(QObject *parent)
|
||||
: AbstractView(parent)
|
||||
, m_block(false)
|
||||
, m_model(new DesignTools::CurveEditorModel(0., 500.))
|
||||
, m_model(new DesignTools::CurveEditorModel())
|
||||
, m_editor(new DesignTools::CurveEditor(m_model))
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
@@ -267,7 +267,7 @@ ModelNode getTargetNode1(DesignTools::PropertyTreeItem *item, const QmlTimeline
|
||||
QString targetId = nodeItem->name();
|
||||
if (timeline.isValid()) {
|
||||
for (auto &&target : timeline.allTargets()) {
|
||||
if (target.displayName() == targetId)
|
||||
if (target.isValid() && target.displayName() == targetId)
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
@@ -87,6 +87,16 @@ QRectF CurveItem::boundingRect() const
|
||||
for (auto *item : m_keyframes)
|
||||
bbox(bounds, item->keyframe());
|
||||
|
||||
if (auto *s = qobject_cast<GraphicsScene *>(scene())) {
|
||||
bounds.setLeft(s->animationRangeMin());
|
||||
bounds.setRight(s->animationRangeMax());
|
||||
}
|
||||
|
||||
if (qFuzzyCompare(bounds.height(), 0.0)) {
|
||||
auto tmp = CurveEditorStyle::defaultValueRange() / 2.0;
|
||||
bounds.adjust(0.0, -tmp, 0.0, tmp);
|
||||
}
|
||||
|
||||
return m_transform.mapRect(bounds);
|
||||
}
|
||||
|
||||
|
@@ -114,9 +114,29 @@ double GraphicsScene::maximumValue() const
|
||||
return limits().top();
|
||||
}
|
||||
|
||||
double GraphicsScene::animationRangeMin() const
|
||||
{
|
||||
if (GraphicsView *gview = graphicsView())
|
||||
return gview->minimumTime();
|
||||
|
||||
return minimumTime();
|
||||
}
|
||||
|
||||
double GraphicsScene::animationRangeMax() const
|
||||
{
|
||||
if (GraphicsView *gview = graphicsView())
|
||||
return gview->maximumTime();
|
||||
|
||||
return maximumTime();
|
||||
}
|
||||
|
||||
QRectF GraphicsScene::rect() const
|
||||
{
|
||||
return sceneRect();
|
||||
QRectF rect;
|
||||
for (auto *curve : curves())
|
||||
rect |= curve->boundingRect();
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
QVector<CurveItem *> GraphicsScene::curves() const
|
||||
@@ -410,6 +430,11 @@ QRectF GraphicsScene::limits() const
|
||||
}
|
||||
|
||||
m_limits = QRectF(QPointF(min.x(), max.y()), QPointF(max.x(), min.y()));
|
||||
if (qFuzzyCompare(m_limits.height(), 0.0)) {
|
||||
auto tmp = CurveEditorStyle::defaultValueRange() / 2.0;
|
||||
m_limits.adjust(0.0, tmp, 0.0, -tmp);
|
||||
}
|
||||
|
||||
m_dirty = false;
|
||||
}
|
||||
return m_limits;
|
||||
|
@@ -67,6 +67,10 @@ public:
|
||||
|
||||
double maximumValue() const;
|
||||
|
||||
double animationRangeMin() const;
|
||||
|
||||
double animationRangeMax() const;
|
||||
|
||||
QRectF rect() const;
|
||||
|
||||
QVector<CurveItem *> curves() const;
|
||||
|
@@ -126,12 +126,12 @@ double GraphicsView::maximumTime() const
|
||||
|
||||
double GraphicsView::minimumValue() const
|
||||
{
|
||||
return m_scene->empty() ? -1.0 : m_scene->minimumValue();
|
||||
return m_scene->empty() ? CurveEditorStyle::defaultValueMin : m_scene->minimumValue();
|
||||
}
|
||||
|
||||
double GraphicsView::maximumValue() const
|
||||
{
|
||||
return m_scene->empty() ? 1.0 : m_scene->maximumValue();
|
||||
return m_scene->empty() ? CurveEditorStyle::defaultValueMax : m_scene->maximumValue();
|
||||
}
|
||||
|
||||
double GraphicsView::zoomX() const
|
||||
|
@@ -92,7 +92,7 @@ void Edit3DCanvas::paintEvent(QPaintEvent *e)
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
painter.drawImage(rect(), m_image, rect());
|
||||
painter.drawImage(rect(), m_image, QRect(0, 0, m_image.width(), m_image.height()));
|
||||
}
|
||||
|
||||
void Edit3DCanvas::resizeEvent(QResizeEvent *e)
|
||||
|
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "designmodewidget.h"
|
||||
#include "switchsplittabwidget.h"
|
||||
|
||||
#include <designeractionmanager.h>
|
||||
|
||||
|
@@ -50,7 +50,6 @@ namespace QmlDesigner {
|
||||
class ItemLibraryWidget;
|
||||
class CrumbleBar;
|
||||
class DocumentWarningWidget;
|
||||
class SwitchSplitTabWidget;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -103,8 +102,6 @@ private: // functions
|
||||
void aboutToShowWorkspaces();
|
||||
|
||||
private: // variables
|
||||
SwitchSplitTabWidget* m_centralTabWidget = nullptr;
|
||||
|
||||
QPointer<QWidget> m_bottomSideBar;
|
||||
Core::EditorToolBar *m_toolBar;
|
||||
CrumbleBar *m_crumbleBar;
|
||||
|
@@ -37,7 +37,6 @@
|
||||
#include <connectionview.h>
|
||||
#include <sourcetool/sourcetool.h>
|
||||
#include <colortool/colortool.h>
|
||||
#include <annotationeditor/annotationtool.h>
|
||||
#include <curveeditor/curveeditorview.h>
|
||||
#include <formeditor/transitiontool.h>
|
||||
#include <texttool/texttool.h>
|
||||
@@ -250,7 +249,6 @@ bool QmlDesignerPlugin::delayedInitialize()
|
||||
|
||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::SourceTool);
|
||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::ColorTool);
|
||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::AnnotationTool);
|
||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TextTool);
|
||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::PathTool);
|
||||
d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TransitionTool);
|
||||
|
@@ -2,7 +2,6 @@ HEADERS += $$PWD/qmldesignerconstants.h \
|
||||
$$PWD/shortcutmanager.h \
|
||||
$$PWD/qmldesignerplugin.h \
|
||||
$$PWD/designmodewidget.h \
|
||||
$$PWD/switchsplittabwidget.h \
|
||||
$$PWD/designersettings.h \
|
||||
$$PWD/generateresource.h \
|
||||
$$PWD/settingspage.h \
|
||||
@@ -16,7 +15,6 @@ HEADERS += $$PWD/qmldesignerconstants.h \
|
||||
SOURCES += $$PWD/qmldesignerplugin.cpp \
|
||||
$$PWD/shortcutmanager.cpp \
|
||||
$$PWD/designmodewidget.cpp \
|
||||
$$PWD/switchsplittabwidget.cpp \
|
||||
$$PWD/designersettings.cpp \
|
||||
$$PWD/generateresource.cpp \
|
||||
$$PWD/settingspage.cpp \
|
||||
|
@@ -712,8 +712,6 @@ Project {
|
||||
"annotationeditor/globalannotationeditordialog.cpp",
|
||||
"annotationeditor/globalannotationeditordialog.h",
|
||||
"annotationeditor/globalannotationeditordialog.ui",
|
||||
"annotationeditor/annotationtool.cpp",
|
||||
"annotationeditor/annotationtool.h",
|
||||
"bindingeditor/bindingeditor.cpp",
|
||||
"bindingeditor/bindingeditor.h",
|
||||
"bindingeditor/actioneditor.cpp",
|
||||
@@ -935,8 +933,6 @@ Project {
|
||||
"designmodecontext.h",
|
||||
"designmodewidget.cpp",
|
||||
"designmodewidget.h",
|
||||
"switchsplittabwidget.cpp",
|
||||
"switchsplittabwidget.h",
|
||||
"documentmanager.cpp",
|
||||
"documentmanager.h",
|
||||
"documentwarningwidget.cpp",
|
||||
|
@@ -1,212 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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 "switchsplittabwidget.h"
|
||||
#include <theme.h>
|
||||
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QVector>
|
||||
#include <QBoxLayout>
|
||||
#include <QTabBar>
|
||||
#include <QToolButton>
|
||||
#include <QSplitter>
|
||||
#include <QLayoutItem>
|
||||
#include <QEvent>
|
||||
|
||||
namespace QmlDesigner {
|
||||
SwitchSplitTabWidget::SwitchSplitTabWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_splitter(new QSplitter)
|
||||
, m_tabBar(new QTabBar)
|
||||
, m_tabBarBackground(new QWidget)
|
||||
{
|
||||
// setting object names for css
|
||||
setObjectName("backgroundWidget");
|
||||
m_splitter->setObjectName("centralTabWidget");
|
||||
m_splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_splitter->setHandleWidth(0);
|
||||
|
||||
QString sheet = QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/centerwidget.css"));
|
||||
m_tabBarBackground->setStyleSheet(Theme::replaceCssColors(sheet));
|
||||
|
||||
m_tabBar->setObjectName("centralTabBar");
|
||||
m_tabBar->setShape(QTabBar::RoundedEast);
|
||||
m_tabBar->setDocumentMode(false);
|
||||
// add a faketab to have the possibility to unselect all tabs
|
||||
m_tabBar->addTab(QString());
|
||||
selectFakeTab();
|
||||
|
||||
m_tabBarBackground->setObjectName("tabBarBackground");
|
||||
|
||||
connect(m_tabBar, &QTabBar::tabBarClicked, [this] (int index) {
|
||||
if (index != -1)
|
||||
updateSplitterSizes(index - fakeTab);
|
||||
});
|
||||
|
||||
setLayout(new QHBoxLayout);
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
layout()->setSpacing(0);
|
||||
layout()->addWidget(m_splitter);
|
||||
|
||||
m_tabBarBackground->setLayout(new QVBoxLayout);
|
||||
m_tabBarBackground->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
m_tabBarBackground->layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
m_tabBarBackground->layout()->addWidget(m_tabBar);
|
||||
|
||||
auto horizontalButton = new QToolButton;
|
||||
horizontalButton->setObjectName("centralTabBar");
|
||||
horizontalButton->setIcon(Utils::Icon({{QLatin1String(":/qmldesigner/images/spliteditorvertically.png"),
|
||||
Utils::Theme::IconsBaseColor}}).icon());
|
||||
horizontalButton->setIconSize(QSize(8, 16));
|
||||
connect(horizontalButton, &QToolButton::clicked, [this] () {
|
||||
m_splitter->setOrientation(Qt::Vertical);
|
||||
updateSplitterSizes();
|
||||
selectFakeTab();
|
||||
});
|
||||
auto verticalButton = new QToolButton;
|
||||
verticalButton->setObjectName("centralTabBar");
|
||||
verticalButton->setIcon(Utils::Icon({{QLatin1String(":/qmldesigner/images/spliteditorhorizontally.png"),
|
||||
Utils::Theme::IconsBaseColor}}).icon());
|
||||
verticalButton->setIconSize(QSize(8, 16));
|
||||
connect(verticalButton, &QToolButton::clicked, [this] () {
|
||||
m_splitter->setOrientation(Qt::Horizontal);
|
||||
updateSplitterSizes();
|
||||
selectFakeTab();
|
||||
});
|
||||
|
||||
m_tabBarBackground->layout()->addWidget(horizontalButton);
|
||||
m_tabBarBackground->layout()->addWidget(verticalButton);
|
||||
layout()->addWidget(m_tabBarBackground);
|
||||
updateSplitButtons();
|
||||
}
|
||||
|
||||
int SwitchSplitTabWidget::count() const
|
||||
{
|
||||
return m_splitter->count();
|
||||
}
|
||||
|
||||
QWidget *SwitchSplitTabWidget::currentWidget() const
|
||||
{
|
||||
QList<int> sizes = m_splitter->sizes();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (sizes.at(i) > 0 && m_splitter->widget(i)->hasFocus())
|
||||
return m_splitter->widget(i);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SwitchSplitTabWidget::updateSplitterSizes(int index)
|
||||
{
|
||||
QVector<int> splitterSizes(m_splitter->count());
|
||||
int splitterFullSize = 0;
|
||||
bool isHorizontal = m_splitter->orientation() == Qt::Horizontal;
|
||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||
auto widget = m_splitter->widget(i);
|
||||
splitterFullSize += isHorizontal ? widget->width() : widget->height();
|
||||
}
|
||||
|
||||
if (index > -1) {
|
||||
// collapse all but the one at index
|
||||
splitterSizes.fill(0);
|
||||
splitterSizes.replace(index, splitterFullSize);
|
||||
} else {
|
||||
// distribute full size among enabled tabs
|
||||
int divisor = splitterSizes.count();
|
||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||
if (!m_tabBar->isTabEnabled(i + fakeTab))
|
||||
--divisor;
|
||||
}
|
||||
|
||||
int splitSize = splitterFullSize / divisor;
|
||||
for (int i = 0; i < m_splitter->count(); ++i)
|
||||
splitterSizes.replace(i, m_tabBar->isTabEnabled(i + fakeTab) ? splitSize : 0);
|
||||
}
|
||||
|
||||
m_splitter->setSizes(splitterSizes.toList());
|
||||
}
|
||||
|
||||
int SwitchSplitTabWidget::addTab(QWidget *w, const QString &label)
|
||||
{
|
||||
m_splitter->addWidget(w);
|
||||
const int newIndex = m_tabBar->addTab(label);
|
||||
if (mode() == TabMode) {
|
||||
m_tabBar->setCurrentIndex(newIndex);
|
||||
updateSplitterSizes(newIndex - fakeTab);
|
||||
}
|
||||
if (mode() == SplitMode)
|
||||
updateSplitterSizes();
|
||||
updateSplitButtons();
|
||||
return newIndex;
|
||||
}
|
||||
|
||||
QWidget *SwitchSplitTabWidget::takeTabWidget(const int index)
|
||||
{
|
||||
if (index == -1 || index > count() - 1)
|
||||
return nullptr;
|
||||
QWidget *widget = m_splitter->widget(index);
|
||||
widget->setParent(nullptr);
|
||||
m_tabBar->removeTab(index + fakeTab);
|
||||
// TODO: set which mode and tab is the current one
|
||||
updateSplitButtons();
|
||||
return widget;
|
||||
}
|
||||
|
||||
void SwitchSplitTabWidget::switchTo(QWidget *widget)
|
||||
{
|
||||
if (widget == nullptr || currentWidget() == widget)
|
||||
return;
|
||||
const int widgetIndex = m_splitter->indexOf(widget);
|
||||
Q_ASSERT(widgetIndex != -1);
|
||||
if (mode() == TabMode) {
|
||||
updateSplitterSizes(widgetIndex);
|
||||
m_tabBar->setCurrentIndex(widgetIndex + fakeTab);
|
||||
}
|
||||
|
||||
widget->setFocus();
|
||||
}
|
||||
|
||||
void SwitchSplitTabWidget::updateSplitButtons()
|
||||
{
|
||||
const bool isTabBarNecessary = count() > 1;
|
||||
m_tabBarBackground->setVisible(isTabBarNecessary);
|
||||
}
|
||||
|
||||
void SwitchSplitTabWidget::selectFakeTab()
|
||||
{
|
||||
m_tabBar->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
SwitchSplitTabWidget::Mode SwitchSplitTabWidget::mode() const
|
||||
{
|
||||
const bool isTabBarNecessary = count() > 1;
|
||||
const int fakeTabPosition = 0;
|
||||
const int hasSelectedTab = m_tabBar->currentIndex() > fakeTabPosition;
|
||||
// Note: When splitting the view by dragging from the side of the view, SplitMode is not detected
|
||||
return (isTabBarNecessary && !hasSelectedTab) ? SplitMode : TabMode;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
@@ -485,8 +485,9 @@ void CodeAssistantPrivate::destroyContext()
|
||||
|
||||
if (isWaitingForProposal()) {
|
||||
cancelCurrentRequest();
|
||||
} else if (isDisplayingProposal()) {
|
||||
} else if (m_proposalWidget) {
|
||||
m_editorWidget->keepAutoCompletionHighlight(false);
|
||||
if (m_proposalWidget->isVisible())
|
||||
m_proposalWidget->closeProposal();
|
||||
disconnect(m_proposalWidget, &QObject::destroyed,
|
||||
this, &CodeAssistantPrivate::finalizeProposal);
|
||||
|
@@ -45,7 +45,6 @@
|
||||
static const char fontFamilyKey[] = "FontFamily";
|
||||
static const char fontSizeKey[] = "FontSize";
|
||||
static const char fontZoomKey[] = "FontZoom";
|
||||
static const char lineSpacingKey[] = "LineSpacing";
|
||||
static const char antialiasKey[] = "FontAntialias";
|
||||
static const char schemeFileNamesKey[] = "ColorSchemes";
|
||||
|
||||
@@ -57,13 +56,11 @@ static const bool DEFAULT_ANTIALIAS = true;
|
||||
namespace TextEditor {
|
||||
|
||||
// -- FontSettings
|
||||
FontSettings::FontSettings()
|
||||
: m_family(defaultFixedFontFamily())
|
||||
, m_fontSize(defaultFontSize())
|
||||
, m_fontZoom(100)
|
||||
, m_lineSpacing(100)
|
||||
, m_antialias(DEFAULT_ANTIALIAS)
|
||||
, m_lineSpacingCache(0)
|
||||
FontSettings::FontSettings() :
|
||||
m_family(defaultFixedFontFamily()),
|
||||
m_fontSize(defaultFontSize()),
|
||||
m_fontZoom(100),
|
||||
m_antialias(DEFAULT_ANTIALIAS)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -72,10 +69,10 @@ void FontSettings::clear()
|
||||
m_family = defaultFixedFontFamily();
|
||||
m_fontSize = defaultFontSize();
|
||||
m_fontZoom = 100;
|
||||
m_lineSpacing = 100;
|
||||
m_antialias = DEFAULT_ANTIALIAS;
|
||||
m_scheme.clear();
|
||||
clearCaches();
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
}
|
||||
|
||||
static QString settingsGroup()
|
||||
@@ -92,12 +89,9 @@ void FontSettings::toSettings(QSettings *s) const
|
||||
if (m_fontSize != defaultFontSize() || s->contains(QLatin1String(fontSizeKey)))
|
||||
s->setValue(QLatin1String(fontSizeKey), m_fontSize);
|
||||
|
||||
if (m_fontZoom != 100 || s->contains(QLatin1String(fontZoomKey)))
|
||||
if (m_fontZoom!= 100 || s->contains(QLatin1String(fontZoomKey)))
|
||||
s->setValue(QLatin1String(fontZoomKey), m_fontZoom);
|
||||
|
||||
if (m_lineSpacing != 100 || s->contains(QLatin1String(lineSpacingKey)))
|
||||
s->setValue(QLatin1String(lineSpacingKey), m_lineSpacing);
|
||||
|
||||
if (m_antialias != DEFAULT_ANTIALIAS || s->contains(QLatin1String(antialiasKey)))
|
||||
s->setValue(QLatin1String(antialiasKey), m_antialias);
|
||||
|
||||
@@ -122,8 +116,7 @@ bool FontSettings::fromSettings(const FormatDescriptions &descriptions, const QS
|
||||
|
||||
m_family = s->value(group + QLatin1String(fontFamilyKey), defaultFixedFontFamily()).toString();
|
||||
m_fontSize = s->value(group + QLatin1String(fontSizeKey), m_fontSize).toInt();
|
||||
m_fontZoom = s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt();
|
||||
m_lineSpacing = s->value(group + QLatin1String(lineSpacingKey), m_lineSpacing).toInt();
|
||||
m_fontZoom= s->value(group + QLatin1String(fontZoomKey), m_fontZoom).toInt();
|
||||
m_antialias = s->value(group + QLatin1String(antialiasKey), DEFAULT_ANTIALIAS).toBool();
|
||||
|
||||
if (s->contains(group + QLatin1String(schemeFileNamesKey))) {
|
||||
@@ -143,7 +136,6 @@ bool FontSettings::equals(const FontSettings &f) const
|
||||
return m_family == f.m_family
|
||||
&& m_schemeFileName == f.m_schemeFileName
|
||||
&& m_fontSize == f.m_fontSize
|
||||
&& m_lineSpacing == f.m_lineSpacing
|
||||
&& m_fontZoom == f.m_fontZoom
|
||||
&& m_antialias == f.m_antialias
|
||||
&& m_scheme == f.m_scheme;
|
||||
@@ -280,13 +272,6 @@ void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
|
||||
};
|
||||
}
|
||||
|
||||
void FontSettings::clearCaches()
|
||||
{
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
m_lineSpacingCache = 0;
|
||||
}
|
||||
|
||||
QTextCharFormat FontSettings::toTextCharFormat(TextStyles textStyles) const
|
||||
{
|
||||
auto textCharFormatIterator = m_textCharFormatCache.find(textStyles);
|
||||
@@ -327,7 +312,8 @@ QString FontSettings::family() const
|
||||
void FontSettings::setFamily(const QString &family)
|
||||
{
|
||||
m_family = family;
|
||||
clearCaches();
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +327,8 @@ int FontSettings::fontSize() const
|
||||
void FontSettings::setFontSize(int size)
|
||||
{
|
||||
m_fontSize = size;
|
||||
clearCaches();
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,28 +344,6 @@ void FontSettings::setFontZoom(int zoom)
|
||||
m_fontZoom = zoom;
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
m_lineSpacingCache = 0;
|
||||
}
|
||||
|
||||
qreal FontSettings::lineSpacing() const
|
||||
{
|
||||
if (qFuzzyIsNull(m_lineSpacingCache)) {
|
||||
auto currentFont = font();
|
||||
currentFont.setPointSize(m_fontSize * m_fontZoom / 100);
|
||||
m_lineSpacingCache = QFontMetricsF(currentFont).lineSpacing() / 100 * m_lineSpacing;
|
||||
}
|
||||
return m_lineSpacingCache;
|
||||
}
|
||||
|
||||
int FontSettings::relativeLineSpacing() const
|
||||
{
|
||||
return m_lineSpacing;
|
||||
}
|
||||
|
||||
void FontSettings::setRelativeLineSpacing(int relativeLineSpacing)
|
||||
{
|
||||
m_lineSpacing = relativeLineSpacing;
|
||||
m_lineSpacingCache = 0;
|
||||
}
|
||||
|
||||
QFont FontSettings::font() const
|
||||
@@ -399,7 +364,8 @@ bool FontSettings::antialias() const
|
||||
void FontSettings::setAntialias(bool antialias)
|
||||
{
|
||||
m_antialias = antialias;
|
||||
clearCaches();
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,7 +402,8 @@ void FontSettings::setColorSchemeFileName(const QString &fileName)
|
||||
bool FontSettings::loadColorScheme(const QString &fileName,
|
||||
const FormatDescriptions &descriptions)
|
||||
{
|
||||
clearCaches();
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
bool loaded = true;
|
||||
m_schemeFileName = fileName;
|
||||
|
||||
@@ -492,7 +459,8 @@ const ColorScheme &FontSettings::colorScheme() const
|
||||
void FontSettings::setColorScheme(const ColorScheme &scheme)
|
||||
{
|
||||
m_scheme = scheme;
|
||||
clearCaches();
|
||||
m_formatCache.clear();
|
||||
m_textCharFormatCache.clear();
|
||||
}
|
||||
|
||||
static QString defaultFontFamily()
|
||||
|
@@ -75,10 +75,6 @@ public:
|
||||
int fontZoom() const;
|
||||
void setFontZoom(int zoom);
|
||||
|
||||
qreal lineSpacing() const;
|
||||
int relativeLineSpacing() const;
|
||||
void setRelativeLineSpacing(int relativeLineSpacing);
|
||||
|
||||
QFont font() const;
|
||||
|
||||
bool antialias() const;
|
||||
@@ -104,19 +100,16 @@ public:
|
||||
|
||||
private:
|
||||
void addMixinStyle(QTextCharFormat &textCharFormat, const MixinTextStyles &mixinStyles) const;
|
||||
void clearCaches();
|
||||
|
||||
private:
|
||||
QString m_family;
|
||||
QString m_schemeFileName;
|
||||
int m_fontSize;
|
||||
int m_fontZoom;
|
||||
int m_lineSpacing;
|
||||
bool m_antialias;
|
||||
ColorScheme m_scheme;
|
||||
mutable QHash<TextStyle, QTextCharFormat> m_formatCache;
|
||||
mutable QHash<TextStyles, QTextCharFormat> m_textCharFormatCache;
|
||||
mutable qreal m_lineSpacingCache;
|
||||
};
|
||||
|
||||
inline bool operator==(const FontSettings &f1, const FontSettings &f2) { return f1.equals(f2); }
|
||||
|
@@ -31,9 +31,9 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/theme/theme.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFontDatabase>
|
||||
@@ -128,11 +128,6 @@ public:
|
||||
|
||||
m_ui.antialias->setChecked(m_value.antialias());
|
||||
m_ui.zoomSpinBox->setValue(m_value.fontZoom());
|
||||
m_ui.lineSpacingSpinBox->setValue(m_value.relativeLineSpacing());
|
||||
m_ui.lineSpacingWarningLabel->setPixmap(Utils::Icons::WARNING.pixmap());
|
||||
m_ui.lineSpacingWarningLabel->setToolTip(tr("A line spacing less than 100% can result in "
|
||||
"overlapping and misaligned graphics."));
|
||||
m_ui.lineSpacingWarningLabel->setVisible(m_value.relativeLineSpacing() < 100);
|
||||
|
||||
m_ui.schemeEdit->setFormatDescriptions(fd);
|
||||
m_ui.schemeEdit->setBaseFont(m_value.font());
|
||||
@@ -148,8 +143,6 @@ public:
|
||||
this, &FontSettingsPageWidget::fontSizeSelected);
|
||||
connect(m_ui.zoomSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, &FontSettingsPageWidget::fontZoomChanged);
|
||||
connect(m_ui.lineSpacingSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, &FontSettingsPageWidget::lineSpacingChanged);
|
||||
connect(m_ui.antialias, &QCheckBox::toggled,
|
||||
this, &FontSettingsPageWidget::antialiasChanged);
|
||||
connect(m_ui.schemeComboBox,
|
||||
@@ -173,7 +166,6 @@ public:
|
||||
void fontSelected(const QFont &font);
|
||||
void fontSizeSelected(int index);
|
||||
void fontZoomChanged();
|
||||
void lineSpacingChanged(const int &value);
|
||||
void antialiasChanged();
|
||||
void colorSchemeSelected(int index);
|
||||
void openCopyColorSchemeDialog();
|
||||
@@ -425,12 +417,6 @@ void FontSettingsPageWidget::fontZoomChanged()
|
||||
m_value.setFontZoom(m_ui.zoomSpinBox->value());
|
||||
}
|
||||
|
||||
void FontSettingsPageWidget::lineSpacingChanged(const int &value)
|
||||
{
|
||||
m_value.setRelativeLineSpacing(value);
|
||||
m_ui.lineSpacingWarningLabel->setVisible(value < 100);
|
||||
}
|
||||
|
||||
void FontSettingsPageWidget::antialiasChanged()
|
||||
{
|
||||
m_value.setAntialias(m_ui.antialias->isChecked());
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>752</width>
|
||||
<width>639</width>
|
||||
<height>306</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -17,23 +17,40 @@
|
||||
<string>Font</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="5">
|
||||
<widget class="QComboBox" name="sizeComboBox">
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="sizeLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QFontComboBox" name="fontComboBox"/>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLabel" name="zoomLabel">
|
||||
<property name="text">
|
||||
<string>Zoom:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="familyLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Family:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -49,7 +66,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="14">
|
||||
<item row="0" column="9">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -62,19 +79,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="sizeLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="antialias">
|
||||
<property name="text">
|
||||
@@ -82,32 +86,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QSpinBox" name="zoomSpinBox">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>3000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QLabel" name="zoomLabel">
|
||||
<property name="text">
|
||||
<string>Zoom:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
@@ -124,61 +102,41 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="12">
|
||||
<widget class="QSpinBox" name="lineSpacingSpinBox">
|
||||
<item row="0" column="8">
|
||||
<widget class="QSpinBox" name="zoomSpinBox">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>3000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="familyLabel">
|
||||
<item row="0" column="1">
|
||||
<widget class="QFontComboBox" name="fontComboBox"/>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QComboBox" name="sizeComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Family:</string>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="11">
|
||||
<widget class="QLabel" name="lineSpacingLabel">
|
||||
<property name="text">
|
||||
<string>Line spacing:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="10">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="13">
|
||||
<widget class="QLabel" name="lineSpacingWarningLabel"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -242,7 +200,6 @@
|
||||
<tabstop>fontComboBox</tabstop>
|
||||
<tabstop>sizeComboBox</tabstop>
|
||||
<tabstop>zoomSpinBox</tabstop>
|
||||
<tabstop>lineSpacingSpinBox</tabstop>
|
||||
<tabstop>antialias</tabstop>
|
||||
<tabstop>schemeComboBox</tabstop>
|
||||
<tabstop>copyButton</tabstop>
|
||||
|
@@ -24,13 +24,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "textdocumentlayout.h"
|
||||
|
||||
#include "fontsettings.h"
|
||||
#include "textdocument.h"
|
||||
#include "texteditorsettings.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace TextEditor {
|
||||
@@ -630,9 +625,6 @@ void TextDocumentLayout::updateMarksBlock(const QTextBlock &block)
|
||||
QRectF TextDocumentLayout::blockBoundingRect(const QTextBlock &block) const
|
||||
{
|
||||
QRectF boundingRect = QPlainTextDocumentLayout::blockBoundingRect(block);
|
||||
if (boundingRect.isNull())
|
||||
return boundingRect;
|
||||
boundingRect.setHeight(TextEditorSettings::fontSettings().lineSpacing());
|
||||
if (TextBlockUserData *userData = textUserData(block))
|
||||
boundingRect.adjust(0, 0, 0, userData->additionalAnnotationHeight());
|
||||
return boundingRect;
|
||||
|
@@ -1107,9 +1107,9 @@ void TextEditorWidget::print(QPrinter *printer)
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
static int foldBoxWidth()
|
||||
static int foldBoxWidth(const QFontMetrics &fm)
|
||||
{
|
||||
const int lineSpacing = TextEditorSettings::fontSettings().lineSpacing();
|
||||
const int lineSpacing = fm.lineSpacing();
|
||||
return lineSpacing + lineSpacing % 2 + 1;
|
||||
}
|
||||
|
||||
@@ -3606,9 +3606,9 @@ QRect TextEditorWidgetPrivate::foldBox()
|
||||
QRectF br = q->blockBoundingGeometry(begin).translated(q->contentOffset());
|
||||
QRectF er = q->blockBoundingGeometry(end).translated(q->contentOffset());
|
||||
|
||||
return QRect(m_extraArea->width() - foldBoxWidth(),
|
||||
return QRect(m_extraArea->width() - foldBoxWidth(q->fontMetrics()),
|
||||
int(br.top()),
|
||||
foldBoxWidth(),
|
||||
foldBoxWidth(q->fontMetrics()),
|
||||
int(er.bottom() - br.top()));
|
||||
}
|
||||
|
||||
@@ -4089,9 +4089,7 @@ bool TextEditorWidgetPrivate::updateAnnotationBounds(TextBlockUserData *blockUse
|
||||
{
|
||||
const bool additionalHeightNeeded = annotationsVisible
|
||||
&& m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines;
|
||||
const int additionalHeight = additionalHeightNeeded
|
||||
? TextEditorSettings::fontSettings().lineSpacing()
|
||||
: 0;
|
||||
const int additionalHeight = additionalHeightNeeded ? q->fontMetrics().lineSpacing() : 0;
|
||||
if (blockUserData->additionalAnnotationHeight() == additionalHeight)
|
||||
return false;
|
||||
blockUserData->setAdditionalAnnotationHeight(additionalHeight);
|
||||
@@ -4132,7 +4130,7 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data,
|
||||
return mark1->priority() > mark2->priority();
|
||||
});
|
||||
|
||||
const qreal itemOffset = blockData.boundingRect.height();
|
||||
const qreal itemOffset = q->fontMetrics().lineSpacing();
|
||||
const qreal initialOffset = m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines ? itemOffset / 2 : itemOffset * 2;
|
||||
const qreal minimalContentWidth = q->fontMetrics().horizontalAdvance('X')
|
||||
* m_displaySettings.m_minimalAnnotationContent;
|
||||
@@ -4177,6 +4175,13 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data,
|
||||
q->viewport()->update(updateRect);
|
||||
}
|
||||
|
||||
QColor blendRightMarginColor(const FontSettings &settings, bool areaColor)
|
||||
{
|
||||
const QColor baseColor = settings.toTextCharFormat(C_TEXT).background().color();
|
||||
const QColor col = (baseColor.value() > 128) ? Qt::black : Qt::white;
|
||||
return blendColors(baseColor, col, areaColor ? 16 : 32);
|
||||
}
|
||||
|
||||
void TextEditorWidgetPrivate::paintRightMarginArea(PaintEventData &data, QPainter &painter) const
|
||||
{
|
||||
if (m_visibleWrapColumn <= 0)
|
||||
@@ -4191,7 +4196,7 @@ void TextEditorWidgetPrivate::paintRightMarginArea(PaintEventData &data, QPainte
|
||||
data.eventRect.top(),
|
||||
data.viewportRect.width() - data.rightMargin,
|
||||
data.eventRect.height());
|
||||
painter.fillRect(behindMargin, data.ifdefedOutFormat.background());
|
||||
painter.fillRect(behindMargin, blendRightMarginColor(m_document->fontSettings(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4201,11 +4206,8 @@ void TextEditorWidgetPrivate::paintRightMarginLine(const PaintEventData &data,
|
||||
if (m_visibleWrapColumn <= 0 || data.rightMargin >= data.viewportRect.width())
|
||||
return;
|
||||
|
||||
const QBrush background = data.ifdefedOutFormat.background();
|
||||
const QColor baseColor = m_document->fontSettings().toTextCharFormat(C_TEXT).background().color();
|
||||
const QColor col = (baseColor.value() > 128) ? Qt::black : Qt::white;
|
||||
const QPen pen = painter.pen();
|
||||
painter.setPen(blendColors(background.isOpaque() ? background.color() : baseColor, col, 32));
|
||||
painter.setPen(blendRightMarginColor(m_document->fontSettings(), false));
|
||||
painter.drawLine(QPointF(data.rightMargin, data.eventRect.top()),
|
||||
QPointF(data.rightMargin, data.eventRect.bottom()));
|
||||
painter.setPen(pen);
|
||||
@@ -5027,7 +5029,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const
|
||||
int markWidth = 0;
|
||||
|
||||
if (d->m_marksVisible) {
|
||||
markWidth += documentLayout->maxMarkWidthFactor * TextEditorSettings::fontSettings().lineSpacing() + 2;
|
||||
markWidth += documentLayout->maxMarkWidthFactor * fm.lineSpacing() + 2;
|
||||
|
||||
// if (documentLayout->doubleMarkCount)
|
||||
// markWidth += fm.lineSpacing() / 3;
|
||||
@@ -5042,7 +5044,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const
|
||||
space += 4;
|
||||
|
||||
if (d->m_codeFoldingVisible)
|
||||
space += foldBoxWidth();
|
||||
space += foldBoxWidth(fm);
|
||||
|
||||
if (viewportMargins() != QMargins{isLeftToRight() ? space : 0, 0, isLeftToRight() ? 0 : space, 0})
|
||||
d->slotUpdateExtraAreaWidth(space);
|
||||
@@ -5068,9 +5070,9 @@ struct Internal::ExtraAreaPaintEventData
|
||||
, selectionStart(editor->textCursor().selectionStart())
|
||||
, selectionEnd(editor->textCursor().selectionEnd())
|
||||
, fontMetrics(d->m_extraArea->font())
|
||||
, lineSpacing(TextEditorSettings::fontSettings().lineSpacing())
|
||||
, lineSpacing(fontMetrics.lineSpacing())
|
||||
, markWidth(d->m_marksVisible ? lineSpacing : 0)
|
||||
, collapseColumnWidth(d->m_codeFoldingVisible ? foldBoxWidth() : 0)
|
||||
, collapseColumnWidth(d->m_codeFoldingVisible ? foldBoxWidth(fontMetrics) : 0)
|
||||
, extraAreaWidth(d->m_extraArea->width() - collapseColumnWidth)
|
||||
, currentLineNumberFormat(
|
||||
editor->textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER))
|
||||
@@ -5194,7 +5196,7 @@ void TextEditorWidgetPrivate::paintCodeFolding(QPainter &painter,
|
||||
bool hovered = blockNumber >= extraAreaHighlightFoldBlockNumber
|
||||
&& blockNumber <= extraAreaHighlightFoldEndBlockNumber;
|
||||
|
||||
int boxWidth = foldBoxWidth();
|
||||
int boxWidth = foldBoxWidth(data.fontMetrics);
|
||||
if (hovered) {
|
||||
int itop = qRound(blockBoundingRect.top());
|
||||
int ibottom = qRound(blockBoundingRect.bottom());
|
||||
@@ -5567,10 +5569,8 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
if (cursor.positionInBlock() == cursor.block().length()-1)
|
||||
column += (e->pos().x() - cursorRect().center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
||||
int block = cursor.blockNumber();
|
||||
if (block == blockCount() - 1) {
|
||||
block += (e->pos().y() - cursorRect().center().y())
|
||||
/ TextEditorSettings::fontSettings().lineSpacing();
|
||||
}
|
||||
if (block == blockCount() - 1)
|
||||
block += (e->pos().y() - cursorRect().center().y()) / QFontMetricsF(font()).lineSpacing();
|
||||
d->enableBlockSelection(block, column, block, column);
|
||||
}
|
||||
} else {
|
||||
@@ -5620,11 +5620,8 @@ void TextEditorWidget::mousePressEvent(QMouseEvent *e)
|
||||
if (cursor.positionInBlock() == cursor.block().length()-1)
|
||||
column += (e->pos().x() - cursorRect(cursor).center().x()) / QFontMetricsF(font()).horizontalAdvance(QLatin1Char(' '));
|
||||
int block = cursor.blockNumber();
|
||||
if (block == blockCount() - 1) {
|
||||
block += (e->pos().y() - cursorRect(cursor).center().y())
|
||||
/ TextEditorSettings::fontSettings().lineSpacing();
|
||||
}
|
||||
|
||||
if (block == blockCount() - 1)
|
||||
block += (e->pos().y() - cursorRect(cursor).center().y()) / QFontMetricsF(font()).lineSpacing();
|
||||
if (d->m_inBlockSelectionMode) {
|
||||
d->m_blockSelection.positionBlock = block;
|
||||
d->m_blockSelection.positionColumn = column;
|
||||
@@ -5798,7 +5795,7 @@ void TextEditorWidget::updateFoldingHighlight(const QPoint &pos)
|
||||
const int highlightBlockNumber = d->extraAreaHighlightFoldedBlockNumber;
|
||||
d->extraAreaHighlightFoldedBlockNumber = -1;
|
||||
|
||||
if (pos.x() > extraArea()->width() - foldBoxWidth()) {
|
||||
if (pos.x() > extraArea()->width() - foldBoxWidth(fontMetrics())) {
|
||||
d->extraAreaHighlightFoldedBlockNumber = cursor.blockNumber();
|
||||
} else if (d->m_displaySettings.m_highlightBlocks) {
|
||||
QTextCursor cursor = textCursor();
|
||||
@@ -5841,7 +5838,7 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
||||
int dist = (e->pos() - d->m_markDragStart).manhattanLength();
|
||||
if (dist > QApplication::startDragDistance()) {
|
||||
d->m_markDragging = true;
|
||||
const int height = TextEditorSettings::fontSettings().lineSpacing() - 1;
|
||||
const int height = fontMetrics().lineSpacing() - 1;
|
||||
const int width = int(.5 + height * d->m_dragMark->widthFactor());
|
||||
d->m_markDragCursor = QCursor(d->m_dragMark->icon().pixmap({height, width}));
|
||||
d->m_dragMark->setVisible(false);
|
||||
@@ -5859,7 +5856,7 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
||||
|
||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) {
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
int boxWidth = foldBoxWidth();
|
||||
int boxWidth = foldBoxWidth(fontMetrics());
|
||||
if (d->m_codeFoldingVisible && e->pos().x() > extraArea()->width() - boxWidth) {
|
||||
if (!cursor.block().next().isVisible()) {
|
||||
d->toggleBlockVisible(cursor.block());
|
||||
@@ -6386,7 +6383,7 @@ void TextEditorWidgetPrivate::adjustScrollBarRanges()
|
||||
{
|
||||
if (!m_highlightScrollBarController)
|
||||
return;
|
||||
const double lineSpacing = TextEditorSettings::fontSettings().lineSpacing();
|
||||
const double lineSpacing = QFontMetricsF(q->font()).lineSpacing();
|
||||
if (lineSpacing == 0)
|
||||
return;
|
||||
|
||||
|
Submodule src/shared/qbs updated: 0d5fdcee74...d870a7a453
@@ -29,6 +29,7 @@
|
||||
#include <sourcelocationscontainer.h>
|
||||
#include <sourcerangescontainer.h>
|
||||
|
||||
#include <clang/Basic/FileManager.h>
|
||||
#include <clang/Basic/SourceManager.h>
|
||||
#include <clang/Lex/Lexer.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <utils/linecolumn.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <clang/Basic/FileManager.h>
|
||||
#include <clang/Basic/SourceLocation.h>
|
||||
#include <clang/Basic/SourceManager.h>
|
||||
#include <clang/Index/USRGeneration.h>
|
||||
|
@@ -137,6 +137,14 @@ extend_qtc_executable(qml2puppet
|
||||
icongizmoimageprovider.cpp icongizmoimageprovider.h
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 6.0.0
|
||||
|
||||
SOURCES_PREFIX "${SRCDIR}/qml2puppet/editor3d/qt5compat"
|
||||
SOURCES
|
||||
qquick3darealight.cpp qquick3darealight_p.h
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
SOURCES_PREFIX "${SRCDIR}/qml2puppet/iconrenderer"
|
||||
SOURCES
|
||||
|
@@ -19,6 +19,8 @@ QtcTool {
|
||||
property bool useQuick3d: Utilities.versionCompare(Qt.core.version, "5.15") >= 0
|
||||
&& Qt["quick3d-private"].present
|
||||
|
||||
property bool useQt5Compat: Utilities.versionCompare(Qt.core.version, "6.0") >= 0
|
||||
|
||||
cpp.defines: {
|
||||
var defines = base.filter(function(d) { return d != "QT_CREATOR"; });
|
||||
if (useQuick3d)
|
||||
@@ -258,6 +260,20 @@ QtcTool {
|
||||
fileTags: product.useQuick3d ? [] : ["unmocable"]
|
||||
overrideTags: false
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "puppet2 Qt 5 compatibility sources"
|
||||
condition: useQt5Compat
|
||||
files: ["editor3d/qt5compat/qquick3darealight.cpp"]
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "puppet2 Qt 5 compatibility headers"
|
||||
condition: useQt5Compat
|
||||
files: ["editor3d/qt5compat/qquick3darealight_p.h"]
|
||||
fileTags: product.useQuick3d ? [] : ["unmocable"]
|
||||
overrideTags: false
|
||||
}
|
||||
}
|
||||
|
||||
Group {
|
||||
|
@@ -22,4 +22,6 @@ add_qtc_plugin(testplugin
|
||||
)
|
||||
|
||||
# The empty string gets removed if I put it above
|
||||
set_target_properties(testplugin PROPERTIES PREFIX "")
|
||||
if (TARGET testplugin)
|
||||
set_target_properties(testplugin PROPERTIES PREFIX "")
|
||||
endif()
|
||||
|
@@ -52,6 +52,7 @@ INCLUDEPATH += $$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/propertyedit
|
||||
INCLUDEPATH += $$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/debugview
|
||||
INCLUDEPATH += $$IDE_SOURCE_TREE/src/plugins/qmldesigner/components/edit3d
|
||||
INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/3rdparty
|
||||
INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/sqlite
|
||||
|
||||
include($$IDE_SOURCE_TREE/src/plugins/qmldesigner/designercore/designercore-lib.pri)
|
||||
|
||||
|
@@ -32,26 +32,26 @@ namespace QmlDesigner {
|
||||
|
||||
TestConnectionManager::TestConnectionManager()
|
||||
{
|
||||
m_connections.emplace_back("Editor", "editormode");
|
||||
connections().emplace_back("Editor", "editormode");
|
||||
}
|
||||
|
||||
void TestConnectionManager::writeCommand(const QVariant &command)
|
||||
{
|
||||
TestConnectionManager::writeCommand(command);
|
||||
ConnectionManager::writeCommand(command);
|
||||
|
||||
m_writeCommandCounter++;
|
||||
writeCommandCounter()++;
|
||||
|
||||
static int synchronizeId = 0;
|
||||
synchronizeId++;
|
||||
SynchronizeCommand synchronizeCommand(synchronizeId);
|
||||
|
||||
QLocalSocket *socket = m_connections.front().socket.get();
|
||||
QLocalSocket *socket = connections().front().socket.get();
|
||||
|
||||
writeCommandToIODevice(QVariant::fromValue(synchronizeCommand), socket, m_writeCommandCounter);
|
||||
m_writeCommandCounter++;
|
||||
writeCommandToIODevice(QVariant::fromValue(synchronizeCommand), socket, writeCommandCounter());
|
||||
writeCommandCounter()++;
|
||||
|
||||
while (socket->waitForReadyRead(100)) {
|
||||
readDataStream(m_connections.front());
|
||||
readDataStream(connections().front());
|
||||
if (m_synchronizeId == synchronizeId)
|
||||
return;
|
||||
}
|
||||
|
@@ -239,7 +239,7 @@ def main():
|
||||
clickButton(waitForObject(":*Qt Creator.Clear_QToolButton"))
|
||||
continue
|
||||
test.compare(filenameCombo.currentText, "%s: %s" % (protocol, pasteId), "Verify title of editor")
|
||||
if protocol in (NAME_PBCOM, NAME_DPCOM) and pastedText.endswith("\n"):
|
||||
if protocol in (NAME_DPCOM) and pastedText.endswith("\n"):
|
||||
pastedText = pastedText[:-1]
|
||||
test.compare(editor.plainText, pastedText, "Verify that pasted and fetched texts are the same")
|
||||
|
||||
|
@@ -40,7 +40,6 @@ add_qtc_test(unittest GTEST
|
||||
clientserveroutsideprocess-test.cpp
|
||||
commandlinebuilder-test.cpp
|
||||
compare-operators.h
|
||||
compilationdatabaseutils-test.cpp
|
||||
compileroptionsbuilder-test.cpp
|
||||
conditionally-disabled-tests.h
|
||||
cppprojectfilecategorizer-test.cpp
|
||||
@@ -319,7 +318,7 @@ extend_qtc_test(unittest
|
||||
)
|
||||
|
||||
extend_qtc_test(unittest
|
||||
CONDITION TARGET clangFormat
|
||||
CONDITION TARGET ClangFormat
|
||||
DEPENDS clangFormat
|
||||
SOURCES
|
||||
clangformat-test.cpp
|
||||
@@ -421,9 +420,8 @@ extend_qtc_test_with_target_sources(CPlusPlus DEFINES CPLUSPLUS_BUILD_STATIC_LIB
|
||||
extend_qtc_test_with_target_sources(3rd_cplusplus DEFINES CPLUSPLUS_BUILD_LIB)
|
||||
extend_qtc_test_with_target_sources(ClangSupport DEFINES CLANGSUPPORT_BUILD_LIB)
|
||||
|
||||
get_target_property(ClangCodeModelSourcesDir ClangCodeModel SOURCES_DIR)
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX "${ClangCodeModelSourcesDir}"
|
||||
SOURCES_PREFIX_FROM_TARGET ClangCodeModel
|
||||
SOURCES
|
||||
clangactivationsequencecontextprocessor.cpp clangactivationsequencecontextprocessor.h
|
||||
clangactivationsequenceprocessor.cpp clangactivationsequenceprocessor.h
|
||||
@@ -436,16 +434,20 @@ extend_qtc_test(unittest
|
||||
clangisdiagnosticrelatedtolocation.h
|
||||
)
|
||||
|
||||
get_target_property(CompilationDatabasePMSourcesDir CompilationDatabaseProjectManager SOURCES_DIR)
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX "${CompilationDatabasePMSourcesDir}"
|
||||
SOURCES_PREFIX_FROM_TARGET CompilationDatabaseProjectManager
|
||||
SOURCES
|
||||
compilationdatabaseutils.cpp compilationdatabaseutils.h
|
||||
)
|
||||
|
||||
get_target_property(CoreSourcesDir Core SOURCES_DIR)
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX "${CoreSourcesDir}"
|
||||
CONDITION TARGET CompilationDatabaseProjectManager
|
||||
SOURCES
|
||||
compilationdatabaseutils-test.cpp
|
||||
)
|
||||
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX_FROM_TARGET Core
|
||||
DEFINES CORE_STATIC_LIBRARY
|
||||
SOURCES
|
||||
coreicons.cpp coreicons.h
|
||||
@@ -453,9 +455,8 @@ extend_qtc_test(unittest
|
||||
locator/ilocatorfilter.cpp locator/ilocatorfilter.h
|
||||
)
|
||||
|
||||
get_target_property(CppToolsSourcesDir CppTools SOURCES_DIR)
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX "${CppToolsSourcesDir}"
|
||||
SOURCES_PREFIX_FROM_TARGET CppTools
|
||||
DEFINES CPPTOOLS_STATIC_LIBRARY
|
||||
SOURCES
|
||||
cppprojectfile.cpp cppprojectfile.h
|
||||
@@ -469,9 +470,8 @@ extend_qtc_test(unittest
|
||||
headerpathfilter.cpp headerpathfilter.h
|
||||
)
|
||||
|
||||
get_target_property(ProjectExplorerSourcesDir ProjectExplorer SOURCES_DIR)
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX "${ProjectExplorerSourcesDir}"
|
||||
SOURCES_PREFIX_FROM_TARGET ProjectExplorer
|
||||
DEFINES PROJECTEXPLORER_STATIC_LIBRARY
|
||||
SOURCES
|
||||
projectmacro.cpp projectmacro.h
|
||||
@@ -517,9 +517,8 @@ extend_qtc_test(unittest
|
||||
progressmanagerinterface.h
|
||||
)
|
||||
|
||||
get_target_property(ClangFormatSourcesDir ClangFormat SOURCES_DIR)
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX "${ClangFormatSourcesDir}"
|
||||
SOURCES_PREFIX_FROM_TARGET ClangFormat
|
||||
DEFINES CLANGPCHMANAGER_STATIC_LIB
|
||||
SOURCES
|
||||
clangformatconstants.h
|
||||
|
@@ -333,19 +333,6 @@ Project {
|
||||
"unittests-main.cpp",
|
||||
"usedmacrofilter-test.cpp",
|
||||
"utf8-test.cpp",
|
||||
"imagecache-test.cpp",
|
||||
"imagecachegenerator-test.cpp",
|
||||
"imagecachestorage-test.cpp",
|
||||
"sqlitedatabasemock.h",
|
||||
"sqlitereadstatementmock.h",
|
||||
"sqlitestatementmock.h",
|
||||
"sqlitetransactionbackendmock.h",
|
||||
"sqlitewritestatementmock.h",
|
||||
"notification.h",
|
||||
"mocktimestampprovider.h",
|
||||
"imagecachecollectormock.h",
|
||||
"mockimagecachegenerator.h",
|
||||
"mockimagecachestorage.h",
|
||||
]
|
||||
|
||||
Group {
|
||||
|
Reference in New Issue
Block a user