Showing the changes to interface/src/Application.cpp (1 of 7 files). Show all
Unified · Split
| @@ -6146,13 +6146,13 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 6145 unmodified lines | ||
| 6146 | 6146 | bool agreeToLicense = true; // assume true |
| 6147 | 6147 | //create set avatar callback |
| 6148 | 6148 | auto setAvatar = [=] (QString url, QString modelName) { |
| 6149 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6150 | − | |
| 6151 | − QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=] (QMessageBox::StandardButton answer) { | |
| 6152 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6153 | − QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr); | |
| 6149 | + ModalDialogListener* dlg = OffscreenUi::asyncQuestion("Set Avatar", | |
| 6150 | + "Would you like to use '" + modelName + "' for your avatar?", | |
| 6151 | + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); | |
| 6152 | + QObject::connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) { | |
| 6153 | + QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 6154 | 6154 | |
| 6155 | − bool ok = (QMessageBox::Ok == answer); | |
| 6155 | + bool ok = (QMessageBox::Ok == static_cast<QMessageBox::StandardButton>(answer.toInt())); | |
| 6156 | 6156 | if (ok) { |
| 6157 | 6157 | getMyAvatar()->useFullAvatarURL(url, modelName); |
| 6158 | 6158 | emit fullAvatarURLChanged(url, modelName); |
| @@ -6160,9 +6160,6 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 1 unmodified line | ||
| 6160 | 6160 | qCDebug(interfaceapp) << "Declined to use the avatar: " << url; |
| 6161 | 6161 | } |
| 6162 | 6162 | }); |
| 6163 | − OffscreenUi::asyncQuestion("Set Avatar", | |
| 6164 | − "Would you like to use '" + modelName + "' for your avatar?", | |
| 6165 | − QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); | |
| 6166 | 6163 | }; |
| 6167 | 6164 | |
| 6168 | 6165 | if (!modelLicense.isEmpty()) { |
| @@ -6170,12 +6167,13 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 1 unmodified line | ||
| 6170 | 6167 | const int MAX_CHARACTERS_PER_LINE = 90; |
| 6171 | 6168 | modelLicense = simpleWordWrap(modelLicense, MAX_CHARACTERS_PER_LINE); |
| 6172 | 6169 | |
| 6173 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6174 | − QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=, &agreeToLicense] (QMessageBox::StandardButton answer) { | |
| 6175 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6176 | − QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr); | |
| 6170 | + ModalDialogListener* dlg = OffscreenUi::asyncQuestion("Avatar Usage License", | |
| 6171 | + modelLicense + "\nDo you agree to these terms?", | |
| 6172 | + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); | |
| 6173 | + QObject::connect(dlg, &ModalDialogListener::response, this, [=, &agreeToLicense] (QVariant answer) { | |
| 6174 | + QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 6177 | 6175 | |
| 6178 | − agreeToLicense = (answer == QMessageBox::Yes); | |
| 6176 | + agreeToLicense = (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes); | |
| 6179 | 6177 | if (agreeToLicense) { |
| 6180 | 6178 | switch (modelType) { |
| 6181 | 6179 | case FSTReader::HEAD_AND_BODY_MODEL: { |
| @@ -6192,10 +6190,6 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 10 unmodified lines | ||
| 6192 | 6190 | |
| 6193 | 6191 | //auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 6194 | 6192 | }); |
| 6195 | − | |
| 6196 | − OffscreenUi::asyncQuestion("Avatar Usage License", | |
| 6197 | − modelLicense + "\nDo you agree to these terms?", | |
| 6198 | − QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); | |
| 6199 | 6193 | } else { |
| 6200 | 6194 | setAvatar(url, modelName); |
| 6201 | 6195 | } |
| @@ -6215,23 +6209,21 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { · 13 unmodified lines | ||
| 6215 | 6209 | shortName = shortName.mid(startIndex, endIndex - startIndex); |
| 6216 | 6210 | } |
| 6217 | 6211 | |
| 6218 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6219 | − QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=] (QMessageBox::StandardButton answer) { | |
| 6212 | + QString message = "Would you like to run this script:\n" + shortName; | |
| 6213 | + ModalDialogListener* dlg = OffscreenUi::asyncQuestion(getWindow(), "Run Script", message, | |
| 6214 | + QMessageBox::Yes | QMessageBox::No); | |
| 6215 | + | |
| 6216 | + QObject::connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) { | |
| 6220 | 6217 | const QString& fileName = scriptFilenameOrURL; |
| 6221 | − if (answer == QMessageBox::Yes) { | |
| 6218 | + if (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes) { | |
| 6222 | 6219 | qCDebug(interfaceapp) << "Chose to run the script: " << fileName; |
| 6223 | 6220 | DependencyManager::get<ScriptEngines>()->loadScript(fileName); |
| 6224 | 6221 | } else { |
| 6225 | 6222 | qCDebug(interfaceapp) << "Declined to run the script: " << scriptFilenameOrURL; |
| 6226 | 6223 | } |
| 6227 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6228 | − QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr); | |
| 6224 | + QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 6229 | 6225 | }); |
| 6230 | 6226 | |
| 6231 | − QString message = "Would you like to run this script:\n" + shortName; | |
| 6232 | − | |
| 6233 | − OffscreenUi::asyncQuestion(getWindow(), "Run Script", message, QMessageBox::Yes | QMessageBox::No); | |
| 6234 | − | |
| 6235 | 6227 | return true; |
| 6236 | 6228 | } |
| 6237 | 6229 | |
| @@ -6268,11 +6260,14 @@ bool Application::askToWearAvatarAttachmentUrl(const QString& url) { · 30 unmodified lines | ||
| 6268 | 6260 | name = nameValue.toString(); |
| 6269 | 6261 | } |
| 6270 | 6262 | |
| 6271 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6272 | − QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=] (QMessageBox::StandardButton answer) { | |
| 6273 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6274 | − QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr); | |
| 6275 | − if (answer == QMessageBox::Yes) { | |
| 6263 | + auto avatarAttachmentConfirmationTitle = tr("Avatar Attachment Confirmation"); | |
| 6264 | + auto avatarAttachmentConfirmationMessage = tr("Would you like to wear '%1' on your avatar?").arg(name); | |
| 6265 | + ModalDialogListener* dlg = OffscreenUi::asyncQuestion(avatarAttachmentConfirmationTitle, | |
| 6266 | + avatarAttachmentConfirmationMessage, | |
| 6267 | + QMessageBox::Ok | QMessageBox::Cancel); | |
| 6268 | + QObject::connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) { | |
| 6269 | + QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 6270 | + if (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes) { | |
| 6276 | 6271 | // add attachment to avatar |
| 6277 | 6272 | auto myAvatar = getMyAvatar(); |
| 6278 | 6273 | assert(myAvatar); |
| @@ -6285,12 +6280,6 @@ bool Application::askToWearAvatarAttachmentUrl(const QString& url) { · 6 unmodified lines | ||
| 6285 | 6280 | qCDebug(interfaceapp) << "User declined to wear the avatar attachment: " << url; |
| 6286 | 6281 | } |
| 6287 | 6282 | }); |
| 6288 | − | |
| 6289 | − auto avatarAttachmentConfirmationTitle = tr("Avatar Attachment Confirmation"); | |
| 6290 | − auto avatarAttachmentConfirmationMessage = tr("Would you like to wear '%1' on your avatar?").arg(name); | |
| 6291 | − OffscreenUi::asyncQuestion(avatarAttachmentConfirmationTitle, | |
| 6292 | − avatarAttachmentConfirmationMessage, | |
| 6293 | − QMessageBox::Ok | QMessageBox::Cancel); | |
| 6294 | 6283 | } else { |
| 6295 | 6284 | // json parse error |
| 6296 | 6285 | auto avatarAttachmentParseErrorString = tr("Error parsing attachment JSON from url: \"%1\""); |
| @@ -6933,17 +6922,17 @@ void Application::openUrl(const QUrl& url) const { · 636 unmodified lines | ||
| 6933 | 6922 | |
| 6934 | 6923 | void Application::loadDialog() { |
| 6935 | 6924 | auto scriptEngines = DependencyManager::get<ScriptEngines>(); |
| 6936 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6937 | − connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, this, [=] (QString response) { | |
| 6938 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6939 | − disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, this, nullptr); | |
| 6925 | + ModalDialogListener* dlg = OffscreenUi::getOpenFileNameAsync(_glWidget, tr("Open Script"), | |
| 6926 | + getPreviousScriptLocation(), | |
| 6927 | + tr("JavaScript Files (*.js)")); | |
| 6928 | + connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) { | |
| 6929 | + disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 6930 | + const QString& response = answer.toString(); | |
| 6940 | 6931 | if (!response.isEmpty() && QFile(response).exists()) { |
| 6941 | 6932 | setPreviousScriptLocation(QFileInfo(response).absolutePath()); |
| 6942 | 6933 | DependencyManager::get<ScriptEngines>()->loadScript(response, true, false, false, true); // Don't load from cache |
| 6943 | 6934 | } |
| 6944 | 6935 | }); |
| 6945 | − OffscreenUi::getOpenFileNameAsync(_glWidget, tr("Open Script"), getPreviousScriptLocation(), | |
| 6946 | − tr("JavaScript Files (*.js)")); | |
| 6947 | 6936 | } |
| 6948 | 6937 | |
| 6949 | 6938 | QString Application::getPreviousScriptLocation() { |
| @@ -6956,10 +6945,9 @@ void Application::setPreviousScriptLocation(const QString& location) { · 6 unmodified lines | ||
| 6956 | 6945 | } |
| 6957 | 6946 | |
| 6958 | 6947 | void Application::loadScriptURLDialog() const { |
| 6959 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6960 | − connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, this, [=] (QVariant response) { | |
| 6961 | − disconnect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, this, nullptr); | |
| 6962 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 6948 | + ModalDialogListener* dlg = OffscreenUi::getTextAsync(OffscreenUi::ICON_NONE, "Open and Run Script", "Script URL"); | |
| 6949 | + connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { | |
| 6950 | + disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 6963 | 6951 | const QString& newScript = response.toString(); |
| 6964 | 6952 | if (QUrl(newScript).scheme() == "atp") { |
| 6965 | 6953 | OffscreenUi::asyncWarning("Error Loading Script", "Cannot load client script over ATP"); |
| @@ -6967,7 +6955,6 @@ void Application::loadScriptURLDialog() const { · 1 unmodified line | ||
| 6967 | 6955 | DependencyManager::get<ScriptEngines>()->loadScript(newScript.trimmed()); |
| 6968 | 6956 | } |
| 6969 | 6957 | }); |
| 6970 | − OffscreenUi::getTextAsync(OffscreenUi::ICON_NONE, "Open and Run Script", "Script URL"); | |
| 6971 | 6958 | } |
| 6972 | 6959 | |
| 6973 | 6960 | void Application::loadLODToolsDialog() { |