Fix debugging enabled flag & remove webkit specific bit
diff --git a/CordovaUbuntu/CordovaViewInternal.qml b/CordovaUbuntu/CordovaViewInternal.qml
index f655571..87f5fac 100644
--- a/CordovaUbuntu/CordovaViewInternal.qml
+++ b/CordovaUbuntu/CordovaViewInternal.qml
@@ -85,8 +85,8 @@
context: WebContext {
id: webcontext
- devtoolsEnabled: true
- devtoolsPort: 9222
+ devtoolsEnabled: debuggingEnabled
+ devtoolsPort: debuggingEnabled ? 9222 : -1
userScripts: [
UserScript {
diff --git a/bin/templates/project/cordova/lib/run.js b/bin/templates/project/cordova/lib/run.js
index b96f49c..9f905d8 100644
--- a/bin/templates/project/cordova/lib/run.js
+++ b/bin/templates/project/cordova/lib/run.js
@@ -2,7 +2,7 @@
/*
*
- * Copyright 2014 Canonical Ltd.
+ * Copyright 2014-2016 Canonical Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,10 +88,10 @@
Utils.pushd(path.join(nativeDir, 'prefix'));
- var cmd = 'QTWEBKIT_INSPECTOR_SERVER=9222 ./cordova-ubuntu www/';
+ var cmd = './cordova-ubuntu www/';
if (debug) {
cmd = "DEBUG=1 " + cmd;
- logger.warn('Debug enabled. Try pointing a WebKit browser to http://127.0.0.1:9222');
+ logger.warn('Debug enabled. Try pointing a Chrome/Chromium browser to http://127.0.0.1:9222');
}
logger.info('Launching the application.');
@@ -134,7 +134,7 @@
Devices.adbExec(target, 'shell "cd /home/phablet/; pkcon install-local ' + names[0] + ' -p --allow-untrusted -y"', {silent: false});
if (debug) {
- logger.warn('Debug enabled. Try pointing a WebKit browser to http://127.0.0.1:9222');
+ logger.warn('Debug enabled. Try pointing a Chrome/Chromium browser to http://127.0.0.1:9222');
Devices.adbExec(target, 'forward tcp:9222 tcp:9222');
}
diff --git a/main.cpp b/main.cpp
index b12aa84..ffef445 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Canonical Ltd.
+ * Copyright 2013-2016 Canonical Ltd.
* Copyright 2011 Wolfgang Koller - http://www.gofg.at/
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,11 @@
#include <QApplication>
#include <QtQuick>
-static void customMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg) {
+static void customMessageOutput(
+ QtMsgType type,
+ const QMessageLogContext &,
+ const QString &msg) {
+
switch (type) {
case QtDebugMsg:
if (qgetenv("DEBUG").size()) {
@@ -39,10 +43,13 @@
}
int main(int argc, char *argv[]) {
- printf("\nApache Cordova native platform version %s is starting\n\n", CORDOVA_UBUNTU_VERSION);
+ printf("\nApache Cordova native platform version %s is starting\n\n"
+ , CORDOVA_UBUNTU_VERSION);
+
fflush(stdout);
qInstallMessageHandler(customMessageOutput);
+
QApplication app(argc, argv);
//TODO: switch to options parser
@@ -60,7 +67,16 @@
QQmlApplicationEngine view;
QDir workingDir = QApplication::applicationDirPath();
- view.rootContext()->setContextProperty("www", wwwDir.absolutePath());
+
+ bool debuggingEnabled =
+ (qEnvironmentVariableIsSet("DEBUG")
+ && QString(qgetenv("DEBUG")) == "1");
+
+ view.rootContext()->setContextProperty(
+ "debuggingEnabled", debuggingEnabled);
+
+ view.rootContext()->setContextProperty(
+ "www", wwwDir.absolutePath());
view.load(QUrl(QString("%1/qml/main.qml").arg(workingDir.absolutePath())));