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