mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-07 08:33:38 +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& directory directory to start the asset browser at
|
||||
/// \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`
|
||||
QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||
void WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||
ensureReticleVisible();
|
||||
QString path = directory;
|
||||
if (path.isEmpty()) {
|
||||
|
@ -260,11 +259,20 @@ QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const
|
|||
if (path.right(1) != "/") {
|
||||
path = path + "/";
|
||||
}
|
||||
QString result = OffscreenUi::getOpenAssetName(nullptr, title, path, nameFilter);
|
||||
if (!result.isEmpty()) {
|
||||
setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath());
|
||||
}
|
||||
return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
|
||||
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
connect(offscreenUi.data(), &OffscreenUi::assetDialogResponse,
|
||||
this, [=] (QString 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) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public slots:
|
|||
void browseDir(const QString& title = "", const QString& directory = "");
|
||||
QScriptValue browse(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 copyToClipboard(const QString& text);
|
||||
void takeSnapshot(bool notify = true, bool includeAnimated = false, float aspectRatio = 0.0f);
|
||||
|
@ -88,6 +88,7 @@ signals:
|
|||
|
||||
void messageBoxClosed(int id, int button);
|
||||
void browseDirChanged(QString browseDir);
|
||||
void assetsDirChanged(QString assetsDir);
|
||||
// triggered when window size or position changes
|
||||
void geometryChanged(QRect geometry);
|
||||
|
||||
|
|
|
@ -486,6 +486,15 @@
|
|||
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) {
|
||||
var message,
|
||||
recording;
|
||||
|
@ -520,12 +529,8 @@
|
|||
break;
|
||||
case LOAD_RECORDING_ACTION:
|
||||
// User wants to select an ATP recording to play.
|
||||
recording = Window.browseAssets("Select Recording to Play", "recordings", "*.hfr");
|
||||
if (recording) {
|
||||
log("Load recording " + recording);
|
||||
UserActivityLogger.logAction("record_load_recording", logDetails());
|
||||
Player.playRecording("atp:" + recording, MyAvatar.position, MyAvatar.orientation);
|
||||
}
|
||||
Window.assetsDirChanged.connect(onAssetsDirChanged);
|
||||
Window.browseAssets("Select Recording to Play", "recordings", "*.hfr");
|
||||
break;
|
||||
case START_RECORDING_ACTION:
|
||||
// Start making a recording.
|
||||
|
|
Loading…
Reference in a new issue