summaryrefslogtreecommitdiff
path: root/src/mainwindow.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-09-05 19:57:14 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-09-05 19:57:14 +0200
commit4ae6300717a10c7fa850b800f18a730aee1d3e07 (patch)
tree455ae17634f5bbd8b18ce3a256db2647853bd600 /src/mainwindow.cc
parentf4b015398462fff1a64d70b632390b4f06fe3bbe (diff)
Internal code editor. Sound system.
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r--src/mainwindow.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index c8036ca..ba6c779 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -30,20 +30,45 @@
#include "outputwindow.h"
#include <QApplication>
+#include <QSplitter>
+#include <QToolBar>
+#include <QAction>
+#include <QFile>
MainWindow::MainWindow(QString p)
{
program = p;
+ /* // Watch file on disk?
connect(&watcher, SIGNAL(fileChanged(const QString &)),
this, SLOT(reset()));
watcher.addPath(program);
+ */
+ QSplitter *splitter = new QSplitter();
+ setCentralWidget(splitter);
+
+ editor = new CodeEditor();
+ splitter->addWidget(editor);
+ QFile file(program);
+ file.open(QIODevice::ReadOnly);
+ editor->setPlainText(file.readAll());
+ file.close();
+
out = new OutputWindow();
- out->show();
+ splitter->addWidget(out);
l = new LUAScript(out, program);
+ connect(l, SIGNAL(lineChanged(int)), editor, SLOT(runningLine(int)));
+
+ QToolBar *toolbar = new QToolBar();
+ addToolBar(Qt::TopToolBarArea, toolbar);
+ QAction *act_run = toolbar->addAction("Run");
+ connect(act_run, SIGNAL(triggered()), this, SLOT(reset()));
+
+ QAction *act_stop = toolbar->addAction("Stop");
+ connect(act_stop, SIGNAL(triggered()), l, SLOT(stopScript()));
reset();
}
@@ -51,6 +76,11 @@ MainWindow::MainWindow(QString p)
void MainWindow::reset()
{
printf("Resetting...\n");
+ QFile file(program);
+ file.open(QIODevice::WriteOnly);
+ QString code = editor->toPlainText();
+ file.write(code.toStdString().c_str(), code.length());
+ file.close();
out->stopScript();
l->stopScript();
out->reset();