X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fconsolewidget.cpp;fp=src%2Fconsolewidget.cpp;h=ce55cc428699421c7364374210b586b8187e5c47;hb=5d8c9e52606315fbfe857f2715b8f051b4f97491;hp=0000000000000000000000000000000000000000;hpb=742d2aa9bb46bce4f690474fa22f5980e175e55e;p=architektonas diff --git a/src/consolewidget.cpp b/src/consolewidget.cpp new file mode 100644 index 0000000..ce55cc4 --- /dev/null +++ b/src/consolewidget.cpp @@ -0,0 +1,58 @@ +// +// consolewidget.cpp: Command line widget +// +// Part of the Architektonas Project +// (C) 2021 Underground Software +// See the README and GPLv3 files for licensing and warranty information +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 11/20/2021 Created this file +// + +#include "consolewidget.h" + +ConsoleWidget::ConsoleWidget(QWidget * parent/*= NULL*/): QWidget(parent) +{ + cmdline = new PromptLineEdit(this); + cmdline->setFrame(false); + + screen = new QTextEdit; + screen->setAlignment(Qt::AlignBottom | Qt::AlignLeft); + screen->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + screen->setReadOnly(true); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addWidget(screen); + mainLayout->addWidget(cmdline); + + setLayout(mainLayout); + + connect(cmdline, SIGNAL(returnPressed()), this, SLOT(Execute())); + + QScrollBar * scrollbar = screen->verticalScrollBar(); + connect(scrollbar, SIGNAL(rangeChanged(int, int)), this, SLOT(MoveScrollBarToBottom(int, int))); +} + +ConsoleWidget::~ConsoleWidget() +{ +} + +void ConsoleWidget::Execute(void) +{ + screen->append(cmdline->text()); + screen->append("Error: don't know how to '" + cmdline->text() + "'"); + cmdline->clear(); +} + +void ConsoleWidget::MoveScrollBarToBottom(int min, int max) +{ + Q_UNUSED(min); + screen->verticalScrollBar()->setValue(max); +} + +void ConsoleWidget::paintEvent(QPaintEvent * /*event*/) +{ +}