mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:02:58 +02:00
Merge pull request #11425 from Atlante45/feat/auto-bake
Asset Browser auto-refresh
This commit is contained in:
commit
883bdc6003
4 changed files with 47 additions and 27 deletions
|
@ -49,9 +49,14 @@ ScrollingWindow {
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
ApplicationInterface.uploadRequest.connect(uploadClicked);
|
ApplicationInterface.uploadRequest.connect(uploadClicked);
|
||||||
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
||||||
|
assetMappingsModel.autoRefreshEnabled = true;
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
assetMappingsModel.autoRefreshEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
function doDeleteFile(path) {
|
function doDeleteFile(path) {
|
||||||
console.log("Deleting " + path);
|
console.log("Deleting " + path);
|
||||||
|
@ -146,7 +151,6 @@ ScrollingWindow {
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
Assets.mappingModel.refresh();
|
Assets.mappingModel.refresh();
|
||||||
treeView.selection.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleGetMappingsError(errorString) {
|
function handleGetMappingsError(errorString) {
|
||||||
|
@ -502,16 +506,6 @@ ScrollingWindow {
|
||||||
onClicked: root.deleteFile()
|
onClicked: root.deleteFile()
|
||||||
enabled: treeView.selection.hasSelection
|
enabled: treeView.selection.hasSelection
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.GlyphButton {
|
|
||||||
|
|
||||||
glyph: hifi.glyphs.reload
|
|
||||||
color: hifi.buttons.black
|
|
||||||
colorScheme: root.colorScheme
|
|
||||||
width: hifi.dimensions.controlLineHeight
|
|
||||||
|
|
||||||
onClicked: root.reload()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,7 +745,7 @@ ScrollingWindow {
|
||||||
var path = assetProxyModel.data(index, 0x100);
|
var path = assetProxyModel.data(index, 0x100);
|
||||||
mappings.push(path);
|
mappings.push(path);
|
||||||
}
|
}
|
||||||
print("Setting baking enabled:" + mappings + checked);
|
print("Setting baking enabled:" + mappings + " " + checked);
|
||||||
Assets.setBakingEnabled(mappings, checked, function() {
|
Assets.setBakingEnabled(mappings, checked, function() {
|
||||||
reload();
|
reload();
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,9 +49,15 @@ Rectangle {
|
||||||
isHMD = HMD.active;
|
isHMD = HMD.active;
|
||||||
ApplicationInterface.uploadRequest.connect(uploadClicked);
|
ApplicationInterface.uploadRequest.connect(uploadClicked);
|
||||||
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
||||||
|
assetMappingsModel.autoRefreshEnabled = true;
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
assetMappingsModel.autoRefreshEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
function doDeleteFile(path) {
|
function doDeleteFile(path) {
|
||||||
console.log("Deleting " + path);
|
console.log("Deleting " + path);
|
||||||
|
|
||||||
|
@ -145,7 +151,6 @@ Rectangle {
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
Assets.mappingModel.refresh();
|
Assets.mappingModel.refresh();
|
||||||
treeView.selection.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleGetMappingsError(errorString) {
|
function handleGetMappingsError(errorString) {
|
||||||
|
@ -502,16 +507,6 @@ Rectangle {
|
||||||
onClicked: root.deleteFile()
|
onClicked: root.deleteFile()
|
||||||
enabled: treeView.selection.hasSelection
|
enabled: treeView.selection.hasSelection
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.GlyphButton {
|
|
||||||
|
|
||||||
glyph: hifi.glyphs.reload
|
|
||||||
color: hifi.buttons.black
|
|
||||||
colorScheme: root.colorScheme
|
|
||||||
width: hifi.dimensions.controlLineHeight
|
|
||||||
|
|
||||||
onClicked: root.reload()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,7 +743,7 @@ Rectangle {
|
||||||
var path = assetProxyModel.data(index, 0x100);
|
var path = assetProxyModel.data(index, 0x100);
|
||||||
mappings.push(path);
|
mappings.push(path);
|
||||||
}
|
}
|
||||||
print("Setting baking enabled:" + mappings + checked);
|
print("Setting baking enabled:" + mappings + " " + checked);
|
||||||
Assets.setBakingEnabled(mappings, checked, function() {
|
Assets.setBakingEnabled(mappings, checked, function() {
|
||||||
reload();
|
reload();
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,8 +19,13 @@
|
||||||
#include <AssetUpload.h>
|
#include <AssetUpload.h>
|
||||||
#include <MappingRequest.h>
|
#include <MappingRequest.h>
|
||||||
#include <NetworkLogging.h>
|
#include <NetworkLogging.h>
|
||||||
|
#include <NodeList.h>
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
|
|
||||||
|
static const int AUTO_REFRESH_INTERVAL = 1000;
|
||||||
|
|
||||||
|
int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
|
||||||
|
|
||||||
AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() {
|
AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() {
|
||||||
_proxyModel.setSourceModel(&_assetMappingModel);
|
_proxyModel.setSourceModel(&_assetMappingModel);
|
||||||
_proxyModel.setSortRole(Qt::DisplayRole);
|
_proxyModel.setSortRole(Qt::DisplayRole);
|
||||||
|
@ -189,6 +194,29 @@ void AssetMappingsScriptingInterface::setBakingEnabled(QStringList paths, bool e
|
||||||
|
|
||||||
AssetMappingModel::AssetMappingModel() {
|
AssetMappingModel::AssetMappingModel() {
|
||||||
setupRoles();
|
setupRoles();
|
||||||
|
|
||||||
|
connect(&_autoRefreshTimer, &QTimer::timeout, this, [this] {
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
auto assetServer = nodeList->soloNodeOfType(NodeType::AssetServer);
|
||||||
|
if (assetServer) {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_autoRefreshTimer.setInterval(AUTO_REFRESH_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AssetMappingModel::isAutoRefreshEnabled() {
|
||||||
|
return _autoRefreshTimer.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetMappingModel::setAutoRefreshEnabled(bool enabled) {
|
||||||
|
if (enabled != _autoRefreshTimer.isActive()) {
|
||||||
|
if (enabled) {
|
||||||
|
_autoRefreshTimer.start();
|
||||||
|
} else {
|
||||||
|
_autoRefreshTimer.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssetMappingModel::isKnownFolder(QString path) const {
|
bool AssetMappingModel::isKnownFolder(QString path) const {
|
||||||
|
@ -205,10 +233,7 @@ bool AssetMappingModel::isKnownFolder(QString path) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
|
|
||||||
|
|
||||||
void AssetMappingModel::refresh() {
|
void AssetMappingModel::refresh() {
|
||||||
qDebug() << "Refreshing asset mapping model";
|
|
||||||
auto assetClient = DependencyManager::get<AssetClient>();
|
auto assetClient = DependencyManager::get<AssetClient>();
|
||||||
auto request = assetClient->createGetAllMappingsRequest();
|
auto request = assetClient->createGetAllMappingsRequest();
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,16 @@
|
||||||
|
|
||||||
class AssetMappingModel : public QStandardItemModel {
|
class AssetMappingModel : public QStandardItemModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool autoRefreshEnabled READ isAutoRefreshEnabled WRITE setAutoRefreshEnabled)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AssetMappingModel();
|
AssetMappingModel();
|
||||||
|
|
||||||
Q_INVOKABLE void refresh();
|
Q_INVOKABLE void refresh();
|
||||||
|
|
||||||
|
bool isAutoRefreshEnabled();
|
||||||
|
void setAutoRefreshEnabled(bool enabled);
|
||||||
|
|
||||||
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); }
|
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); }
|
||||||
bool isKnownFolder(QString path) const;
|
bool isKnownFolder(QString path) const;
|
||||||
|
|
||||||
|
@ -44,6 +49,7 @@ private:
|
||||||
void setupRoles();
|
void setupRoles();
|
||||||
|
|
||||||
QHash<QString, QStandardItem*> _pathToItemMap;
|
QHash<QString, QStandardItem*> _pathToItemMap;
|
||||||
|
QTimer _autoRefreshTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(AssetMappingModel*)
|
Q_DECLARE_METATYPE(AssetMappingModel*)
|
||||||
|
|
Loading…
Reference in a new issue