on xenial help sign in
added missing files
e3b4252Michael Zanetti
src/DebuggingController.cppnew file+69
@@ -0,0 +1,69 @@
1+/*
2+ * Copyright (C) 2016 - Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU Lesser General Public License, as
6+ * published by the Free Software Foundation; either version 2.1 or 3.0
7+ * of the License.
8+ *
9+ * This program is distributed in the hope that it will be useful, but
10+ * WITHOUT ANY WARRANTY; without even the implied warranties of
11+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12+ * PURPOSE. See the applicable version of the GNU Lesser General Public
13+ * License for more details.
14+ *
15+ * You should have received a copy of both the GNU Lesser General Public
16+ * License along with this program. If not, see <http://www.gnu.org/licenses/>
17+ */
18+
19+#include "DebuggingController.h"
20+
21+#include <QGuiApplication>
22+#include <QWindow>
23+#include <private/qquickwindow_p.h>
24+#include <private/qabstractanimationjob_p.h>
25+#include <private/qquickitem_p.h>
26+#include <private/qsgrenderer_p.h>
27+
28+DebuggingController::DebuggingController(QObject *parent):
29+ UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent)
30+{
31+}
32+
33+void DebuggingController::SetSceneGraphVisualizer(const QString &visualizer)
34+{
35+ Q_FOREACH (QWindow *window, QGuiApplication::allWindows()) {
36+ QQuickWindow* qquickWindow = qobject_cast<QQuickWindow*>(window);
37+ if (qquickWindow) {
38+ QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(qquickWindow);
39+ winPriv->customRenderMode = visualizer.toLatin1();
40+ qquickWindow->update();
41+
42+#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
43+ // Qt does some performance optimizations that break custom render modes.
44+ // Thus the optimizations are only applied if there is no custom render mode set.
45+ // So we need to make the scenegraph recheck whether a custom render mode is set.
46+ // We do this by simply recreating the renderer.
47+
48+ QQuickItemPrivate *contentPriv = QQuickItemPrivate::get(qquickWindow->contentItem());
49+ QSGNode *rootNode = contentPriv->itemNode();
50+ while (rootNode->parent())
51+ rootNode = rootNode->parent();
52+
53+ delete winPriv->renderer;
54+ winPriv->renderer = winPriv->context->createRenderer();
55+ winPriv->renderer->setRootNode(static_cast<QSGRootNode *>(rootNode));
56+#endif
57+ }
58+ }
59+}
60+
61+void DebuggingController::SetSlowAnimations(bool slowAnimations)
62+{
63+ QUnifiedTimer::instance()->setSlowModeEnabled(slowAnimations);
64+}
65+
66+void DebuggingController::SetLoggingFilterRules(const QString &filterRules)
67+{
68+ QLoggingCategory::setFilterRules(filterRules);
69+}
src/DebuggingController.hnew file+54
@@ -0,0 +1,54 @@
1+/*
2+ * Copyright (C) 2016 - Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU Lesser General Public License, as
6+ * published by the Free Software Foundation; either version 2.1 or 3.0
7+ * of the License.
8+ *
9+ * This program is distributed in the hope that it will be useful, but
10+ * WITHOUT ANY WARRANTY; without even the implied warranties of
11+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12+ * PURPOSE. See the applicable version of the GNU Lesser General Public
13+ * License for more details.
14+ *
15+ * You should have received a copy of both the GNU Lesser General Public
16+ * License along with this program. If not, see <http://www.gnu.org/licenses/>
17+ */
18+
19+
20+#ifndef DEBUGGINGCONTROLLER_H
21+#define DEBUGGINGCONTROLLER_H
22+
23+#include <QQmlEngine>
24+#include <QQmlExtensionPlugin>
25+
26+#include "unitydbusobject.h"
27+
28+class DebuggingController: public UnityDBusObject
29+{
30+ Q_OBJECT
31+ Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity8.Debugging")
32+
33+public:
34+ DebuggingController(QObject *parent = nullptr);
35+ ~DebuggingController() = default;
36+
37+public Q_SLOTS:
38+ /**
39+ * Set the QSG_VISUALIZE mode. This follows the vlues supported by Qt in
40+ * http://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph-renderer.html
41+ */
42+ Q_SCRIPTABLE void SetSceneGraphVisualizer(const QString &visualizer);
43+
44+ /**
45+ * Slow down animations for better inspection.
46+ */
47+ Q_SCRIPTABLE void SetSlowAnimations(bool slowAnimations);
48+
49+ /**
50+ * Set the QLoggingCategory filter rules.
51+ */
52+ Q_SCRIPTABLE void SetLoggingFilterRules(const QString &filterRules);
53+};
54+#endif // DEBUGGINGCONTROLLER_H