mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:28:09 +02:00
Reimplement snapshot dir browser for async
This commit is contained in:
parent
9aace9e67d
commit
e9ed05c3ba
3 changed files with 29 additions and 18 deletions
|
@ -174,8 +174,7 @@ 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`
|
||||||
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
|
void WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {
|
||||||
QScriptValue WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {
|
|
||||||
ensureReticleVisible();
|
ensureReticleVisible();
|
||||||
QString path = directory;
|
QString path = directory;
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
@ -184,11 +183,19 @@ QScriptValue WindowScriptingInterface::browseDir(const QString& title, const QSt
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
path = fixupPathForMac(directory);
|
path = fixupPathForMac(directory);
|
||||||
#endif
|
#endif
|
||||||
QString result = OffscreenUi::getExistingDirectory(nullptr, title, path);
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse,
|
||||||
|
this, [=] (QString result) {
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse,
|
||||||
|
this, nullptr);
|
||||||
if (!result.isEmpty()) {
|
if (!result.isEmpty()) {
|
||||||
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
|
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
|
||||||
}
|
}
|
||||||
return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result);
|
emit browseDirChanged(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
OffscreenUi::getExistingDirectoryAsync(nullptr, title, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
|
|
|
@ -53,7 +53,7 @@ public slots:
|
||||||
QScriptValue confirm(const QString& message = "");
|
QScriptValue confirm(const QString& message = "");
|
||||||
QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
|
QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
|
||||||
CustomPromptResult customPrompt(const QVariant& config);
|
CustomPromptResult customPrompt(const QVariant& config);
|
||||||
QScriptValue 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 = "");
|
QScriptValue browseAssets(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
|
@ -87,7 +87,7 @@ signals:
|
||||||
void announcement(const QString& message);
|
void announcement(const QString& message);
|
||||||
|
|
||||||
void messageBoxClosed(int id, int button);
|
void messageBoxClosed(int id, int button);
|
||||||
|
void browseDirChanged(QString browseDir);
|
||||||
// triggered when window size or position changes
|
// triggered when window size or position changes
|
||||||
void geometryChanged(QRect geometry);
|
void geometryChanged(QRect geometry);
|
||||||
|
|
||||||
|
|
|
@ -120,15 +120,8 @@ function onMessage(message) {
|
||||||
openLoginWindow();
|
openLoginWindow();
|
||||||
break;
|
break;
|
||||||
case 'chooseSnapshotLocation':
|
case 'chooseSnapshotLocation':
|
||||||
var snapshotPath = Window.browseDir("Choose Snapshots Directory", "", "");
|
Window.browseDirChanged.connect(snapshotDirChanged);
|
||||||
|
Window.browseDir("Choose Snapshots Directory", "", "");
|
||||||
if (snapshotPath) { // not cancelled
|
|
||||||
Snapshot.setSnapshotsLocation(snapshotPath);
|
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
|
||||||
type: "snapshot",
|
|
||||||
action: "snapshotLocationChosen"
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'openSettings':
|
case 'openSettings':
|
||||||
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
||||||
|
@ -579,6 +572,17 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function snapshotDirChanged(snapshotPath) {
|
||||||
|
Window.browseDirChanged.disconnect(snapshotDirChanged);
|
||||||
|
if (snapshotPath !== "") { // not cancelled
|
||||||
|
Snapshot.setSnapshotsLocation(snapshotPath);
|
||||||
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
|
type: "snapshot",
|
||||||
|
action: "snapshotLocationChosen"
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function processingGifStarted(pathStillSnapshot) {
|
function processingGifStarted(pathStillSnapshot) {
|
||||||
Window.processingGifStarted.disconnect(processingGifStarted);
|
Window.processingGifStarted.disconnect(processingGifStarted);
|
||||||
Window.processingGifCompleted.connect(processingGifCompleted);
|
Window.processingGifCompleted.connect(processingGifCompleted);
|
||||||
|
|
Loading…
Reference in a new issue