From 4ae6300717a10c7fa850b800f18a730aee1d3e07 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 5 Sep 2014 19:57:14 +0200 Subject: Internal code editor. Sound system. --- src/mainwindow.cc | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/mainwindow.cc') 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 +#include +#include +#include +#include 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(); -- cgit v1.2.3