diff options
-rw-r--r-- | src/gui/conversation.cc | 3 | ||||
-rw-r--r-- | src/gui/debate.cc | 12 | ||||
-rw-r--r-- | src/gui/debate.h | 3 | ||||
-rw-r--r-- | src/gui/main-window.cc | 19 |
4 files changed, 17 insertions, 20 deletions
diff --git a/src/gui/conversation.cc b/src/gui/conversation.cc index d3301d79..4fedfa52 100644 --- a/src/gui/conversation.cc +++ b/src/gui/conversation.cc @@ -279,8 +279,7 @@ namespace OpenAxiom { setFont(monospace_font()); setBackgroundRole(QPalette::Base); greatings.setFont(font()); - connect(win->server(), SIGNAL(readyReadStandardOutput()), - this, SLOT(read_reply())); + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); } Conversation::~Conversation() { diff --git a/src/gui/debate.cc b/src/gui/debate.cc index 1554bcb2..dbec1ae8 100644 --- a/src/gui/debate.cc +++ b/src/gui/debate.cc @@ -38,13 +38,13 @@ namespace OpenAxiom { Debate::Debate(MainWindow* w) : QScrollArea(w), win(w), conv(this) { + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setWidget(&conv); setViewportMargins(0, 0, 0, 0); viewport()->setAutoFillBackground(true); viewport()->setBackgroundRole(conv.backgroundRole()); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - // adjustSize(); + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } Debate::~Debate() { } @@ -53,12 +53,4 @@ namespace OpenAxiom { Debate::server() const { return win->server(); } - - void Debate::resizeEvent(QResizeEvent* e) { - QScrollArea::resizeEvent(e); - if (conv.length() != 0) - conv.resize(viewport()->size()); - setSizePolicy(QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding); - } } diff --git a/src/gui/debate.h b/src/gui/debate.h index 64bba63d..5e5356bb 100644 --- a/src/gui/debate.h +++ b/src/gui/debate.h @@ -50,9 +50,6 @@ namespace OpenAxiom { Conversation* exchanges() { return &conv; } Server* server() const; - protected: - void resizeEvent(QResizeEvent*); - private: MainWindow* const win; Conversation conv; diff --git a/src/gui/main-window.cc b/src/gui/main-window.cc index 836f56d1..442841b7 100644 --- a/src/gui/main-window.cc +++ b/src/gui/main-window.cc @@ -33,26 +33,35 @@ #include <QAction> #include <QApplication> #include <QMessageBox> +#include <QScrollBar> #include "debate.h" #include "main-window.h" namespace OpenAxiom { + static void connect_server_io(MainWindow* win, Debate* debate) { + QObject::connect(win->server(), SIGNAL(readyReadStandardError()), + win, SLOT(display_error())); + QObject::connect(win->server(), SIGNAL(readyReadStandardOutput()), + debate->exchanges(), SLOT(read_reply())); + } + + MainWindow::MainWindow(int argc, char* argv[]) : srv(argc, argv), debate(this) { setCentralWidget(&debate); setWindowTitle("OpenAxiom"); + auto s = debate.widget()->frameSize(); + s.rwidth() += debate.verticalScrollBar()->width(); + s.rheight() += debate.horizontalScrollBar()->width(); + resize(s); 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())); - connect(server(), SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(done(int, QProcess::ExitStatus))); - connect(server(), SIGNAL(readyReadStandardError()), - this, SLOT(display_error())); - + connect_server_io(this, &debate); server()->launch(); // When invoked in a --role=server mode, OpenAxiom would // wait to be pinged before displaying a prompt. This is |