Showing the changes to interface/src/ui/ScriptEditorWidget.cpp (1 of 11 files). Show all
Unified · Split
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | #include <QWidget> | 26 | #include <QWidget> |
| 27 | 27 | ||
| 28 | #include <NetworkAccessManager.h> | 28 | #include <NetworkAccessManager.h> |
| 29 | #include <OffscreenUi.h> | ||
| 29 | 30 | ||
| 30 | #include "Application.h" | 31 | #include "Application.h" |
| 31 | #include "ScriptHighlighting.h" | 32 | #include "ScriptHighlighting.h" |
| @@ -120,7 +121,7 @@ bool ScriptEditorWidget::setRunning(bool run) { · 88 unmodified lines | |||
| 120 | bool ScriptEditorWidget::saveFile(const QString &scriptPath) { | 121 | bool ScriptEditorWidget::saveFile(const QString &scriptPath) { |
| 121 | QFile file(scriptPath); | 122 | QFile file(scriptPath); |
| 122 | if (!file.open(QFile::WriteOnly | QFile::Text)) { | 123 | if (!file.open(QFile::WriteOnly | QFile::Text)) { |
| 123 | QMessageBox::warning(this, tr("Interface"), tr("Cannot write script %1:\n%2.").arg(scriptPath) | 124 | OffscreenUi::warning(this, tr("Interface"), tr("Cannot write script %1:\n%2.").arg(scriptPath) |
| 124 | .arg(file.errorString())); | 125 | .arg(file.errorString())); |
| 125 | return false; | 126 | return false; |
| 126 | } | 127 | } |
| @@ -141,7 +142,7 @@ void ScriptEditorWidget::loadFile(const QString& scriptPath) { · 14 unmodified lines | |||
| 141 | if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) { | 142 | if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) { |
| 142 | QFile file(scriptPath); | 143 | QFile file(scriptPath); |
| 143 | if (!file.open(QFile::ReadOnly | QFile::Text)) { | 144 | if (!file.open(QFile::ReadOnly | QFile::Text)) { |
| 144 | QMessageBox::warning(this, tr("Interface"), tr("Cannot read script %1:\n%2.").arg(scriptPath) | 145 | OffscreenUi::warning(this, tr("Interface"), tr("Cannot read script %1:\n%2.").arg(scriptPath) |
| 145 | .arg(file.errorString())); | 146 | .arg(file.errorString())); |
| 146 | return; | 147 | return; |
| 147 | } | 148 | } |
| @@ -208,7 +209,7 @@ void ScriptEditorWidget::setScriptFile(const QString& scriptPath) { · 60 unmodified lines | |||
| 208 | 209 | ||
| 209 | bool ScriptEditorWidget::questionSave() { | 210 | bool ScriptEditorWidget::questionSave() { |
| 210 | if (_scriptEditorWidgetUI->scriptEdit->document()->isModified()) { | 211 | if (_scriptEditorWidgetUI->scriptEdit->document()->isModified()) { |
| 211 | QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Interface"), | 212 | QMessageBox::StandardButton button = OffscreenUi::warning(this, tr("Interface"), |
| 212 | tr("The script has been modified.\nDo you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard | | 213 | tr("The script has been modified.\nDo you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard | |
| 213 | QMessageBox::Cancel, QMessageBox::Save); | 214 | QMessageBox::Cancel, QMessageBox::Save); |
| 214 | return button == QMessageBox::Save ? save() : (button == QMessageBox::Discard); | 215 | return button == QMessageBox::Save ? save() : (button == QMessageBox::Discard); |
| @@ -222,7 +223,7 @@ void ScriptEditorWidget::onWindowActivated() { · 7 unmodified lines | |||
| 222 | 223 | ||
| 223 | if (QFileInfo(_currentScript).lastModified() > _currentScriptModified) { | 224 | if (QFileInfo(_currentScript).lastModified() > _currentScriptModified) { |
| 224 | if (static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent())->autoReloadScripts() | 225 | if (static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent())->autoReloadScripts() |
| 225 | || QMessageBox::warning(this, _currentScript, | 226 | || OffscreenUi::warning(this, _currentScript, |
| 226 | tr("This file has been modified outside of the Interface editor.") + "\n\n" | 227 | tr("This file has been modified outside of the Interface editor.") + "\n\n" |
| 227 | + (isModified() | 228 | + (isModified() |
| 228 | ? tr("Do you want to reload it and lose the changes you've made in the Interface editor?") | 229 | ? tr("Do you want to reload it and lose the changes you've made in the Interface editor?") |