Add checkbox that automatically reloads externally changed files

This commit is contained in:
David Rowe 2014-06-29 21:50:16 -07:00
parent c454c790fa
commit ce874305be
4 changed files with 23 additions and 7 deletions

View file

@ -219,12 +219,13 @@ void ScriptEditorWidget::onWindowActivated() {
_isReloading = true;
if (QFileInfo(_currentScript).lastModified() > _currentScriptModified) {
if (QMessageBox::warning(this, _currentScript,
tr("This file has been modified outside of the Interface editor.") + "\n\n"
+(isModified()
? tr("Do you want to reload it and lose the changes you've made in the Interface editor?")
: tr("Do you want to reload it?")),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
if (static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent())->autoReloadScripts()
|| QMessageBox::warning(this, _currentScript,
tr("This file has been modified outside of the Interface editor.") + "\n\n"
+ (isModified()
? tr("Do you want to reload it and lose the changes you've made in the Interface editor?")
: tr("Do you want to reload it?")),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
loadFile(_currentScript);
if (_scriptEditorWidgetUI->onTheFlyCheckBox->isChecked() && isRunning()) {
_isRestarting = true;

View file

@ -220,6 +220,10 @@ void ScriptEditorWindow::terminateCurrentTab() {
}
}
bool ScriptEditorWindow::autoReloadScripts() {
return _ScriptEditorWindowUI->autoReloadCheckBox->isChecked();
}
bool ScriptEditorWindow::event(QEvent* event) {
if (event->type() == QEvent::WindowActivate) {
emit windowActivated();

View file

@ -26,6 +26,7 @@ public:
~ScriptEditorWindow();
void terminateCurrentTab();
bool autoReloadScripts();
signals:
void windowActivated();

View file

@ -33,7 +33,7 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0">
<property name="spacing">
<number>3</number>
</property>
@ -185,6 +185,16 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="autoReloadCheckBox">
<property name="styleSheet">
<string notr="true">font: 13px &quot;Helvetica&quot;,&quot;Arial&quot;,&quot;sans-serif&quot;;</string>
</property>
<property name="text">
<string>Automatically reload externally changed files</string>
</property>
</widget>
</item>
</layout>
</item>
<item>