mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 16:43:24 +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
interface
resources/qml
src/scripting
|
@ -49,9 +49,14 @@ ScrollingWindow {
|
|||
Component.onCompleted: {
|
||||
ApplicationInterface.uploadRequest.connect(uploadClicked);
|
||||
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
||||
assetMappingsModel.autoRefreshEnabled = true;
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
assetMappingsModel.autoRefreshEnabled = false;
|
||||
}
|
||||
|
||||
function doDeleteFile(path) {
|
||||
console.log("Deleting " + path);
|
||||
|
@ -146,7 +151,6 @@ ScrollingWindow {
|
|||
|
||||
function reload() {
|
||||
Assets.mappingModel.refresh();
|
||||
treeView.selection.clear();
|
||||
}
|
||||
|
||||
function handleGetMappingsError(errorString) {
|
||||
|
@ -502,16 +506,6 @@ ScrollingWindow {
|
|||
onClicked: root.deleteFile()
|
||||
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);
|
||||
mappings.push(path);
|
||||
}
|
||||
print("Setting baking enabled:" + mappings + checked);
|
||||
print("Setting baking enabled:" + mappings + " " + checked);
|
||||
Assets.setBakingEnabled(mappings, checked, function() {
|
||||
reload();
|
||||
});
|
||||
|
|
|
@ -49,9 +49,15 @@ Rectangle {
|
|||
isHMD = HMD.active;
|
||||
ApplicationInterface.uploadRequest.connect(uploadClicked);
|
||||
assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError);
|
||||
assetMappingsModel.autoRefreshEnabled = true;
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
assetMappingsModel.autoRefreshEnabled = false;
|
||||
}
|
||||
|
||||
function doDeleteFile(path) {
|
||||
console.log("Deleting " + path);
|
||||
|
||||
|
@ -145,7 +151,6 @@ Rectangle {
|
|||
|
||||
function reload() {
|
||||
Assets.mappingModel.refresh();
|
||||
treeView.selection.clear();
|
||||
}
|
||||
|
||||
function handleGetMappingsError(errorString) {
|
||||
|
@ -502,16 +507,6 @@ Rectangle {
|
|||
onClicked: root.deleteFile()
|
||||
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);
|
||||
mappings.push(path);
|
||||
}
|
||||
print("Setting baking enabled:" + mappings + checked);
|
||||
print("Setting baking enabled:" + mappings + " " + checked);
|
||||
Assets.setBakingEnabled(mappings, checked, function() {
|
||||
reload();
|
||||
});
|
||||
|
|
|
@ -19,8 +19,13 @@
|
|||
#include <AssetUpload.h>
|
||||
#include <MappingRequest.h>
|
||||
#include <NetworkLogging.h>
|
||||
#include <NodeList.h>
|
||||
#include <OffscreenUi.h>
|
||||
|
||||
static const int AUTO_REFRESH_INTERVAL = 1000;
|
||||
|
||||
int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
|
||||
|
||||
AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() {
|
||||
_proxyModel.setSourceModel(&_assetMappingModel);
|
||||
_proxyModel.setSortRole(Qt::DisplayRole);
|
||||
|
@ -189,6 +194,29 @@ void AssetMappingsScriptingInterface::setBakingEnabled(QStringList paths, bool e
|
|||
|
||||
AssetMappingModel::AssetMappingModel() {
|
||||
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 {
|
||||
|
@ -205,10 +233,7 @@ bool AssetMappingModel::isKnownFolder(QString path) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*");
|
||||
|
||||
void AssetMappingModel::refresh() {
|
||||
qDebug() << "Refreshing asset mapping model";
|
||||
auto assetClient = DependencyManager::get<AssetClient>();
|
||||
auto request = assetClient->createGetAllMappingsRequest();
|
||||
|
||||
|
|
|
@ -25,11 +25,16 @@
|
|||
|
||||
class AssetMappingModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool autoRefreshEnabled READ isAutoRefreshEnabled WRITE setAutoRefreshEnabled)
|
||||
|
||||
public:
|
||||
AssetMappingModel();
|
||||
|
||||
Q_INVOKABLE void refresh();
|
||||
|
||||
bool isAutoRefreshEnabled();
|
||||
void setAutoRefreshEnabled(bool enabled);
|
||||
|
||||
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); }
|
||||
bool isKnownFolder(QString path) const;
|
||||
|
||||
|
@ -44,6 +49,7 @@ private:
|
|||
void setupRoles();
|
||||
|
||||
QHash<QString, QStandardItem*> _pathToItemMap;
|
||||
QTimer _autoRefreshTimer;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(AssetMappingModel*)
|
||||
|
|
Loading…
Reference in a new issue