aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-07-01 17:26:12 +0000
committerdos-reis <gdr@axiomatics.org>2011-07-01 17:26:12 +0000
commit5e63328f3bcd8b1d1cc7d59350f92cc4185df7c0 (patch)
treea67350d9021f77f9de394c9f35bd776189241957 /src/gui
parent8816646796401df89afdd12daf749ca99400c949 (diff)
downloadopen-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')
-rw-r--r--src/gui/conversation.cc26
-rw-r--r--src/gui/conversation.h10
2 files changed, 29 insertions, 7 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();
+ }
}
}
diff --git a/src/gui/conversation.h b/src/gui/conversation.h
index 85220122..8f379f8d 100644
--- a/src/gui/conversation.h
+++ b/src/gui/conversation.h
@@ -35,7 +35,7 @@
#include <vector>
#include <QFrame>
#include <QLineEdit>
-#include <QLabel>
+#include <QTextEdit>
#include <QFont>
#include <QEvent>
#include <QResizeEvent>
@@ -57,10 +57,12 @@ namespace OpenAxiom {
// --------------------
// An output text area is a widget where we output text.
// The texts are accumulated, as opposed to overwritten.
- class OutputTextArea : public QLabel {
- typedef QLabel Base;
+ class OutputTextArea : public QTextEdit {
+ typedef QTextEdit Base;
public:
explicit OutputTextArea(QWidget*);
+ // the metrics of this output area
+ QSize sizeHint() const;
// Add a new paragraph to existing texts. Paragraghs are
// separated by the newline character.
void add_paragraph(const QString&);
@@ -123,7 +125,7 @@ namespace OpenAxiom {
// Conversion number
int number() const { return no; }
- // Reimplement positiion management.
+ // Reimplement position management.
QSize sizeHint() const;
protected: