diff options
Diffstat (limited to 'src/gui/main-window.cc')
-rw-r--r-- | src/gui/main-window.cc | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/src/gui/main-window.cc b/src/gui/main-window.cc index 9912bf41..b3063638 100644 --- a/src/gui/main-window.cc +++ b/src/gui/main-window.cc @@ -31,42 +31,46 @@ #include <QMenuBar> #include <QAction> +#include <QApplication> +#include <QMessageBox> #include "debate.h" #include "main-window.h" namespace OpenAxiom { - - // Attempt to resize the main window so that on the first exposure - // the exchanges in this debate have the preferred geometry and the - // horizontal scroll bar is not needed. - static void - try_to_honor_widget_size(MainWindow* w, Debate* debate) { - // Force a show first, to provoke conversation size. - // That helps getting the sizes right. On the other hand, it - // makes for several resize event roundring leading to - // an awkward looking brief window showing. FIXME. - w->show(); - QSize diff = debate->exchanges()->size() - debate->viewport()->size(); - if (diff.width() < 0) - diff.setWidth(0); - if (diff.height() < 0) - diff.setHeight(0); - w->resize(w->size() + diff); - } - - MainWindow::MainWindow(Command& cmd) : fs(cmd.root_dir), srv(cmd), tabs(this) { + MainWindow::MainWindow(Command& cmd) : srv(cmd), tabs(this) { setCentralWidget(&tabs); - Debate* debate = new Debate(&tabs, cmd); + Debate* debate = new Debate(&tabs); tabs.addTab(debate, "Main Frame"); QMenu* file = menuBar()->addMenu(tr("&File")); QAction* action = new QAction(tr("Quit"), this); file->addAction(action); action->setShortcut(tr("Ctrl+Q")); connect(action, SIGNAL(triggered()), this, SLOT(close())); - try_to_honor_widget_size(this, debate); + + connect(server(), SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(done(int, QProcess::ExitStatus))); + connect(server(), SIGNAL(readyReadStandardError()), + this, SLOT(display_error())); + + server()->launch(); + // When invoked in a --role=server mode, OpenAxiom would + // wait to be pinged before displaying a prompt. This is + // an unfortunate result of a rather awkward hack. + server()->input(""); } MainWindow::~MainWindow() { } + + void MainWindow::done(int s, QProcess::ExitStatus) { + // For the time being, shut done the whole application + // if the interpreter quits. FIXME. + QApplication::exit(s); + } + + void MainWindow::display_error() { + auto s = server()->readAllStandardError(); + QMessageBox::critical(this, tr("System error"), QString(s)); + } } |