From dcecacbf52121d6f8adf076d2cebaeec1e141339 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 23 Aug 2012 20:23:19 +0200 Subject: Implement automatic reset/reload when script file changes on disc. --- src/mainwindow.cc | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/mainwindow.cc') diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 784bfbb..c8036ca 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -29,11 +29,31 @@ #include "outputwindow.h" -MainWindow::MainWindow(QString program) +#include + +MainWindow::MainWindow(QString p) { + program = p; + + connect(&watcher, SIGNAL(fileChanged(const QString &)), + this, SLOT(reset())); + + watcher.addPath(program); + out = new OutputWindow(); out->show(); - l = new LUAScript(out); - l->addFile(program.toStdString()); + + l = new LUAScript(out, program); + + reset(); +} + +void MainWindow::reset() +{ + printf("Resetting...\n"); + out->stopScript(); + l->stopScript(); + out->reset(); l->start(); + printf("Reset done\n"); } -- cgit v1.2.3