1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/*
quickinspector.h
This file is part of GammaRay, the Qt application inspection and manipulation tool.
SPDX-FileCopyrightText: 2014 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Volker Krause <volker.krause@kdab.com>
SPDX-License-Identifier: GPL-2.0-or-later
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#ifndef GAMMARAY_QUICKINSPECTOR_QUICKINSPECTOR_H
#define GAMMARAY_QUICKINSPECTOR_QUICKINSPECTOR_H
#include "quickinspectorinterface.h"
#include <common/remoteviewinterface.h>
#include <core/toolfactory.h>
#include <QQuickWindow>
#include <QImage>
#include <QMutex>
#include <memory>
QT_BEGIN_NAMESPACE
class QQuickShaderEffectSource;
class QAbstractItemModel;
class QItemSelection;
class QItemSelectionModel;
class QSGNode;
// class QSGBasicGeometryNode;
// class QSGGeometryNode;
// class QSGClipNode;
// class QSGTransformNode;
// class QSGRootNode;
// class QSGOpacityNode;
QT_END_NAMESPACE
namespace GammaRay {
class PropertyController;
class AbstractScreenGrabber;
class GrabbedFrame;
struct QuickDecorationsSettings;
class QuickItemModel;
class QuickSceneGraphModel;
class RemoteViewServer;
class ObjectId;
class PaintAnalyzer;
using ObjectIds = QVector<ObjectId>;
class RenderModeRequest : public QObject
{
Q_OBJECT
public:
explicit RenderModeRequest(QObject *parent = nullptr);
~RenderModeRequest() override;
void applyOrDelay(QQuickWindow *toWindow, QuickInspectorInterface::RenderMode customRenderMode);
signals:
void aboutToCleanSceneGraph();
void sceneGraphCleanedUp();
void finished();
private slots:
void apply();
void preFinished();
private:
static QMutex mutex;
QuickInspectorInterface::RenderMode mode;
QMetaObject::Connection connection;
QPointer<QQuickWindow> window;
};
class QuickInspector : public QuickInspectorInterface
{
Q_OBJECT
Q_INTERFACES(GammaRay::QuickInspectorInterface)
public:
explicit QuickInspector(Probe *probe, QObject *parent = nullptr);
~QuickInspector() override;
signals:
void elementsAtReceived(const GammaRay::ObjectIds &ids, int bestCandidate);
public slots:
void selectWindow(int index) override;
void setCustomRenderMode(GammaRay::QuickInspectorInterface::RenderMode customRenderMode)
override;
void checkFeatures() override;
void setOverlaySettings(const GammaRay::QuickDecorationsSettings &settings) override;
void checkOverlaySettings() override;
void requestElementsAt(const QPoint &pos, GammaRay::RemoteViewInterface::RequestMode mode);
void pickElementId(const GammaRay::ObjectId &id);
void sendRenderedScene(const GammaRay::GrabbedFrame &grabbedFrame);
void analyzePainting() override;
void checkSlowMode() override;
void setSlowMode(bool slow) override;
protected:
bool eventFilter(QObject *receiver, QEvent *event) override;
private slots:
void slotGrabWindow();
void itemSelectionChanged(const QItemSelection &selection);
void sgSelectionChanged(const QItemSelection &selection);
void sgNodeDeleted(QSGNode *node);
void qObjectSelected(QObject *object);
void nonQObjectSelected(void *object, const QString &typeName);
void objectCreated(QObject *object);
void recreateOverlay();
void aboutToCleanSceneGraph();
void sceneGraphCleanedUp();
private:
void selectWindow(QQuickWindow *window);
void selectItem(QQuickItem *item);
void selectSGNode(QSGNode *node);
static void registerMetaTypes();
static void registerVariantHandlers();
static void registerPCExtensions();
QString findSGNodeType(QSGNode *node) const;
static void scanForProblems();
QRectF combinedChildrenRect(QQuickItem *object) const;
GammaRay::ObjectIds recursiveItemsAt(QQuickItem *parent, const QPointF &pos,
GammaRay::RemoteViewInterface::RequestMode mode,
int &bestCandidate, bool parentIsGoodCandidate = true) const;
Probe *m_probe;
std::unique_ptr<AbstractScreenGrabber> m_overlay;
QPointer<QQuickWindow> m_window;
QPointer<QQuickItem> m_currentItem;
QSGNode *m_currentSgNode;
QAbstractItemModel *m_windowModel;
QuickItemModel *m_itemModel;
QItemSelectionModel *m_itemSelectionModel;
QuickSceneGraphModel *m_sgModel;
QItemSelectionModel *m_sgSelectionModel;
PropertyController *m_itemPropertyController;
PropertyController *m_sgPropertyController;
RemoteViewServer *m_remoteView;
RenderModeRequest *m_pendingRenderMode;
QuickInspectorInterface::RenderMode m_renderMode;
PaintAnalyzer *m_paintAnalyzer;
bool m_slowDownEnabled;
};
class QuickInspectorFactory : public QObject,
public StandardToolFactory<QQuickWindow, QuickInspector>
{
Q_OBJECT
Q_INTERFACES(GammaRay::ToolFactory)
Q_PLUGIN_METADATA(IID "com.kdab.GammaRay.ToolFactory" FILE "gammaray_quickinspector.json")
public:
explicit QuickInspectorFactory(QObject *parent = nullptr)
: QObject(parent)
{
}
};
}
#endif
|