Commit 24ce071a authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): utils.js is now a module

parent 5dedf82c
......@@ -78,7 +78,8 @@
<file>ui/modules/Linphone/Styles/TimelineStyle.qml</file>
<file>ui/modules/Linphone/Timeline.qml</file>
<file>ui/modules/Linphone/View/ScrollableListView.qml</file>
<file>ui/scripts/utils.js</file>
<file>ui/scripts/Utils/qmldir</file>
<file>ui/scripts/Utils/utils.js</file>
<file>ui/views/MainWindow/Contact.qml</file>
<file>ui/views/MainWindow/Contacts.qml</file>
<file>ui/views/MainWindow/Conversation.qml</file>
......
......@@ -57,6 +57,7 @@ int main (int argc, char *argv[]) {
// Set modules paths.
engine.addImportPath(":/ui/modules");
engine.addImportPath(":/ui/scripts");
engine.load(QUrl("qrc:/ui/views/MainWindow/MainWindow.qml"));
if (engine.rootObjects().isEmpty())
......
import QtQuick 2.7
import 'qrc:/ui/scripts/utils.js' as Utils
import Utils 1.0
// ===================================================================
......
import QtQuick 2.7
import Linphone 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
import Utils 1.0
// ===================================================================
// Helper to handle button click outside a component.
......
module Utils
Utils 1.0 utils.js
......@@ -79,16 +79,14 @@ function snakeToCamel (s) {
// -------------------------------------------------------------------
function Timer (parent) {
return Qt.createQmlObject('import QtQuick 2.7; Timer { }', parent)
}
// A copy of `Window.setTimeout` from js.
// Use setTimeout.call(parentContext, delayTime, cb) to use it.
//
// delay is in milliseconds.
function setTimeout (delay, cb) {
var timer = new Timer(this)
var timer = new (function (parent) {
return Qt.createQmlObject('import QtQuick 2.7; Timer { }', parent)
})(this)
timer.interval = delay
timer.repeat = false
......
......@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import Linphone 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
import Utils 1.0
ColumnLayout {
spacing: 0
......
......@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import Linphone 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
import Utils 1.0
ColumnLayout {
spacing: 2
......
......@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import Linphone 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
import Utils 1.0
ApplicationWindow {
id: window
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment