Merge lp:~nick-dedekind/unity8/console-log into lp:unity8

Proposed by Nick Dedekind
Status: Work in progress
Proposed branch: lp:~nick-dedekind/unity8/console-log
Merge into: lp:unity8
Prerequisite: lp:~mzanetti/unity8/onthefly-debugging
Diff against target: 586 lines (+454/-5)
12 files modified
plugins/Unity/CMakeLists.txt (+1/-0)
plugins/Unity/Debug/CMakeLists.txt (+30/-0)
plugins/Unity/Debug/consolelog.cpp (+221/-0)
plugins/Unity/Debug/consolelog.h (+87/-0)
plugins/Unity/Debug/plugin.cpp (+31/-0)
plugins/Unity/Debug/plugin.h (+32/-0)
plugins/Unity/Debug/qmldir (+3/-0)
qml/Shell.qml (+17/-0)
src/DebuggingController.cpp (+13/-2)
src/DebuggingController.h (+15/-0)
src/ShellApplication.cpp (+2/-1)
tests/uqmlscene/main.cpp (+2/-2)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/console-log
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Unity Team Pending
Review via email: mp+299527@code.launchpad.net

Commit message

Debug tool for printing our the console log to a control.

Description of the change

Debug tool for printing our the console log to a control.

Enable/Disable shell overlay via debug dbus interface:
com.canonical.Unity8/com/canonical/Unity8/Debugging::SetLogOverlay

To post a comment you must log in.
lp:~nick-dedekind/unity8/console-log updated
2537. By Nick Dedekind

added missing files

2538. By Nick Dedekind

fixed comment

2539. By Nick Dedekind

order

2540. By Nick Dedekind

use functional

2541. By Nick Dedekind

use qthread::sleep, close write fd + cleanup

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2537
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1696/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/2243/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2271
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2177
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2177
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2177
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2168/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2168/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1696/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2541
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1697/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/2244/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2272
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2178
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2178
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2178
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2169/console
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2169/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1697/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in tests/uqmlscene/CMakeLists.txt
1 conflicts encountered.

Revision history for this message
Albert Astals Cid (aacid) wrote :

More than a month with merge conflicts -> WiP

Unmerged revisions

2541. By Nick Dedekind

use qthread::sleep, close write fd + cleanup

2540. By Nick Dedekind

use functional

2539. By Nick Dedekind

order

2538. By Nick Dedekind

fixed comment

2537. By Nick Dedekind

added missing files

2536. By Nick Dedekind

connect to debug interface

2535. By Nick Dedekind

pulled parent

2534. By Nick Dedekind

merged fly debugging

2533. By Nick Dedekind

Added Unity.Debug

2532. By Nick Dedekind

