mirror of
https://github.com/overte-org/overte.git
synced 2025-06-16 09:00:28 +02:00
Keep old function names for compatibility
This commit is contained in:
parent
4e5c650621
commit
15f8bc0141
6 changed files with 121 additions and 17 deletions
|
@ -116,7 +116,17 @@ QScriptValue WindowScriptingInterface::confirm(const QString& message) {
|
||||||
/// Display a prompt with a text box
|
/// Display a prompt with a text box
|
||||||
/// \param const QString& message message to display
|
/// \param const QString& message message to display
|
||||||
/// \param const QString& defaultText default text in the text box
|
/// \param const QString& defaultText default text in the text box
|
||||||
void WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
|
/// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise.
|
||||||
|
QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
|
||||||
|
bool ok = false;
|
||||||
|
QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText, &ok);
|
||||||
|
return ok ? QScriptValue(result) : QScriptValue::NullValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Display a prompt with a text box
|
||||||
|
/// \param const QString& message message to display
|
||||||
|
/// \param const QString& defaultText default text in the text box
|
||||||
|
void WindowScriptingInterface::promptAsync(const QString& message, const QString& defaultText) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse,
|
connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse,
|
||||||
this, [=] (QVariant result) {
|
this, [=] (QVariant result) {
|
||||||
|
@ -180,7 +190,29 @@ void WindowScriptingInterface::ensureReticleVisible() const {
|
||||||
/// \param const QString& title title of the window
|
/// \param const QString& title title of the window
|
||||||
/// \param const QString& directory directory to start the file browser at
|
/// \param const QString& directory directory to start the file browser at
|
||||||
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
||||||
void WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {
|
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
|
||||||
|
QScriptValue WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {
|
||||||
|
ensureReticleVisible();
|
||||||
|
QString path = directory;
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
path = getPreviousBrowseLocation();
|
||||||
|
}
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
path = fixupPathForMac(directory);
|
||||||
|
#endif
|
||||||
|
QString result = OffscreenUi::getExistingDirectory(nullptr, title, path);
|
||||||
|
if (!result.isEmpty()) {
|
||||||
|
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
|
||||||
|
}
|
||||||
|
return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Display a "browse to directory" dialog. If `directory` is an invalid file or directory the browser will start at the current
|
||||||
|
/// working directory.
|
||||||
|
/// \param const QString& title title of the window
|
||||||
|
/// \param const QString& directory directory to start the file browser at
|
||||||
|
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
||||||
|
void WindowScriptingInterface::browseDirAsync(const QString& title, const QString& directory) {
|
||||||
ensureReticleVisible();
|
ensureReticleVisible();
|
||||||
QString path = directory;
|
QString path = directory;
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
@ -204,12 +236,32 @@ void WindowScriptingInterface::browseDir(const QString& title, const QString& di
|
||||||
OffscreenUi::getExistingDirectoryAsync(nullptr, title, path);
|
OffscreenUi::getExistingDirectoryAsync(nullptr, title, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \param const QString& title title of the window
|
||||||
|
/// \param const QString& directory directory to start the file browser at
|
||||||
|
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
||||||
|
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
|
||||||
|
QScriptValue WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||||
|
ensureReticleVisible();
|
||||||
|
QString path = directory;
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
path = getPreviousBrowseLocation();
|
||||||
|
}
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
path = fixupPathForMac(directory);
|
||||||
|
#endif
|
||||||
|
QString result = OffscreenUi::getOpenFileName(nullptr, title, path, nameFilter);
|
||||||
|
if (!result.isEmpty()) {
|
||||||
|
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
|
||||||
|
}
|
||||||
|
return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
|
||||||
|
}
|
||||||
|
|
||||||
/// Display an open file dialog. If `directory` is an invalid file or directory the browser will start at the current
|
/// Display an open file dialog. If `directory` is an invalid file or directory the browser will start at the current
|
||||||
/// working directory.
|
/// working directory.
|
||||||
/// \param const QString& title title of the window
|
/// \param const QString& title title of the window
|
||||||
/// \param const QString& directory directory to start the file browser at
|
/// \param const QString& directory directory to start the file browser at
|
||||||
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
||||||
void WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) {
|
void WindowScriptingInterface::browseAsync(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||||
ensureReticleVisible();
|
ensureReticleVisible();
|
||||||
QString path = directory;
|
QString path = directory;
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
@ -238,7 +290,29 @@ void WindowScriptingInterface::browse(const QString& title, const QString& direc
|
||||||
/// \param const QString& title title of the window
|
/// \param const QString& title title of the window
|
||||||
/// \param const QString& directory directory to start the file browser at
|
/// \param const QString& directory directory to start the file browser at
|
||||||
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
||||||
void WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) {
|
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
|
||||||
|
QScriptValue WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||||
|
ensureReticleVisible();
|
||||||
|
QString path = directory;
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
path = getPreviousBrowseLocation();
|
||||||
|
}
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
path = fixupPathForMac(directory);
|
||||||
|
#endif
|
||||||
|
QString result = OffscreenUi::getSaveFileName(nullptr, title, path, nameFilter);
|
||||||
|
if (!result.isEmpty()) {
|
||||||
|
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
|
||||||
|
}
|
||||||
|
return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Display a save file dialog. If `directory` is an invalid file or directory the browser will start at the current
|
||||||
|
/// working directory.
|
||||||
|
/// \param const QString& title title of the window
|
||||||
|
/// \param const QString& directory directory to start the file browser at
|
||||||
|
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
|
||||||
|
void WindowScriptingInterface::saveAsync(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||||
ensureReticleVisible();
|
ensureReticleVisible();
|
||||||
QString path = directory;
|
QString path = directory;
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
@ -267,7 +341,32 @@ void WindowScriptingInterface::save(const QString& title, const QString& directo
|
||||||
/// \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`
|
||||||
void WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
|
/// \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) {
|
||||||
|
ensureReticleVisible();
|
||||||
|
QString path = directory;
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
path = getPreviousBrowseAssetLocation();
|
||||||
|
}
|
||||||
|
if (path.left(1) != "/") {
|
||||||
|
path = "/" + path;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid
|
||||||
|
/// directory the browser will start at the root directory.
|
||||||
|
/// \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`
|
||||||
|
void WindowScriptingInterface::browseAssetsAsync(const QString& title, const QString& directory, const QString& nameFilter) {
|
||||||
ensureReticleVisible();
|
ensureReticleVisible();
|
||||||
QString path = directory;
|
QString path = directory;
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
|
|
@ -51,12 +51,17 @@ public slots:
|
||||||
void raiseMainWindow();
|
void raiseMainWindow();
|
||||||
void alert(const QString& message = "");
|
void alert(const QString& message = "");
|
||||||
QScriptValue confirm(const QString& message = "");
|
QScriptValue confirm(const QString& message = "");
|
||||||
void prompt(const QString& message = "", const QString& defaultText = "");
|
QScriptValue prompt(const QString& message, const QString& defaultText);
|
||||||
|
void promptAsync(const QString& message = "", const QString& defaultText = "");
|
||||||
CustomPromptResult customPrompt(const QVariant& config);
|
CustomPromptResult customPrompt(const QVariant& config);
|
||||||
void browseDir(const QString& title = "", const QString& directory = "");
|
QScriptValue browseDir(const QString& title = "", const QString& directory = "");
|
||||||
void browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
void browseDirAsync(const QString& title = "", const QString& directory = "");
|
||||||
void save(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
void browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
void browseAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
|
QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
|
void saveAsync(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
|
QScriptValue browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
|
void browseAssetsAsync(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);
|
||||||
|
|
|
@ -432,7 +432,7 @@ var toolBar = (function () {
|
||||||
|
|
||||||
addButton("importEntitiesButton", "assets-01.svg", function() {
|
addButton("importEntitiesButton", "assets-01.svg", function() {
|
||||||
Window.openFileChanged.connect(onFileOpenChanged);
|
Window.openFileChanged.connect(onFileOpenChanged);
|
||||||
Window.browse("Select Model to Import", "", "*.json");
|
Window.browseAsync("Select Model to Import", "", "*.json");
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("openAssetBrowserButton", "assets-01.svg", function() {
|
addButton("openAssetBrowserButton", "assets-01.svg", function() {
|
||||||
|
@ -1501,15 +1501,15 @@ function handeMenuEvent(menuItem) {
|
||||||
Window.notifyEditError("No entities have been selected.");
|
Window.notifyEditError("No entities have been selected.");
|
||||||
} else {
|
} else {
|
||||||
Window.saveFileChanged.connect(onFileSaveChanged);
|
Window.saveFileChanged.connect(onFileSaveChanged);
|
||||||
Window.save("Select Where to Save", "", "*.json");
|
Window.saveAsync("Select Where to Save", "", "*.json");
|
||||||
}
|
}
|
||||||
} else if (menuItem === "Import Entities" || menuItem === "Import Entities from URL") {
|
} else if (menuItem === "Import Entities" || menuItem === "Import Entities from URL") {
|
||||||
if (menuItem === "Import Entities") {
|
if (menuItem === "Import Entities") {
|
||||||
Window.openFileChanged.connect(onFileOpenChanged);
|
Window.openFileChanged.connect(onFileOpenChanged);
|
||||||
Window.browse("Select Model to Import", "", "*.json");
|
Window.browseAsync("Select Model to Import", "", "*.json");
|
||||||
} else {
|
} else {
|
||||||
Window.promptTextChanged.connect(onFileOpenChanged);
|
Window.promptTextChanged.connect(onFileOpenChanged);
|
||||||
Window.prompt("URL of SVO to import", "");
|
Window.promptAsync("URL of SVO to import", "");
|
||||||
}
|
}
|
||||||
} else if (menuItem === "Entity List...") {
|
} else if (menuItem === "Entity List...") {
|
||||||
entityListTool.toggleVisible();
|
entityListTool.toggleVisible();
|
||||||
|
|
|
@ -150,7 +150,7 @@ EntityListTool = function(opts) {
|
||||||
Window.notifyEditError("No entities have been selected.");
|
Window.notifyEditError("No entities have been selected.");
|
||||||
} else {
|
} else {
|
||||||
Window.saveFileChanged.connect(onFileSaveChanged);
|
Window.saveFileChanged.connect(onFileSaveChanged);
|
||||||
Window.save("Select Where to Save", "", "*.json");
|
Window.saveAsync("Select Where to Save", "", "*.json");
|
||||||
}
|
}
|
||||||
} else if (data.type == "pal") {
|
} else if (data.type == "pal") {
|
||||||
var sessionIds = {}; // Collect the sessionsIds of all selected entitities, w/o duplicates.
|
var sessionIds = {}; // Collect the sessionsIds of all selected entitities, w/o duplicates.
|
||||||
|
|
|
@ -121,7 +121,7 @@ function onMessage(message) {
|
||||||
break;
|
break;
|
||||||
case 'chooseSnapshotLocation':
|
case 'chooseSnapshotLocation':
|
||||||
Window.browseDirChanged.connect(snapshotDirChanged);
|
Window.browseDirChanged.connect(snapshotDirChanged);
|
||||||
Window.browseDir("Choose Snapshots Directory", "", "");
|
Window.browseDirAsync("Choose Snapshots Directory", "", "");
|
||||||
break;
|
break;
|
||||||
case 'openSettings':
|
case 'openSettings':
|
||||||
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
||||||
|
|
|
@ -530,7 +530,7 @@
|
||||||
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.
|
||||||
Window.assetsDirChanged.connect(onAssetsDirChanged);
|
Window.assetsDirChanged.connect(onAssetsDirChanged);
|
||||||
Window.browseAssets("Select Recording to Play", "recordings", "*.hfr");
|
Window.browseAssetsAsync("Select Recording to Play", "recordings", "*.hfr");
|
||||||
break;
|
break;
|
||||||
case START_RECORDING_ACTION:
|
case START_RECORDING_ACTION:
|
||||||
// Start making a recording.
|
// Start making a recording.
|
||||||
|
|
Loading…
Reference in a new issue