From 8c020a0ec2af180c40bdba8971d007de77aba3fe Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 25 Apr 2017 18:01:19 +0100 Subject: [PATCH] saving work --- .../qml/hifi/tablet/InputRecorder.qml | 37 ++++++++++++------- libraries/controllers/CMakeLists.txt | 2 +- .../src/controllers/InputRecorder.cpp | 9 ++++- libraries/ui/src/FileDialogHelper.cpp | 4 ++ libraries/ui/src/FileDialogHelper.h | 1 + scripts/developer/inputRecording.js | 22 +++++++++++ 6 files changed, 58 insertions(+), 17 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/InputRecorder.qml b/interface/resources/qml/hifi/tablet/InputRecorder.qml index b9b5406a72..77f21e338c 100644 --- a/interface/resources/qml/hifi/tablet/InputRecorder.qml +++ b/interface/resources/qml/hifi/tablet/InputRecorder.qml @@ -98,25 +98,15 @@ Rectangle { } + + HifiControls.Button { - id: load + id: browse anchors.right: parent.right anchors.top: selectedFile.bottom anchors.topMargin: 10 - text: "Load" - color: hifi.buttons.black - enabled: true - onClicked: sendToScript({method: "Load", params: {file: path }}); - } - - HifiControls.Button { - id: browse - anchors.right: load.left - anchors.top: selectedFile.bottom - anchors.topMargin: 10 - - text: "Browse" + text: "Load..." color: hifi.buttons.black enabled: true onClicked: { @@ -146,6 +136,25 @@ Rectangle { function getFileSelected(file) { selectedFile.text = file; inputRecorder.path = file; + sendToScript({method: "Load", params: {file: path }}); + } + + function fromScript(message) { + switch (message.method) { + case "update": + updateButtonStatus(message.params); + break; + } + } + + function updateButtonStatus(status) { + inputRecorder.recording = status; + + if (inputRecorder.recording) { + start.text = "Stop Recording"; + } else { + start.text = "Start Recording"; + } } } diff --git a/libraries/controllers/CMakeLists.txt b/libraries/controllers/CMakeLists.txt index 384218691a..bf226f2647 100644 --- a/libraries/controllers/CMakeLists.txt +++ b/libraries/controllers/CMakeLists.txt @@ -10,4 +10,4 @@ GroupSources("src/controllers") add_dependency_external_projects(glm) find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS} "${CMAKE_BINARY_DIR}/includes") diff --git a/libraries/controllers/src/controllers/InputRecorder.cpp b/libraries/controllers/src/controllers/InputRecorder.cpp index cd41c40804..5a10cc1d4a 100644 --- a/libraries/controllers/src/controllers/InputRecorder.cpp +++ b/libraries/controllers/src/controllers/InputRecorder.cpp @@ -17,9 +17,14 @@ #include #include #include -#include +#include +#include -QString SAVE_DIRECTORY = QDir::homePath()+"/hifi-input-recordings/"; +#include +#include + +QString SAVE_DIRECTORY = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/" + BuildInfo::INTERFACE_NAME + + "/interface" + "/hifi-input-recordings/"; QString FILE_PREFIX_NAME = "input-recording-"; QString COMPRESS_EXTENSION = ".tar.gz"; namespace controller { diff --git a/libraries/ui/src/FileDialogHelper.cpp b/libraries/ui/src/FileDialogHelper.cpp index 2752de8592..6d14adf1db 100644 --- a/libraries/ui/src/FileDialogHelper.cpp +++ b/libraries/ui/src/FileDialogHelper.cpp @@ -26,6 +26,10 @@ QStringList FileDialogHelper::standardPath(StandardLocation location) { return QStandardPaths::standardLocations(static_cast(location)); } +QString FileDialogHelper::writableLocation(StandardLocation location) { + return QStandardPaths::writableLocation(static_cast(location)); +} + QString FileDialogHelper::urlToPath(const QUrl& url) { return url.toLocalFile(); } diff --git a/libraries/ui/src/FileDialogHelper.h b/libraries/ui/src/FileDialogHelper.h index 6c352ecdfc..12fd60daac 100644 --- a/libraries/ui/src/FileDialogHelper.h +++ b/libraries/ui/src/FileDialogHelper.h @@ -48,6 +48,7 @@ public: Q_INVOKABLE QUrl home(); Q_INVOKABLE QStringList standardPath(StandardLocation location); + Q_INVOKABLE QString writableLocation(StandardLocation location); Q_INVOKABLE QStringList drives(); Q_INVOKABLE QString urlToPath(const QUrl& url); Q_INVOKABLE bool urlIsDir(const QUrl& url); diff --git a/scripts/developer/inputRecording.js b/scripts/developer/inputRecording.js index 26abea72bb..7a3809c058 100644 --- a/scripts/developer/inputRecording.js +++ b/scripts/developer/inputRecording.js @@ -7,6 +7,7 @@ // (function() { + var recording = false; var onRecordingScreen = false; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ @@ -15,13 +16,20 @@ function onClick() { if (onRecordingScreen) { tablet.gotoHomeScreen(); + onRecordingScreen = false; } else { tablet.loadQMLSource("InputRecorder.qml"); + onRecordingScreen = true; } } + function onScreenChanged(type, url) { + onRecordingScreen = false; + } + button.clicked.connect(onClick); tablet.fromQml.connect(fromQml); + tablet.screenChanged.connect(onScreenChanged); function fromQml(message) { switch (message.method) { case "Start": @@ -45,10 +53,12 @@ function startRecording() { Controller.startInputRecording(); + recording = true; } function stopRecording() { Controller.stopInputRecording(); + recording = false; } function saveRecording() { @@ -63,11 +73,23 @@ Controller.startInputPlayback(); } + function sendToQml(message) { + tablet.sendToQml(message); + } + + function update() { + sendToQml({method: "update", params: recording}); + } + + Script.setInterval(update, 60); + Script.scriptEnding.connect(function () { button.clicked.disconnect(onClick); if (tablet) { tablet.removeButton(button); } + + Controller.stopInputRecording(); }); }());