added console log

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/CMakeLists.txt'
2--- plugins/Unity/CMakeLists.txt 2015-10-09 12:36:14 +0000
3+++ plugins/Unity/CMakeLists.txt 2016-07-08 11:04:05 +0000
4@@ -1,4 +1,5 @@
5 add_subdirectory(Connectivity)
6+add_subdirectory(Debug)
7 add_subdirectory(Indicators)
8 add_subdirectory(Launcher)
9 add_subdirectory(Session)
10
11=== added directory 'plugins/Unity/Debug'
12=== added file 'plugins/Unity/Debug/CMakeLists.txt'
13--- plugins/Unity/Debug/CMakeLists.txt 1970-01-01 00:00:00 +0000
14+++ plugins/Unity/Debug/CMakeLists.txt 2016-07-08 11:04:05 +0000
15@@ -0,0 +1,30 @@
16+include_directories(
17+ ${CMAKE_CURRENT_SOURCE_DIR}
18+ ${CMAKE_CURRENT_BINARY_DIR}
19+)
20+
21+include_directories(
22+ SYSTEM
23+ ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
24+ ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
25+ ${GIO_INCLUDE_DIRS}
26+)
27+
28+set(QMLPLUGIN_SRC
29+ consolelog.cpp
30+ plugin.cpp
31+ )
32+
33+add_library(Debug-qml SHARED
34+ ${QMLPLUGIN_SRC}
35+ )
36+
37+# Because this is an internal support library, we want
38+# to expose all symbols in it. Consider changing this
39+# either to a static library or just using the
40+# files directly in targets.
41+set_target_properties(Debug-qml PROPERTIES COMPILE_FLAGS -fvisibility=default)
42+
43+qt5_use_modules(Debug-qml Qml Quick Concurrent)
44+
45+add_unity8_plugin(Unity.Debug 0.1 Unity/Debug TARGETS Debug-qml)
46
47=== added file 'plugins/Unity/Debug/consolelog.cpp'
48--- plugins/Unity/Debug/consolelog.cpp 1970-01-01 00:00:00 +0000
49+++ plugins/Unity/Debug/consolelog.cpp 2016-07-08 11:04:05 +0000
50@@ -0,0 +1,221 @@
51+/*
52+ * Copyright 2016 Canonical Ltd.
53+ *
54+ * This program is free software; you can redistribute it and/or modify
55+ * it under the terms of the GNU Lesser General Public License as published by
56+ * the Free Software Foundation; version 3.
57+ *
58+ * This program is distributed in the hope that it will be useful,
59+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
60+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61+ * GNU Lesser General Public License for more details.
62+ *
63+ * You should have received a copy of the GNU Lesser General Public License
64+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
65+*/
66+
67+#include "consolelog.h"
68+
69+#include <unistd.h>
70+#include <stdio.h>
71+#include <thread>
72+#include <iostream>
73+#include <sys/ioctl.h>
74+
75+#include <functional>
76+
77+namespace
78+{
79+
80+int wait_fd(std::function<int(void)> fn)
81+{
82+ int ret = -1;
83+ bool fd_blocked = false;
84+ do
85+ {
86+ ret = fn();
87+ fd_blocked = (errno == EINTR || errno == EBUSY);
88+ if (fd_blocked)
89+ QThread::msleep(10);
90+ }
91+ while (ret < 0);
92+ return ret;
93+}
94+
95+#define PIPE_WAIT(val) wait_fd(std::bind(pipe, val))
96+#define DUP_WAIT(fd) wait_fd(std::bind(dup, fd))
97+#define DUP2_WAIT(fd1, fd2) wait_fd(std::bind(dup2, fd1, fd2))
98+#define CLOSE_WAIT(fd) wait_fd(std::bind(close, fd))
99+
100+}
101+
102+LogRedirector::LogRedirector()
103+ : m_ref(0)
104+ , m_stop(false)
105+{
106+ setObjectName("ConsoleLog");
107+
108+ // make stdout & stderr streams unbuffered
109+ // so that we don't need to flush the streams
110+ // before capture and after capture
111+ // (fflush can cause a deadlock if the stream is currently being used)
112+ setvbuf(stdout,NULL,_IONBF,0);
113+ setvbuf(stderr,NULL,_IONBF,0);
114+}
115+
116+void LogRedirector::run()
117+{
118+ PIPE_WAIT(m_pipe);
119+
120+ int oldStdOut = DUP_WAIT(fileno(stdout));
121+ int oldStdErr = DUP_WAIT(fileno(stderr));
122+
123+ DUP2_WAIT(m_pipe[WRITE], fileno(stdout));
124+ DUP2_WAIT(m_pipe[WRITE], fileno(stderr));
125+ CLOSE_WAIT(m_pipe[WRITE]);
126+
127+ while(true) {
128+ {
129+ QMutexLocker lock(&m_mutex);
130+ if (m_stop) break;
131+ }
132+ checkLog();
133+ QThread::msleep(50);
134+ }
135+
136+ DUP2_WAIT(oldStdOut, fileno(stdout));
137+ DUP2_WAIT(oldStdErr, fileno(stderr));
138+
139+ CLOSE_WAIT(oldStdOut);
140+ CLOSE_WAIT(oldStdErr);
141+ CLOSE_WAIT(m_pipe[READ]);
142+}
143+
144+
145+void LogRedirector::checkLog()
146+{
147+ // Do not allow read to block with no data.
148+ // If we stop the thread while waiting a read,
149+ // it will block the main thread waiting for this thread to stop.
150+ int count = 0;
151+ ioctl(m_pipe[READ], FIONREAD, &count);
152+ if (count <= 0) return;
153+
154+ std::string captured;
155+ std::string buf;
156+ const int bufSize = 1024;
157+ buf.resize(bufSize);
158+ int bytesRead = 0;
159+ bytesRead = read(m_pipe[READ], &(*buf.begin()), bufSize);
160+ while(bytesRead == bufSize)
161+ {
162+ captured += buf;
163+ bytesRead = 0;
164+ bytesRead = read(m_pipe[READ], &(*buf.begin()), bufSize);
165+ }
166+ if (bytesRead > 0)
167+ {
168+ buf.resize(bytesRead);
169+ captured += buf;
170+ }
171+
172+ if (!captured.empty()) {
173+ Q_EMIT log(QString::fromStdString(captured));
174+ }
175+}
176+
177+LogRedirector *LogRedirector::instance()
178+{
179+ static LogRedirector* log = nullptr;
180+ if (!log) {
181+ log = new LogRedirector();
182+ }
183+ return log;
184+}
185+
186+void LogRedirector::add(ConsoleLog* logger)
187+{
188+ QMutexLocker lock(&m_mutex);
189+ connect(this, &LogRedirector::log, logger, &ConsoleLog::logged, Qt::UniqueConnection);
190+
191+ m_ref++;
192+ if (!LogRedirector::instance()->isRunning()) {
193+ m_stop = false;
194+ LogRedirector::instance()->start();
195+ }
196+}
197+
198+void LogRedirector::remove(ConsoleLog* logger)
199+{
200+ QMutexLocker lock(&m_mutex);
201+ disconnect(this, &LogRedirector::log, logger, &ConsoleLog::logged);
202+
203+ m_ref = qMax(m_ref-1, 0);
204+ if (m_ref == 0 && LogRedirector::instance()->isRunning()) {
205+ m_stop = true;
206+ lock.unlock();
207+ LogRedirector::instance()->wait();
208+ }
209+}
210+
211+ConsoleLog::ConsoleLog(QObject *parent)
212+ : QObject(parent)
213+ , m_enabled(false)
214+ , m_maxLines(60)
215+{
216+ auto updateEnabled = [this]() {
217+ if (m_enabled) {
218+ LogRedirector::instance()->add(this);
219+ } else {
220+ LogRedirector::instance()->remove(this);
221+ }
222+ };
223+ connect(this, &ConsoleLog::enabledChanged, this, updateEnabled);
224+}
225+
226+ConsoleLog::~ConsoleLog()
227+{
228+ if (m_enabled) {
229+ LogRedirector::instance()->remove(this);
230+ }
231+}
232+
233+void ConsoleLog::setEnabled(bool enabled)
234+{
235+ if (m_enabled == enabled) {
236+ return;
237+ }
238+
239+ m_enabled = enabled;
240+ Q_EMIT enabledChanged();
241+}
242+
243+QString ConsoleLog::out() const
244+{
245+ return m_out.join("\n");
246+}
247+
248+void ConsoleLog::setMaxLines(int maxLines)
249+{
250+ if (m_maxLines == maxLines) {
251+ return;
252+ }
253+
254+ m_maxLines = maxLines;
255+ while (m_out.count() > m_maxLines) {
256+ m_out.removeLast();
257+ }
258+ Q_EMIT outChanged();
259+ Q_EMIT maxLinesChanged();
260+}
261+
262+void ConsoleLog::logged(QString captured)
263+{
264+ QStringList li = captured.split("\n", QString::SkipEmptyParts);
265+ li << m_out;
266+ m_out = li;
267+ while (m_out.count() > m_maxLines) {
268+ m_out.removeLast();
269+ }
270+ Q_EMIT outChanged();
271+}
272
273=== added file 'plugins/Unity/Debug/consolelog.h'
274--- plugins/Unity/Debug/consolelog.h 1970-01-01 00:00:00 +0000
275+++ plugins/Unity/Debug/consolelog.h 2016-07-08 11:04:05 +0000
276@@ -0,0 +1,87 @@
277+/*
278+ * Copyright 2016 Canonical Ltd.
279+ *
280+ * This program is free software; you can redistribute it and/or modify
281+ * it under the terms of the GNU Lesser General Public License as published by
282+ * the Free Software Foundation; version 3.
283+ *
284+ * This program is distributed in the hope that it will be useful,
285+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
286+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
287+ * GNU Lesser General Public License for more details.
288+ *
289+ * You should have received a copy of the GNU Lesser General Public License
290+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
291+*/
292+
293+#ifndef CONSOLELOG_H
294+#define CONSOLELOG_H
295+
296+#include <QThread>
297+#include <QMutex>
298+#include <QSet>
299+
300+class ConsoleLog;
301+
302+class LogRedirector : public QThread
303+{
304+ Q_OBJECT
305+public:
306+ static LogRedirector *instance();
307+
308+ void add(ConsoleLog* logger);
309+ void remove(ConsoleLog* logger);
310+
311+private Q_SLOTS:
312+ void checkLog();
313+
314+Q_SIGNALS:
315+ void log(QString log);
316+
317+private:
318+ LogRedirector();
319+ void run() Q_DECL_OVERRIDE;
320+
321+ QMutex m_mutex;
322+ int m_pipe[2];
323+ int m_ref;
324+ bool m_stop;
325+
326+ enum PIPES { READ, WRITE };
327+};
328+
329+class ConsoleLog : public QObject
330+{
331+ Q_OBJECT
332+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
333+ Q_PROPERTY(QString out READ out NOTIFY outChanged)
334+ Q_PROPERTY(int maxLines READ maxLines WRITE setMaxLines NOTIFY maxLinesChanged)
335+public:
336+ explicit ConsoleLog(QObject *parent = 0);
337+ ~ConsoleLog();
338+
339+ bool isEnabled() const { return m_enabled; }
340+ void setEnabled(bool enabled);
341+
342+ QString out() const;
343+
344+ int maxLines() const { return m_maxLines; }
345+ void setMaxLines(int maxLines);
346+
347+public Q_SLOTS:
348+ void logged(QString captured);
349+
350+Q_SIGNALS:
351+ void enabledChanged();
352+ void outChanged();
353+ void maxLinesChanged();
354+
355+private:
356+ void updateEnabled();
357+
358+ QStringList m_out;
359+ bool m_enabled;
360+ int m_maxLines;
361+};
362+
363+#endif // CONSOLELOG_H
364
365=== added file 'plugins/Unity/Debug/plugin.cpp'
366--- plugins/Unity/Debug/plugin.cpp 1970-01-01 00:00:00 +0000
367+++ plugins/Unity/Debug/plugin.cpp 2016-07-08 11:04:05 +0000
368@@ -0,0 +1,31 @@
369+/*
370+ * Copyright (C) 2016 Canonical, Ltd.
371+ *
372+ * This program is free software; you can redistribute it and/or modify
373+ * it under the terms of the GNU General Public License as published by
374+ * the Free Software Foundation; version 3.
375+ *
376+ * This program is distributed in the hope that it will be useful,
377+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
378+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
379+ * GNU General Public License for more details.
380+ *
381+ * You should have received a copy of the GNU General Public License
382+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
383+ */
384+
385+// Qt
386+#include <QtQml/qqml.h>
387+
388+// self
389+#include "plugin.h"
390+
391+// local
392+#include "consolelog.h"
393+
394+void UnityDebugPlugin::registerTypes(const char *uri)
395+{
396+ Q_ASSERT(uri == QLatin1String("Unity.Debug"));
397+
398+ qmlRegisterType<ConsoleLog>(uri, 0, 1, "ConsoleLog");
399+}
400
401=== added file 'plugins/Unity/Debug/plugin.h'
402--- plugins/Unity/Debug/plugin.h 1970-01-01 00:00:00 +0000
403+++ plugins/Unity/Debug/plugin.h 2016-07-08 11:04:05 +0000
404@@ -0,0 +1,32 @@
405+/*
406+ * Copyright (C) 2016 Canonical, Ltd.
407+ *
408+ * This program is free software; you can redistribute it and/or modify
409+ * it under the terms of the GNU General Public License as published by
410+ * the Free Software Foundation; version 3.
411+ *
412+ * This program is distributed in the hope that it will be useful,
413+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
415+ * GNU General Public License for more details.
416+ *
417+ * You should have received a copy of the GNU General Public License
418+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
419+ */
420+
421+#ifndef UNITYDEBUG_PLUGIN_H
422+#define UNITYDEBUG_PLUGIN_H
423+
424+#include <QtQml/QQmlEngine>
425+#include <QtQml/QQmlExtensionPlugin>
426+
427+class UnityDebugPlugin : public QQmlExtensionPlugin
428+{
429+ Q_OBJECT
430+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
431+
432+public:
433+ void registerTypes(const char *uri) override;
434+};
435+
436+#endif
437
438=== added file 'plugins/Unity/Debug/qmldir'
439--- plugins/Unity/Debug/qmldir 1970-01-01 00:00:00 +0000
440+++ plugins/Unity/Debug/qmldir 2016-07-08 11:04:05 +0000
441@@ -0,0 +1,3 @@
442+module Unity.Debug
443+plugin Debug-qml
444+typeinfo Debug.qmltypes
445
446=== modified file 'qml/Shell.qml'
447--- qml/Shell.qml 2016-07-05 09:57:08 +0000
448+++ qml/Shell.qml 2016-07-08 11:04:05 +0000
449@@ -43,6 +43,7 @@
450 import Unity.Indicators 0.1 as Indicators
451 import Cursor 1.1
452 import WindowManager 0.1
453+import Unity.Debug 0.1 as Debug
454
455
456 StyledItem {
457@@ -809,4 +810,20 @@
458 }
459 }
460 }
461+
462+ Loader {
463+ z: shutdownFadeOutRectangle.z + 1
464+ active: DebuggingController.logOverlay
465+
466+ sourceComponent: Text {
467+ width: shell.width
468+ height: shell.height
469+
470+ text: consoleLog.out
471+ Debug.ConsoleLog {
472+ id: consoleLog
473+ enabled: true
474+ }
475+ }
476+ }
477 }
478
479=== modified file 'src/DebuggingController.cpp'
480--- src/DebuggingController.cpp 2016-07-08 11:04:05 +0000
481+++ src/DebuggingController.cpp 2016-07-08 11:04:05 +0000
482@@ -25,8 +25,9 @@
483 #include <private/qquickitem_p.h>
484 #include <private/qsgrenderer_p.h>
485
486-DebuggingController::DebuggingController(QObject *parent):
487- UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent)
488+DebuggingController::DebuggingController(QObject *parent)
489+ : UnityDBusObject(QStringLiteral("/com/canonical/Unity8/Debugging"), QStringLiteral("com.canonical.Unity8"), true, parent)
490+ , m_logOverlay(false)
491 {
492 }
493
494@@ -67,3 +68,13 @@
495 {
496 QLoggingCategory::setFilterRules(filterRules);
497 }
498+
499+void DebuggingController::SetLogOverlay(bool logOverlay)
500+{
501+ if (logOverlay == m_logOverlay) {
502+ return;
503+ }
504+
505+ m_logOverlay = logOverlay;
506+ Q_EMIT logOverlayChanged(m_logOverlay);
507+}
508
509=== modified file 'src/DebuggingController.h'
510--- src/DebuggingController.h 2016-07-08 11:04:05 +0000
511+++ src/DebuggingController.h 2016-07-08 11:04:05 +0000
512@@ -30,10 +30,14 @@
513 Q_OBJECT
514 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity8.Debugging")
515
516+ Q_PROPERTY(bool logOverlay READ logOverlay NOTIFY logOverlayChanged)
517+
518 public:
519 DebuggingController(QObject *parent = nullptr);
520 ~DebuggingController() = default;
521
522+ bool logOverlay() const { return m_logOverlay; }
523+
524 public Q_SLOTS:
525 /**
526 * Set the QSG_VISUALIZE mode. This follows the vlues supported by Qt in
527@@ -50,5 +54,16 @@
528 * Set the QLoggingCategory filter rules.
529 */
530 Q_SCRIPTABLE void SetLoggingFilterRules(const QString &filterRules);
531+
532+ /**
533+ * Enable/Disable the shell console log overlay
534+ */
535+ Q_SCRIPTABLE void SetLogOverlay(bool logOverlay);
536+
537+Q_SIGNALS:
538+ void logOverlayChanged(bool logOverlay);
539+
540+private:
541+ bool m_logOverlay;
542 };
543 #endif // DEBUGGINGCONTROLLER_H
544
545=== modified file 'src/ShellApplication.cpp'
546--- src/ShellApplication.cpp 2016-07-08 11:04:05 +0000
547+++ src/ShellApplication.cpp 2016-07-08 11:04:05 +0000
548@@ -19,6 +19,7 @@
549 // Qt
550 #include <QLibrary>
551 #include <QScreen>
552+#include <QQmlContext>
553
554 #include <libintl.h>
555
556@@ -94,7 +95,7 @@
557 }
558 #endif
559
560- new DebuggingController(this);
561+ m_qmlEngine->rootContext()->setContextProperty("DebuggingController", new DebuggingController(this));
562
563 // Some hard-coded policy for now.
564 // NB: We don't support more than two screens at the moment
565
566=== modified file 'tests/uqmlscene/main.cpp'
567--- tests/uqmlscene/main.cpp 2016-07-08 11:04:05 +0000
568+++ tests/uqmlscene/main.cpp 2016-07-08 11:04:05 +0000
569@@ -468,8 +468,6 @@
570
571 int exitCode = 0;
572
573- new DebuggingController(&app);
574-
575 if (!options.file.isEmpty()) {
576 if (!options.versionDetection || checkVersion(options.file)) {
577 #ifndef QT_NO_TRANSLATION
578@@ -479,6 +477,8 @@
579 // TODO: as soon as the engine construction completes, the debug service is
580 // listening for connections. But actually we aren't ready to debug anything.
581 QQmlEngine engine;
582+ engine.rootContext()->setContextProperty("DebuggingController", new DebuggingController(&app));
583+
584 QQmlComponent *component = new QQmlComponent(&engine);
585 for (int i = 0; i < imports.size(); ++i)
586 engine.addImportPath(imports.at(i));

Subscribers

People subscribed via source and target branches