mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 05:44:44 +02:00
Merge pull request #12386 from cain-kilgore/21668
WL 21668 - Make sure all Prompts are correctly emitting a signal on cancel and that cancellations return null
This commit is contained in:
commit
331b253ba0
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
|
/// \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.
|
/// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise.
|
||||||
QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
|
QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
|
||||||
bool ok = false;
|
QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText);
|
||||||
QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText, &ok);
|
if (QScriptValue(result).equals("")) {
|
||||||
return ok ? QScriptValue(result) : QScriptValue::NullValue;
|
return QScriptValue::NullValue;
|
||||||
|
}
|
||||||
|
return QScriptValue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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::promptAsync(const QString& message, const QString& defaultText) {
|
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) {
|
connect(dlg, &ModalDialogListener::response, this, [=] (QVariant result) {
|
||||||
disconnect(dlg, &ModalDialogListener::response, this, nullptr);
|
disconnect(dlg, &ModalDialogListener::response, this, nullptr);
|
||||||
emit promptTextChanged(result.toString());
|
emit promptTextChanged(result.toString());
|
||||||
|
|
|
@ -340,10 +340,11 @@ class InputDialogListener : public ModalDialogListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connect(_dialog, SIGNAL(selected(QVariant)), this, SLOT(onSelected(const QVariant&)));
|
connect(_dialog, SIGNAL(selected(QVariant)), this, SLOT(onSelected(const QVariant&)));
|
||||||
|
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelected()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSelected(const QVariant& result) {
|
void onSelected(const QVariant& result = "") {
|
||||||
_result = result;
|
_result = result;
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
emit response(_result);
|
emit response(_result);
|
||||||
|
@ -698,10 +699,11 @@ class FileDialogListener : public ModalDialogListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connect(_dialog, SIGNAL(selectedFile(QVariant)), this, SLOT(onSelectedFile(QVariant)));
|
connect(_dialog, SIGNAL(selectedFile(QVariant)), this, SLOT(onSelectedFile(QVariant)));
|
||||||
|
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelectedFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSelectedFile(QVariant file) {
|
void onSelectedFile(QVariant file = "") {
|
||||||
_result = file.toUrl().toLocalFile();
|
_result = file.toUrl().toLocalFile();
|
||||||
_finished = true;
|
_finished = true;
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
@ -947,10 +949,11 @@ class AssetDialogListener : public ModalDialogListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connect(_dialog, SIGNAL(selectedAsset(QVariant)), this, SLOT(onSelectedAsset(QVariant)));
|
connect(_dialog, SIGNAL(selectedAsset(QVariant)), this, SLOT(onSelectedAsset(QVariant)));
|
||||||
|
connect(_dialog, SIGNAL(canceled()), this, SLOT(onSelectedAsset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSelectedAsset(QVariant asset) {
|
void onSelectedAsset(QVariant asset = "") {
|
||||||
_result = asset;
|
_result = asset;
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
emit response(_result);
|
emit response(_result);
|
||||||
|
|
Loading…
Reference in a new issue