From 057ef4d5662d651b445c7d79c443aac32dde4f94 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 14 Sep 2016 15:32:38 +0200 Subject: [PATCH] feat(app): use external `scripts` folder --- tests/build_resources_file | 2 +- tests/imgs/chat.svg | 17 +++++++++++++++++ tests/resources.qrc | 1 + tests/ui/scripts/utils.js | 18 ++++++++++++++++++ tests/ui/views/mainWindow/mainWindow.qml | 18 ++++-------------- 5 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 tests/imgs/chat.svg create mode 100644 tests/ui/scripts/utils.js diff --git a/tests/build_resources_file b/tests/build_resources_file index f03afe5c3..dd3989a20 100755 --- a/tests/build_resources_file +++ b/tests/build_resources_file @@ -7,7 +7,7 @@ for filename in $(find languages/ ui/ imgs/ -type f) do extension="${filename##*.}" - if [[ "${extension}" == @(qml|svg|qm) ]]; then + if [[ "${extension}" == @(qml|svg|qm|js) ]]; then echo " $filename" fi done diff --git a/tests/imgs/chat.svg b/tests/imgs/chat.svg new file mode 100644 index 000000000..851ec6a94 --- /dev/null +++ b/tests/imgs/chat.svg @@ -0,0 +1,17 @@ + + + + chat_add + Created with Sketch. + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/resources.qrc b/tests/resources.qrc index e3c4d4dc4..34d9517a0 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -20,6 +20,7 @@ ui/components/form/TransparentComboBox.qml ui/components/form/SmallButton.qml ui/components/form/DarkButton.qml + ui/scripts/utils.js ui/views/newCall.qml ui/views/manageAccounts.qml ui/views/mainWindow/mainWindow.qml diff --git a/tests/ui/scripts/utils.js b/tests/ui/scripts/utils.js new file mode 100644 index 000000000..f629f2cb9 --- /dev/null +++ b/tests/ui/scripts/utils.js @@ -0,0 +1,18 @@ +// =================================================================== +// Contains many common helpers. +// =================================================================== + +function openWindow (windowName, parent) { + var component = Qt.createComponent( + 'qrc:/ui/views/' + windowName + '.qml' + ); + + if (component.status !== Component.Ready) { + console.debug('Window ' + windowName + ' not ready.') + if(component.status === Component.Error) { + console.debug('Error:' + component.errorString()) + } + } else { + component.createObject(parent).show() + } +} diff --git a/tests/ui/views/mainWindow/mainWindow.qml b/tests/ui/views/mainWindow/mainWindow.qml index efa32fad9..7a8823115 100644 --- a/tests/ui/views/mainWindow/mainWindow.qml +++ b/tests/ui/views/mainWindow/mainWindow.qml @@ -7,19 +7,9 @@ import 'qrc:/ui/components/contact' import 'qrc:/ui/components/form' import 'qrc:/ui/components/misc' -ApplicationWindow { - function openWindow (name) { - var component = Qt.createComponent('qrc:/ui/views/' + name + '.qml'); - if (component.status !== Component.Ready) { - console.debug('Window not ready.') - if(component.status === Component.Error) { - console.debug('Error:' + component.errorString()) - } - } else { - component.createObject(mainWindow).show() - } - } +import 'qrc:/ui/scripts/utils.js' as Utils +ApplicationWindow { id: mainWindow minimumHeight: 70 minimumWidth: 780 @@ -57,11 +47,11 @@ ApplicationWindow { // User actions. ActionButton { - onClicked: openWindow('manageAccounts') + onClicked: Utils.openWindow('manageAccounts', mainWindow) } ActionButton { - onClicked: openWindow('newCall') + onClicked: Utils.openWindow('newCall', mainWindow) } // Search.