mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Reimplement asset browsing for async
This commit is contained in:
parent
e9ed05c3ba
commit
51a5c30353
3 changed files with 28 additions and 14 deletions
|
@ -247,8 +247,7 @@ QScriptValue WindowScriptingInterface::save(const QString& title, const QString&
|
||||||
/// \param const QString& title title of the window
|
/// \param const QString& title title of the window
|
||||||
/// \param const QString& directory directory to start the asset browser at
|
/// \param const QString& directory directory to start the asset browser at
|
||||||
/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`
|
/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`
|
||||||
/// \return QScriptValue asset path as a string if one was selected, otherwise `QScriptValue::NullValue`
|
void WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||||
QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
|
|
||||||
ensureReticleVisible();
|
ensureReticleVisible();
|
||||||
QString path = directory;
|
QString path = directory;
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
@ -260,11 +259,20 @@ QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const
|
||||||
if (path.right(1) != "/") {
|
if (path.right(1) != "/") {
|
||||||
path = path + "/";
|
path = path + "/";
|
||||||
}
|
}
|
||||||
QString result = OffscreenUi::getOpenAssetName(nullptr, title, path, nameFilter);
|
|
||||||
if (!result.isEmpty()) {
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath());
|
connect(offscreenUi.data(), &OffscreenUi::assetDialogResponse,
|
||||||
}
|
this, [=] (QString result) {
|
||||||
return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
disconnect(offscreenUi.data(), &OffscreenUi::assetDialogResponse,
|
||||||
|
this, nullptr);
|
||||||
|
if (!result.isEmpty()) {
|
||||||
|
setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath());
|
||||||
|
}
|
||||||
|
emit assetsDirChanged(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
OffscreenUi::getOpenAssetNameAsync(nullptr, title, path, nameFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::showAssetServer(const QString& upload) {
|
void WindowScriptingInterface::showAssetServer(const QString& upload) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public slots:
|
||||||
void browseDir(const QString& title = "", const QString& directory = "");
|
void browseDir(const QString& title = "", const QString& directory = "");
|
||||||
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
QScriptValue browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
void browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
void showAssetServer(const QString& upload = "");
|
void showAssetServer(const QString& upload = "");
|
||||||
void copyToClipboard(const QString& text);
|
void copyToClipboard(const QString& text);
|
||||||
void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f);
|
void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f);
|
||||||
|
@ -88,6 +88,7 @@ signals:
|
||||||
|
|
||||||
void messageBoxClosed(int id, int button);
|
void messageBoxClosed(int id, int button);
|
||||||
void browseDirChanged(QString browseDir);
|
void browseDirChanged(QString browseDir);
|
||||||
|
void assetsDirChanged(QString assetsDir);
|
||||||
// triggered when window size or position changes
|
// triggered when window size or position changes
|
||||||
void geometryChanged(QRect geometry);
|
void geometryChanged(QRect geometry);
|
||||||
|
|
||||||
|
|
|
@ -486,6 +486,15 @@
|
||||||
return isFinishOnOpen;
|
return isFinishOnOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onAssetsDirChanged(recording) {
|
||||||
|
Window.assetsDirChanged.disconnect(onAssetsDirChanged);
|
||||||
|
if (recording !== "") {
|
||||||
|
log("Load recording " + recording);
|
||||||
|
UserActivityLogger.logAction("record_load_recording", logDetails());
|
||||||
|
Player.playRecording("atp:" + recording, MyAvatar.position, MyAvatar.orientation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onWebEventReceived(data) {
|
function onWebEventReceived(data) {
|
||||||
var message,
|
var message,
|
||||||
recording;
|
recording;
|
||||||
|
@ -520,12 +529,8 @@
|
||||||
break;
|
break;
|
||||||
case LOAD_RECORDING_ACTION:
|
case LOAD_RECORDING_ACTION:
|
||||||
// User wants to select an ATP recording to play.
|
// User wants to select an ATP recording to play.
|
||||||
recording = Window.browseAssets("Select Recording to Play", "recordings", "*.hfr");
|
Window.assetsDirChanged.connect(onAssetsDirChanged);
|
||||||
if (recording) {
|
Window.browseAssets("Select Recording to Play", "recordings", "*.hfr");
|
||||||
log("Load recording " + recording);
|
|
||||||
UserActivityLogger.logAction("record_load_recording", logDetails());
|
|
||||||
Player.playRecording("atp:" + recording, MyAvatar.position, MyAvatar.orientation);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case START_RECORDING_ACTION:
|
case START_RECORDING_ACTION:
|
||||||
// Start making a recording.
|
// Start making a recording.
|
||||||
|
|
Loading…
Reference in a new issue