Commit 880808f5 authored by Tomas Mecir's avatar Tomas Mecir

various fixes, mostly with transcript and layouting

parent 42af2e50
...@@ -112,11 +112,10 @@ void cTranscript::addLineToTranscript (cTextChunk *chunk) ...@@ -112,11 +112,10 @@ void cTranscript::addLineToTranscript (cTextChunk *chunk)
cANSIParser *ap = dynamic_cast<cANSIParser *>(object ("ansiparser")); cANSIParser *ap = dynamic_cast<cANSIParser *>(object ("ansiparser"));
QString s; QString s;
switch (type) { switch (type) {
case TRANSCRIPT_PLAIN: s = chunk->toText (); break; case TRANSCRIPT_PLAIN: s = chunk->toText () + "\n"; break;
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap); break; case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap) + "\n"; break;
case TRANSCRIPT_HTML: s = chunk->toHTML (); break; case TRANSCRIPT_HTML: s = chunk->toHTML (); break;
}; };
s += "\n"; // we use <pre> in HTML, so this applies equally to all three
file.write (s.toLocal8Bit ()); file.write (s.toLocal8Bit ());
file.flush(); file.flush();
} }
...@@ -137,11 +136,10 @@ void cTranscript::addLineToAdvTranscript (cTextChunk *chunk) ...@@ -137,11 +136,10 @@ void cTranscript::addLineToAdvTranscript (cTextChunk *chunk)
cANSIParser *ap = dynamic_cast<cANSIParser *>(object ("ansiparser")); cANSIParser *ap = dynamic_cast<cANSIParser *>(object ("ansiparser"));
QString s; QString s;
switch (advtype) { switch (advtype) {
case TRANSCRIPT_PLAIN: s = chunk->toText (); break; case TRANSCRIPT_PLAIN: s = chunk->toText () + "\n"; break;
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap); break; case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap) + "\n"; break;
case TRANSCRIPT_HTML: s = chunk->toHTML (); break; case TRANSCRIPT_HTML: s = chunk->toHTML (); break;
}; };
s += "\n"; // we use <pre> in HTML, so this applies equally to all three
advfile.write (s.toLocal8Bit ()); advfile.write (s.toLocal8Bit ());
advfile.flush(); advfile.flush();
...@@ -268,10 +266,13 @@ void cTranscript::startTranscript () ...@@ -268,10 +266,13 @@ void cTranscript::startTranscript ()
file.write ("\n\n"); file.write ("\n\n");
if (type == TRANSCRIPT_HTML) if (type == TRANSCRIPT_HTML)
{ {
cProfileSettings *sett = settings();
//TODO: what if we're adding to an existing HTML transcript? //TODO: what if we're adding to an existing HTML transcript?
file.write ("<html>\n"); file.write ("<html><head>\n");
file.write ("<meta name=\"Generator\" content=\"KMuddy\">\n"); file.write ("<meta name=\"Generator\" content=\"KMuddy\">\n");
file.write ("<body bgcolor="); file.write (("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + sett->getString ("encoding") + "\">").toLatin1());
file.write ("<style> p { margin: 0px; padding: 2px; } </style>");
file.write ("</head><body bgcolor=");
file.write (output->defaultBkColor().name().toLatin1()); file.write (output->defaultBkColor().name().toLatin1());
file.write (">\n"); file.write (">\n");
} }
......
...@@ -44,8 +44,8 @@ dlgEditProfile::dlgEditProfile(QWidget *parent) : QDialog (parent) ...@@ -44,8 +44,8 @@ dlgEditProfile::dlgEditProfile(QWidget *parent) : QDialog (parent)
QGridLayout *layout = new QGridLayout (this); QGridLayout *layout = new QGridLayout (this);
// create the button that opens the MUD listing // create the button that opens the MUD listing
QPushButton *btlist = new QPushButton (i18n ("&Select from MUD list"), this); // QPushButton *btlist = new QPushButton (i18n ("&Select from MUD list"), this);
connect (btlist, SIGNAL (clicked()), this, SLOT (openMudList())); // connect (btlist, SIGNAL (clicked()), this, SLOT (openMudList()));
// put some edit boxes there // put some edit boxes there
QLabel *l1 = new QLabel (i18n ("Profile &name:"), this); QLabel *l1 = new QLabel (i18n ("Profile &name:"), this);
...@@ -90,7 +90,7 @@ dlgEditProfile::dlgEditProfile(QWidget *parent) : QDialog (parent) ...@@ -90,7 +90,7 @@ dlgEditProfile::dlgEditProfile(QWidget *parent) : QDialog (parent)
l6->setBuddy (connstr); l6->setBuddy (connstr);
layout->setSpacing (10); layout->setSpacing (10);
layout->addWidget (btlist, 0, 0); // layout->addWidget (btlist, 0, 0);
layout->addWidget (l1, 1, 0); layout->addWidget (l1, 1, 0);
layout->addWidget (l2, 2, 0); layout->addWidget (l2, 2, 0);
layout->addWidget (l3, 3, 0); layout->addWidget (l3, 3, 0);
......
...@@ -29,8 +29,10 @@ ...@@ -29,8 +29,10 @@
#include <QGraphicsTextItem> #include <QGraphicsTextItem>
#include <QScrollBar> #include <QScrollBar>
#include <QTextBlock> #include <QTextBlock>
#include <QTextBlockFormat>
#include <QTextCursor> #include <QTextCursor>
#include <QTextDocument> #include <QTextDocument>
#include <QDebug>
#include <KActionCollection> #include <KActionCollection>
...@@ -116,7 +118,7 @@ class cConsole::Private { ...@@ -116,7 +118,7 @@ class cConsole::Private {
QColor bgcolor; QColor bgcolor;
QFont font; QFont font;
int sess; int sess;
int charWidth, charHeight; double charWidth, charHeight;
bool wantNewLine; bool wantNewLine;
bool atBottom; bool atBottom;
...@@ -142,7 +144,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) { ...@@ -142,7 +144,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) {
connect (verticalScrollBar (), SIGNAL (valueChanged (int)), this, SLOT (sliderChanged (int))); connect (verticalScrollBar (), SIGNAL (valueChanged (int)), this, SLOT (sliderChanged (int)));
d->text = new QTextDocument; d->text = new QTextDocument;
QString stylesheet = "* { color: " + QColor (Qt::lightGray).name() + "; white-space: pre-wrap; } a { color: " + QColor (Qt::blue).name() + ": } "; QString stylesheet = "* { color: " + QColor (Qt::lightGray).name() + "; white-space: pre-wrap; } a { color: " + QColor (Qt::blue).name() + "; } p,div { padding: 1px; line-spacing: 1.3 } ";
d->text->setDefaultStyleSheet (stylesheet); d->text->setDefaultStyleSheet (stylesheet);
QTextOption opt; QTextOption opt;
opt.setWrapMode (QTextOption::WrapAtWordBoundaryOrAnywhere); opt.setWrapMode (QTextOption::WrapAtWordBoundaryOrAnywhere);
...@@ -232,7 +234,7 @@ void cConsole::setFont (QFont f) { ...@@ -232,7 +234,7 @@ void cConsole::setFont (QFont f) {
QFontMetrics fm (f); QFontMetrics fm (f);
d->charWidth = fm.width ("m"); d->charWidth = fm.width ("m");
d->charHeight = fm.lineSpacing(); d->charHeight = fm.lineSpacing() + 2;
fixupOutput(); fixupOutput();
} }
...@@ -311,7 +313,13 @@ void cConsole::forceEmitSize () { ...@@ -311,7 +313,13 @@ void cConsole::forceEmitSize () {
} }
void cConsole::dumpBuffer (bool fromcurrent, QFile &file, char dumpType) { void cConsole::dumpBuffer (bool fromcurrent, QFile &file, char dumpType) {
// TODO QString contents;
// TODO: support 'fromcurrent'
if ((dumpType == TRANSCRIPT_PLAIN) || (dumpType == TRANSCRIPT_ANSI))
contents = d->text->toPlainText();
else if (dumpType == TRANSCRIPT_HTML)
contents = d->text->toHtml();
file.write (contents.toLocal8Bit());
} }
void cConsole::setHistorySize (int size) { void cConsole::setHistorySize (int size) {
...@@ -372,6 +380,9 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine) ...@@ -372,6 +380,9 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
if (d->wantNewLine) { if (d->wantNewLine) {
cursor.insertBlock (); cursor.insertBlock ();
d->wantNewLine = false; d->wantNewLine = false;
QTextBlockFormat bformat = cursor.blockFormat();
bformat.setLineHeight (2, QTextBlockFormat::LineDistanceHeight);
cursor.setBlockFormat (bformat);
} }
cursor.insertHtml (chunk->toHTML()); cursor.insertHtml (chunk->toHTML());
......
...@@ -717,7 +717,7 @@ QString cTextChunk::toHTML () ...@@ -717,7 +717,7 @@ QString cTextChunk::toHTML ()
for (it = _entries.begin(); it != _entries.end(); ++it) for (it = _entries.begin(); it != _entries.end(); ++it)
s += (*it)->toHTML (suffix); s += (*it)->toHTML (suffix);
s += suffix; s += suffix;
return s; return "<p>" + s + "</p>";
} }
cTextChunk *cTextChunk::makeLine (const QString &text, QColor fg, QColor bg, cConsole *console) cTextChunk *cTextChunk::makeLine (const QString &text, QColor fg, QColor bg, cConsole *console)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment