mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:24:00 +02:00
open avatar projects
This commit is contained in:
parent
3943fe2861
commit
c0bd9121fb
6 changed files with 149 additions and 32 deletions
|
@ -7,6 +7,7 @@ import "../controlsUit" 1.0 as HifiControls
|
|||
import "../stylesUit" 1.0
|
||||
import "../windows" as Windows
|
||||
import "../dialogs"
|
||||
import "avatarPackager"
|
||||
|
||||
Windows.ScrollingWindow {
|
||||
id: root
|
||||
|
@ -19,35 +20,78 @@ Windows.ScrollingWindow {
|
|||
destroyOnHidden: true
|
||||
implicitWidth: 384; implicitHeight: 640
|
||||
minSize: Qt.vector2d(200, 300)
|
||||
|
||||
//HifiConstants { id: hifi }
|
||||
|
||||
AvatarProject {
|
||||
id: avatarProject
|
||||
colorScheme: root.colorScheme
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: avatarPackagerMain
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
RalewaySemiBold {
|
||||
id: displayNameLabel
|
||||
id: avatarPackagerLabel
|
||||
size: 24;
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 25
|
||||
text: 'Avatar Projects'
|
||||
anchors.bottomMargin: 25
|
||||
text: 'Avatar Packager'
|
||||
}
|
||||
|
||||
HifiControls.Button {
|
||||
id: createProjectButton
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: displayNameLabel.bottom
|
||||
text: qsTr("Open Avatar Project")
|
||||
// color: hifi.buttons.blue
|
||||
anchors.top: avatarPackagerLabel.bottom
|
||||
text: qsTr("Create Project")
|
||||
colorScheme: root.colorScheme
|
||||
height: 30
|
||||
onClicked: function() {
|
||||
let avatarProject = AvatarPackagerCore.openAvatarProject();
|
||||
if (avatarProject) {
|
||||
console.log("LOAD COMPLETE");
|
||||
} else {
|
||||
console.log("LOAD FAILED");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
HifiControls.Button {
|
||||
id: openProjectButton
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: createProjectButton.bottom
|
||||
text: qsTr("Open Avatar Project")
|
||||
colorScheme: root.colorScheme
|
||||
height: 30
|
||||
onClicked: function() {
|
||||
var avatarProjectsPath = fileDialogHelper.standardPath(/*fileDialogHelper.StandardLocation.DocumentsLocation*/ 1) + "/High Fidelity/Avatar Projects";
|
||||
console.log("path = " + avatarProjectsPath);
|
||||
|
||||
// TODO: make the dialog modal
|
||||
|
||||
var browser = desktop.fileDialog({
|
||||
selectDirectory: false,
|
||||
dir: fileDialogHelper.pathToUrl(avatarProjectsPath),
|
||||
filter: "Avatar Project FST Files (*.fst)",
|
||||
title: "Open Project (.fst)"
|
||||
});
|
||||
|
||||
browser.canceled.connect(function() {
|
||||
|
||||
});
|
||||
|
||||
browser.selectedFile.connect(function(fileUrl) {
|
||||
console.log("FOUND PATH " + fileUrl);
|
||||
let fstFilePath = fileDialogHelper.urlToPath(fileUrl);
|
||||
let avatarProject = AvatarPackagerCore.openAvatarProject(fstFilePath);
|
||||
if (avatarProject) {
|
||||
console.log("LOAD COMPLETE");
|
||||
console.log("file dir = " + AvatarPackagerCore.currentAvatarProject.projectFolderPath);
|
||||
avatarProject.visible = true;
|
||||
avatarPackagerMain.visible = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
import QtQuick 2.6
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import "../../controlsUit" 1.0 as HifiControls
|
||||
import "../../stylesUit" 1.0
|
||||
|
||||
Rectangle {
|
||||
id: avatarProject
|
||||
|
||||
HifiConstants { id: hifi }
|
||||
|
||||
|
||||
z: 3
|
||||
property int colorScheme;
|
||||
|
||||
visible: false
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
RalewaySemiBold {
|
||||
id: avatarProjectLabel
|
||||
size: 24;
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 25
|
||||
anchors.bottomMargin: 25
|
||||
text: 'Avatar Project'
|
||||
}
|
||||
HifiControls.Button {
|
||||
id: openFolderButton
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: avatarProjectLabel.bottom
|
||||
text: qsTr("Open Project Folder")
|
||||
colorScheme: avatarProject.colorScheme
|
||||
height: 30
|
||||
onClicked: function() {
|
||||
fileDialogHelper.openDirectory(AvatarPackagerCore.currentAvatarProject.projectFolderPath);
|
||||
}
|
||||
}
|
||||
HifiControls.Button {
|
||||
id: uploadButton
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: openFolderButton.bottom
|
||||
text: qsTr("Upload")
|
||||
color: hifi.buttons.blue
|
||||
colorScheme: avatarProject.colorScheme
|
||||
height: 30
|
||||
onClicked: function() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,11 +12,9 @@
|
|||
#include "AvatarPackager.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
|
||||
#include <OffscreenUi.h>
|
||||
#include "ModelSelector.h"
|
||||
|
||||
bool AvatarPackager::open() {
|
||||
static const QUrl url{ "hifi/AvatarPackager.qml" };
|
||||
|
@ -28,17 +26,10 @@ bool AvatarPackager::open() {
|
|||
return true;
|
||||
}
|
||||
|
||||
QObject* AvatarPackager::openAvatarProject() {
|
||||
// TODO: use QML file browser here, could handle this on QML side instead
|
||||
static Setting::Handle<QString> lastModelBrowseLocation("LastModelBrowseLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
||||
const QString filename = QFileDialog::getOpenFileName(nullptr, "Select your model file ...",
|
||||
lastModelBrowseLocation.get(),
|
||||
"Model files (*.fst *.fbx)");
|
||||
QFileInfo fileInfo(filename);
|
||||
|
||||
if (fileInfo.isFile() && fileInfo.completeSuffix().contains(QRegExp("fst|fbx|FST|FBX"))) {
|
||||
return AvatarProject::openAvatarProject(fileInfo.absoluteFilePath());
|
||||
QObject* AvatarPackager::openAvatarProject(QString avatarProjectFSTPath) {
|
||||
if (_currentAvatarProject) {
|
||||
_currentAvatarProject->deleteLater();
|
||||
}
|
||||
return nullptr;
|
||||
_currentAvatarProject = AvatarProject::openAvatarProject(avatarProjectFSTPath);
|
||||
return _currentAvatarProject;
|
||||
}
|
||||
|
|
|
@ -21,15 +21,16 @@
|
|||
class AvatarPackager : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
Q_PROPERTY(QObject* currentAvatarProject READ getAvatarProject)
|
||||
|
||||
public:
|
||||
bool open();
|
||||
|
||||
Q_INVOKABLE void openAvatarProjectWithoutReturnType() {
|
||||
openAvatarProject();
|
||||
}
|
||||
Q_INVOKABLE QObject* openAvatarProject(QString avatarProjectFSTPath);
|
||||
|
||||
Q_INVOKABLE QObject* openAvatarProject();
|
||||
private:
|
||||
Q_INVOKABLE AvatarProject* getAvatarProject() const { return _currentAvatarProject; };
|
||||
AvatarProject* _currentAvatarProject { nullptr };
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarPackager_h
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// AvatarProject.h
|
||||
// AvatarProject.cpp
|
||||
//
|
||||
//
|
||||
// Created by Thijs Wenker on 12/7/2018
|
||||
|
|
|
@ -14,8 +14,15 @@
|
|||
#define hifi_AvatarProject_h
|
||||
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
class AvatarProject : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString projectFolderPath READ getProjectPath)
|
||||
Q_PROPERTY(QString projectFSTPath READ getFSTPath)
|
||||
Q_PROPERTY(QString projectFBXPath READ getFBXPath)
|
||||
|
||||
public:
|
||||
Q_INVOKABLE bool write() {
|
||||
// Write FST here
|
||||
|
@ -33,13 +40,28 @@ public:
|
|||
static AvatarProject* openAvatarProject(QString path);
|
||||
|
||||
private:
|
||||
AvatarProject(QString fstPath) {
|
||||
|
||||
AvatarProject(QString fstPath) :
|
||||
_fstPath(fstPath) {
|
||||
auto fileInfo = QFileInfo(_fstPath);
|
||||
_projectPath = fileInfo.absoluteDir().absolutePath();
|
||||
|
||||
_fstPath = _projectPath + "TemporaryFBX.fbx";
|
||||
|
||||
}
|
||||
|
||||
~AvatarProject() {
|
||||
// TODO: cleanup FST / AvatarProjectUploader etc.
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString getProjectPath() const { return _projectPath; }
|
||||
Q_INVOKABLE QString getFSTPath() const { return _fstPath; }
|
||||
Q_INVOKABLE QString getFBXPath() const { return _fbxPath; }
|
||||
|
||||
QString _projectPath;
|
||||
QString _fstPath;
|
||||
// TODO: handle this in the FST Class
|
||||
QString _fbxPath;
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarProject_h
|
||||
|
|
Loading…
Reference in a new issue