saving work

This commit is contained in:
Dante Ruiz 2017-04-25 18:01:19 +01:00
parent 2a997f2a4d
commit 8c020a0ec2
6 changed files with 58 additions and 17 deletions
interface/resources/qml/hifi/tablet
libraries
scripts/developer

View file

@ -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";
}
}
}

View file

@ -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")

View file

@ -17,9 +17,14 @@
#include <QStandardPaths>
#include <QDateTime>
#include <QByteArray>
#include <GLMHelpers.h>
#include <QStandardPaths>
#include <PathUtils.h>
QString SAVE_DIRECTORY = QDir::homePath()+"/hifi-input-recordings/";
#include <BuildInfo.h>
#include <GLMHelpers.h>
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 {

View file

@ -26,6 +26,10 @@ QStringList FileDialogHelper::standardPath(StandardLocation location) {
return QStandardPaths::standardLocations(static_cast<QStandardPaths::StandardLocation>(location));
}
QString FileDialogHelper::writableLocation(StandardLocation location) {
return QStandardPaths::writableLocation(static_cast<QStandardPaths::StandardLocation>(location));
}
QString FileDialogHelper::urlToPath(const QUrl& url) {
return url.toLocalFile();
}

View file

@ -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);

View file

@ -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();
});
}());