diff options
author | dos-reis <gdr@axiomatics.org> | 2011-07-01 17:26:12 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-07-01 17:26:12 +0000 |
commit | 5e63328f3bcd8b1d1cc7d59350f92cc4185df7c0 (patch) | |
tree | a67350d9021f77f9de394c9f35bd776189241957 /src/gui/conversation.cc | |
parent | 8816646796401df89afdd12daf749ca99400c949 (diff) | |
download | open-axiom-5e63328f3bcd8b1d1cc7d59350f92cc4185df7c0.tar.gz |
* gui/conversation.h (OutputTextArea): Now inherit from
QTextEditor, for the nth time.
(OutputTextArea::sizeHint): Declare as override.
* gui/conversation.cc (OutputTextArea::OutputTextArea): Make the
output text editor read only. Disallow vertical scroll bars.
(OutputTextArea::sizeHint): Give a tight estimate.
(OutputTextArea::add_paragraph): Tidy.
(OutputTextArea::add_text): Likewise.
(Exchange::reply_to_query): Toggle the mouse in busy state
after submitting query.
(Conversation::read_reply): Untoggle mouse' busy state if last
output text was read.
Diffstat (limited to 'src/gui/conversation.cc')
-rw-r--r-- | src/gui/conversation.cc | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/gui/conversation.cc b/src/gui/conversation.cc index 0293b494..c3357e0f 100644 --- a/src/gui/conversation.cc +++ b/src/gui/conversation.cc @@ -35,6 +35,7 @@ #include <iostream> #include <QScrollBar> +#include <QApplication> #include "conversation.h" #include "debate.h" @@ -64,11 +65,27 @@ namespace OpenAxiom { // -------------------- OutputTextArea::OutputTextArea(QWidget* p) : Base(p) { + setReadOnly(true); // this is a output only area. + setLineWrapMode(NoWrap); // for the time being, mess with nothing. setFont(p->font()); + setViewportMargins(0, 0, 0, 0); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + // We do not want to see scroll bars. Usually disallowing vertical + // scroll bars and allocating enough horizontal space is sufficient + // to ensure that we don't see any horizontal scrollbar. + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setLineWidth(1); } + // This overriding implementation is so that we can control the + // amount of vertical space in the read-only editor viewport allocated + // for the display of output text. In particular we do not want + // scrollbars. + QSize + OutputTextArea::sizeHint() const { + return QSize(width(), document()->lineCount() * fontMetrics().height()); + } + // Concatenate two paragraphs. static QString accumulate_paragaphs(const QString& before, const QString& after) { @@ -78,7 +95,7 @@ namespace OpenAxiom { } void OutputTextArea::add_paragraph(const QString& s) { - setText(accumulate_paragaphs(text(), s)); + setPlainText(accumulate_paragaphs(toPlainText(), s)); QSize sz = sizeHint(); sz.setWidth(parentWidget()->width() - our_margin(this)); resize(sz); @@ -87,7 +104,7 @@ namespace OpenAxiom { } void OutputTextArea::add_text(const QString& s) { - setText(text() + s); + setPlainText(toPlainText() + s); QSize sz = sizeHint(); const int w = parentWidget()->width() - 2 * frameWidth(); if (w > sz.width()) @@ -228,6 +245,7 @@ namespace OpenAxiom { if (empty_string(input)) return; topic()->submit_query(input); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); } void Exchange::resizeEvent(QResizeEvent* e) { @@ -393,8 +411,10 @@ namespace OpenAxiom { exchange()->updateGeometry(); if (empty_string(output.prompt)) ensure_visibility(debate(), exchange()); - else + else { ensure_visibility(debate(), next(exchange())); + QApplication::restoreOverrideCursor(); + } } } |