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

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

parent 5dedf82c
...@@ -78,7 +78,8 @@ ...@@ -78,7 +78,8 @@
<file>ui/modules/Linphone/Styles/TimelineStyle.qml</file> <file>ui/modules/Linphone/Styles/TimelineStyle.qml</file>
<file>ui/modules/Linphone/Timeline.qml</file> <file>ui/modules/Linphone/Timeline.qml</file>
<file>ui/modules/Linphone/View/ScrollableListView.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/Contact.qml</file>
<file>ui/views/MainWindow/Contacts.qml</file> <file>ui/views/MainWindow/Contacts.qml</file>
<file>ui/views/MainWindow/Conversation.qml</file> <file>ui/views/MainWindow/Conversation.qml</file>
......
...@@ -57,6 +57,7 @@ int main (int argc, char *argv[]) { ...@@ -57,6 +57,7 @@ int main (int argc, char *argv[]) {
// Set modules paths. // Set modules paths.
engine.addImportPath(":/ui/modules"); engine.addImportPath(":/ui/modules");
engine.addImportPath(":/ui/scripts");
engine.load(QUrl("qrc:/ui/views/MainWindow/MainWindow.qml")); engine.load(QUrl("qrc:/ui/views/MainWindow/MainWindow.qml"));
if (engine.rootObjects().isEmpty()) if (engine.rootObjects().isEmpty())
......
import QtQuick 2.7 import QtQuick 2.7
import 'qrc:/ui/scripts/utils.js' as Utils import Utils 1.0
// =================================================================== // ===================================================================
......
import QtQuick 2.7 import QtQuick 2.7
import Linphone 1.0 import Linphone 1.0
import Utils 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
// =================================================================== // ===================================================================
// Helper to handle button click outside a component. // Helper to handle button click outside a component.
......
module Utils
Utils 1.0 utils.js
...@@ -79,16 +79,14 @@ function snakeToCamel (s) { ...@@ -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. // A copy of `Window.setTimeout` from js.
// Use setTimeout.call(parentContext, delayTime, cb) to use it. // Use setTimeout.call(parentContext, delayTime, cb) to use it.
// //
// delay is in milliseconds. // delay is in milliseconds.
function setTimeout (delay, cb) { 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.interval = delay
timer.repeat = false timer.repeat = false
......
...@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0 ...@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import Linphone 1.0 import Linphone 1.0
import Utils 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
ColumnLayout { ColumnLayout {
spacing: 0 spacing: 0
......
...@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0 ...@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import Linphone 1.0 import Linphone 1.0
import Utils 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
ColumnLayout { ColumnLayout {
spacing: 2 spacing: 2
......
...@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0 ...@@ -3,8 +3,7 @@ import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import Linphone 1.0 import Linphone 1.0
import Utils 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
ApplicationWindow { ApplicationWindow {
id: window 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