mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 10:14:28 +02:00
Apply AvatarPackager code review cleanup
This commit is contained in:
parent
f27ee1767c
commit
c2ceeb3d76
10 changed files with 44 additions and 32 deletions
|
@ -14,25 +14,34 @@ Item {
|
||||||
property int uploaderState;
|
property int uploaderState;
|
||||||
property var uploader;
|
property var uploader;
|
||||||
|
|
||||||
|
/*
|
||||||
state: root.uploader === undefined ? "" :
|
state: root.uploader === undefined ? "" :
|
||||||
(root.uploader.state > uploaderState ? "success"
|
(root.uploader.state > uploaderState ? "success"
|
||||||
: (root.uploader.error !== 0 ? "fail" : (root.uploader.state === uploaderState ? "running" : "")))
|
: (root.uploader.error !== 0 ? "fail" : (root.uploader.state === uploaderState ? "running" : "")))
|
||||||
|
*/
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
name: "running"
|
name: ""
|
||||||
|
when: root.uploader === null
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "success"
|
||||||
|
when: root.uploader.state > uploaderState
|
||||||
PropertyChanges { target: stepText; color: "white" }
|
PropertyChanges { target: stepText; color: "white" }
|
||||||
PropertyChanges { target: runningImage; visible: true; playing: true }
|
PropertyChanges { target: successGlyph; visible: true }
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "fail"
|
name: "fail"
|
||||||
|
when: root.uploader.error !== 0
|
||||||
PropertyChanges { target: stepText; color: "#EA4C5F" }
|
PropertyChanges { target: stepText; color: "#EA4C5F" }
|
||||||
PropertyChanges { target: failGlyph; visible: true }
|
PropertyChanges { target: failGlyph; visible: true }
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "success"
|
name: "running"
|
||||||
|
when: root.uploader.state === uploaderState
|
||||||
PropertyChanges { target: stepText; color: "white" }
|
PropertyChanges { target: stepText; color: "white" }
|
||||||
PropertyChanges { target: successGlyph; visible: true }
|
PropertyChanges { target: runningImage; visible: true; playing: true }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -60,4 +60,4 @@ Item {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,4 @@ RalewaySemiBold {
|
||||||
|
|
||||||
onClicked: root.clicked()
|
onClicked: root.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ AvatarProject* AvatarProject::createAvatarProject(const QString& projectsFolder,
|
||||||
return new AvatarProject(fst);
|
return new AvatarProject(fst);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AvatarProject::getScriptPaths(const QDir& scriptsDir) {
|
QStringList AvatarProject::getScriptPaths(const QDir& scriptsDir) const {
|
||||||
QStringList result{};
|
QStringList result{};
|
||||||
constexpr auto flags = QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot | QDir::Hidden;
|
constexpr auto flags = QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot | QDir::Hidden;
|
||||||
if (!scriptsDir.exists()) {
|
if (!scriptsDir.exists()) {
|
||||||
|
@ -244,6 +244,8 @@ MarketplaceItemUploader* AvatarProject::upload(bool updateExisting) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarProject::openInInventory() {
|
void AvatarProject::openInInventory() {
|
||||||
|
constexpr int TIME_TO_WAIT_FOR_INVENTORY_TO_OPEN_MS { 1000 };
|
||||||
|
|
||||||
auto tablet = dynamic_cast<TabletProxy*>(
|
auto tablet = dynamic_cast<TabletProxy*>(
|
||||||
DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"));
|
DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
tablet->loadQMLSource("hifi/commerce/wallet/Wallet.qml");
|
tablet->loadQMLSource("hifi/commerce/wallet/Wallet.qml");
|
||||||
|
@ -251,9 +253,7 @@ void AvatarProject::openInInventory() {
|
||||||
auto name = getProjectName();
|
auto name = getProjectName();
|
||||||
|
|
||||||
// I'm not a fan of this, but it's the only current option.
|
// I'm not a fan of this, but it's the only current option.
|
||||||
QTimer::singleShot(1000, [name]() {
|
QTimer::singleShot(TIME_TO_WAIT_FOR_INVENTORY_TO_OPEN_MS, [name, tablet]() {
|
||||||
auto tablet = dynamic_cast<TabletProxy*>(
|
|
||||||
DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"));
|
|
||||||
tablet->sendToQml(QVariantMap({ { "method", "updatePurchases" }, { "filterText", name } }));
|
tablet->sendToQml(QVariantMap({ { "method", "updatePurchases" }, { "filterText", name } }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ private:
|
||||||
|
|
||||||
void refreshProjectFiles();
|
void refreshProjectFiles();
|
||||||
void appendDirectory(const QString& prefix, const QDir& dir);
|
void appendDirectory(const QString& prefix, const QDir& dir);
|
||||||
QStringList getScriptPaths(const QDir& scriptsDir);
|
QStringList getScriptPaths(const QDir& scriptsDir) const;
|
||||||
|
|
||||||
FST* _fst;
|
FST* _fst;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,10 @@ MarketplaceItemUploader::MarketplaceItemUploader(QString title,
|
||||||
QUuid marketplaceID,
|
QUuid marketplaceID,
|
||||||
QList<ProjectFilePath> filePaths) :
|
QList<ProjectFilePath> filePaths) :
|
||||||
_title(title),
|
_title(title),
|
||||||
_description(description), _rootFilename(rootFilename), _marketplaceID(marketplaceID), _filePaths(filePaths) {
|
_description(description),
|
||||||
|
_rootFilename(rootFilename),
|
||||||
|
_marketplaceID(marketplaceID),
|
||||||
|
_filePaths(filePaths) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarketplaceItemUploader::setState(State newState) {
|
void MarketplaceItemUploader::setState(State newState) {
|
||||||
|
@ -299,11 +302,13 @@ void MarketplaceItemUploader::doWaitForInventory() {
|
||||||
if (success) {
|
if (success) {
|
||||||
setState(State::Complete);
|
setState(State::Complete);
|
||||||
} else {
|
} else {
|
||||||
|
constexpr int MAX_INVENTORY_REQUESTS { 8 };
|
||||||
|
constexpr int TIME_BETWEEN_INVENTORY_REQUESTS_MS { 5000 };
|
||||||
qDebug() << "Failed to find item in inventory";
|
qDebug() << "Failed to find item in inventory";
|
||||||
if (_numRequestsForInventory > 8) {
|
if (_numRequestsForInventory > MAX_INVENTORY_REQUESTS) {
|
||||||
setError(Error::Unknown);
|
setError(Error::Unknown);
|
||||||
} else {
|
} else {
|
||||||
QTimer::singleShot(5000, [this]() { doWaitForInventory(); });
|
QTimer::singleShot(TIME_BETWEEN_INVENTORY_REQUESTS_MS, [this]() { doWaitForInventory(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,21 +30,19 @@ class MarketplaceItemUploader : public QObject {
|
||||||
Q_PROPERTY(Error error READ getError NOTIFY errorChanged)
|
Q_PROPERTY(Error error READ getError NOTIFY errorChanged)
|
||||||
Q_PROPERTY(QString responseData READ getResponseData)
|
Q_PROPERTY(QString responseData READ getResponseData)
|
||||||
public:
|
public:
|
||||||
enum class Error
|
enum class Error {
|
||||||
{
|
|
||||||
None,
|
None,
|
||||||
Unknown
|
Unknown,
|
||||||
};
|
};
|
||||||
Q_ENUM(Error);
|
Q_ENUM(Error);
|
||||||
|
|
||||||
enum class State
|
enum class State {
|
||||||
{
|
|
||||||
Idle,
|
Idle,
|
||||||
GettingCategories,
|
GettingCategories,
|
||||||
UploadingAvatar,
|
UploadingAvatar,
|
||||||
WaitingForUploadResponse,
|
WaitingForUploadResponse,
|
||||||
WaitingForInventory,
|
WaitingForInventory,
|
||||||
Complete
|
Complete,
|
||||||
};
|
};
|
||||||
Q_ENUM(State);
|
Q_ENUM(State);
|
||||||
|
|
||||||
|
@ -63,7 +61,6 @@ public:
|
||||||
State getState() const { return _state; }
|
State getState() const { return _state; }
|
||||||
bool getComplete() const { return _state == State::Complete; }
|
bool getComplete() const { return _state == State::Complete; }
|
||||||
|
|
||||||
|
|
||||||
QUuid getMarketplaceID() const { return _marketplaceID; }
|
QUuid getMarketplaceID() const { return _marketplaceID; }
|
||||||
|
|
||||||
Error getError() const { return _error; }
|
Error getError() const { return _error; }
|
||||||
|
@ -86,8 +83,8 @@ private:
|
||||||
|
|
||||||
QNetworkReply* _reply;
|
QNetworkReply* _reply;
|
||||||
|
|
||||||
State _state{ State::Idle };
|
State _state { State::Idle };
|
||||||
Error _error{ Error::None };
|
Error _error { Error::None };
|
||||||
|
|
||||||
QString _title;
|
QString _title;
|
||||||
QString _description;
|
QString _description;
|
||||||
|
@ -98,7 +95,7 @@ private:
|
||||||
|
|
||||||
QString _responseData;
|
QString _responseData;
|
||||||
|
|
||||||
int _numRequestsForInventory{ 0 };
|
int _numRequestsForInventory { 0 };
|
||||||
|
|
||||||
QString _rootFilePath;
|
QString _rootFilePath;
|
||||||
QList<ProjectFilePath> _filePaths;
|
QList<ProjectFilePath> _filePaths;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <hfm/HFM.h>
|
#include <hfm/HFM.h>
|
||||||
|
|
||||||
|
constexpr float DEFAULT_SCALE { 1.0f };
|
||||||
|
|
||||||
FST::FST(QString fstPath, QVariantHash data) : _fstPath(std::move(fstPath)) {
|
FST::FST(QString fstPath, QVariantHash data) : _fstPath(std::move(fstPath)) {
|
||||||
|
|
||||||
auto setValueFromFSTData = [&data] (const QString& propertyID, auto &targetProperty) mutable {
|
auto setValueFromFSTData = [&data] (const QString& propertyID, auto &targetProperty) mutable {
|
||||||
|
@ -55,7 +57,7 @@ FST* FST::createFSTFromModel(const QString& fstPath, const QString& modelFilePat
|
||||||
mapping.insert(TEXDIR_FIELD, "textures");
|
mapping.insert(TEXDIR_FIELD, "textures");
|
||||||
|
|
||||||
// mixamo/autodesk defaults
|
// mixamo/autodesk defaults
|
||||||
mapping.insert(SCALE_FIELD, 1.0);
|
mapping.insert(SCALE_FIELD, DEFAULT_SCALE);
|
||||||
QVariantHash joints = mapping.value(JOINT_FIELD).toHash();
|
QVariantHash joints = mapping.value(JOINT_FIELD).toHash();
|
||||||
joints.insert("jointEyeLeft", hfmModel.jointIndices.contains("jointEyeLeft") ? "jointEyeLeft" :
|
joints.insert("jointEyeLeft", hfmModel.jointIndices.contains("jointEyeLeft") ? "jointEyeLeft" :
|
||||||
(hfmModel.jointIndices.contains("EyeLeft") ? "EyeLeft" : "LeftEye"));
|
(hfmModel.jointIndices.contains("EyeLeft") ? "EyeLeft" : "LeftEye"));
|
||||||
|
@ -161,7 +163,7 @@ void FST::setModelPath(const QString& modelPath) {
|
||||||
emit modelPathChanged(modelPath);
|
emit modelPathChanged(modelPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantHash FST::getMapping() {
|
QVariantHash FST::getMapping() const {
|
||||||
QVariantHash mapping;
|
QVariantHash mapping;
|
||||||
mapping.unite(_other);
|
mapping.unite(_other);
|
||||||
mapping.insert(NAME_FIELD, _name);
|
mapping.insert(NAME_FIELD, _name);
|
||||||
|
|
|
@ -45,9 +45,9 @@ public:
|
||||||
QStringList getScriptPaths() const { return _scriptPaths; }
|
QStringList getScriptPaths() const { return _scriptPaths; }
|
||||||
void setScriptPaths(QStringList scriptPaths) { _scriptPaths = scriptPaths; }
|
void setScriptPaths(QStringList scriptPaths) { _scriptPaths = scriptPaths; }
|
||||||
|
|
||||||
QString getPath() { return _fstPath; }
|
QString getPath() const { return _fstPath; }
|
||||||
|
|
||||||
QVariantHash getMapping();
|
QVariantHash getMapping() const;
|
||||||
|
|
||||||
bool write();
|
bool write();
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace AccountManagerAuth {
|
namespace AccountManagerAuth {
|
||||||
enum Type
|
enum Type {
|
||||||
{
|
|
||||||
None,
|
None,
|
||||||
Required,
|
Required,
|
||||||
Optional
|
Optional,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ private:
|
||||||
bool _isWaitingForTokenRefresh{ false };
|
bool _isWaitingForTokenRefresh{ false };
|
||||||
bool _isAgent{ false };
|
bool _isAgent{ false };
|
||||||
|
|
||||||
bool _isWaitingForKeypairResponse{ false };
|
bool _isWaitingForKeypairResponse { false };
|
||||||
QByteArray _pendingPrivateKey;
|
QByteArray _pendingPrivateKey;
|
||||||
|
|
||||||
QUuid _sessionID{ QUuid::createUuid() };
|
QUuid _sessionID{ QUuid::createUuid() };
|
||||||
|
|
Loading…
Reference in a new issue