mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:54:25 +02:00
Fixed Async Prompts/Assets/Dialogs
This commit is contained in:
parent
7fe4f8480a
commit
5048bf16cb
2 changed files with 13 additions and 7 deletions
|
@ -120,16 +120,19 @@ QScriptValue WindowScriptingInterface::confirm(const QString& message) {
|
|||
/// \param const QString& defaultText default text in the text box
|
||||
/// \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;
|
||||
QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText);
|
||||
if (QScriptValue(result).equals("")) {
|
||||
return QScriptValue::NullValue;
|
||||
}
|
||||
return QScriptValue(result);
|
||||
}
|
||||
|
||||
/// 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) {
|
||||
ModalDialogListener* dlg = OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText);
|
||||
bool ok = false;
|
||||
ModalDialogListener* dlg = OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText, &ok);
|
||||
connect(dlg, &ModalDialogListener::response, this, [=] (QVariant result) {
|
||||
disconnect(dlg, &ModalDialogListener::response, this, nullptr);
|
||||
emit promptTextChanged(result.toString());
|
||||
|
|
|
@ -336,10 +336,11 @@ class InputDialogListener : public ModalDialogListener {
|
|||
return;
|
||||
}
|
||||
connect(_dialog, SIGNAL(selected(QVariant)), this, SLOT(onSelected(const QVariant&)));
|
||||
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelected()));
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onSelected(const QVariant& result) {
|
||||
void onSelected(const QVariant& result = "") {
|
||||
_result = result;
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
emit response(_result);
|
||||
|
@ -700,10 +701,11 @@ class FileDialogListener : public ModalDialogListener {
|
|||
return;
|
||||
}
|
||||
connect(_dialog, SIGNAL(selectedFile(QVariant)), this, SLOT(onSelectedFile(QVariant)));
|
||||
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelectedFile()));
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onSelectedFile(QVariant file) {
|
||||
void onSelectedFile(QVariant file = "") {
|
||||
_result = file.toUrl().toLocalFile();
|
||||
_finished = true;
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
|
@ -949,10 +951,11 @@ class AssetDialogListener : public ModalDialogListener {
|
|||
return;
|
||||
}
|
||||
connect(_dialog, SIGNAL(selectedAsset(QVariant)), this, SLOT(onSelectedAsset(QVariant)));
|
||||
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelectedAsset()));
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onSelectedAsset(QVariant asset) {
|
||||
void onSelectedAsset(QVariant asset = "") {
|
||||
_result = asset;
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
emit response(_result);
|
||||
|
|
Loading…
Reference in a new issue