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)
cANSIParser *ap = dynamic_cast<cANSIParser *>(object ("ansiparser"));
QString s;
switch (type) {
case TRANSCRIPT_PLAIN: s = chunk->toText (); break;
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap); break;
case TRANSCRIPT_PLAIN: s = chunk->toText () + "\n"; break;
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap) + "\n"; 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.flush();
}
......@@ -137,11 +136,10 @@ void cTranscript::addLineToAdvTranscript (cTextChunk *chunk)
cANSIParser *ap = dynamic_cast<cANSIParser *>(object ("ansiparser"));
QString s;
switch (advtype) {
case TRANSCRIPT_PLAIN: s = chunk->toText (); break;
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap); break;
case TRANSCRIPT_PLAIN: s = chunk->toText () + "\n"; break;
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap) + "\n"; 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.flush();
......@@ -268,10 +266,13 @@ void cTranscript::startTranscript ()
file.write ("\n\n");
if (type == TRANSCRIPT_HTML)
{
cProfileSettings *sett = settings();
//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 ("<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 (">\n");
}
......
......@@ -44,8 +44,8 @@ dlgEditProfile::dlgEditProfile(QWidget *parent) : QDialog (parent)
QGridLayout *layout = new QGridLayout (this);
// create the button that opens the MUD listing
QPushButton *btlist = new QPushButton (i18n ("&Select from MUD list"), this);
connect (btlist, SIGNAL (clicked()), this, SLOT (openMudList()));
// QPushButton *btlist = new QPushButton (i18n ("&Select from MUD list"), this);
// connect (btlist, SIGNAL (clicked()), this, SLOT (openMudList()));
// put some edit boxes there
QLabel *l1 = new QLabel (i18n ("Profile &name:"), this);
......@@ -90,7 +90,7 @@ dlgEditProfile::dlgEditProfile(QWidget *parent) : QDialog (parent)
l6->setBuddy (connstr);
layout->setSpacing (10);
layout->addWidget (btlist, 0, 0);
// layout->addWidget (btlist, 0, 0);
layout->addWidget (l1, 1, 0);
layout->addWidget (l2, 2, 0);
layout->addWidget (l3, 3, 0);
......
......@@ -29,8 +29,10 @@
#include <QGraphicsTextItem>
#include <QScrollBar>
#include <QTextBlock>
#include <QTextBlockFormat>
#include <QTextCursor>
#include <QTextDocument>
#include <QDebug>
#include <KActionCollection>
......@@ -116,7 +118,7 @@ class cConsole::Private {
QColor bgcolor;
QFont font;
int sess;
int charWidth, charHeight;
double charWidth, charHeight;
bool wantNewLine;
bool atBottom;
......@@ -142,7 +144,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) {
connect (verticalScrollBar (), SIGNAL (valueChanged (int)), this, SLOT (sliderChanged (int)));
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);
QTextOption opt;
opt.setWrapMode (QTextOption::WrapAtWordBoundaryOrAnywhere);
......@@ -232,7 +234,7 @@ void cConsole::setFont (QFont f) {
QFontMetrics fm (f);
d->charWidth = fm.width ("m");
d->charHeight = fm.lineSpacing();
d->charHeight = fm.lineSpacing() + 2;
fixupOutput();
}
......@@ -311,7 +313,13 @@ void cConsole::forceEmitSize () {
}
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) {
......@@ -372,6 +380,9 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
if (d->wantNewLine) {
cursor.insertBlock ();
d->wantNewLine = false;
QTextBlockFormat bformat = cursor.blockFormat();
bformat.setLineHeight (2, QTextBlockFormat::LineDistanceHeight);
cursor.setBlockFormat (bformat);
}
cursor.insertHtml (chunk->toHTML());
......
......@@ -717,7 +717,7 @@ QString cTextChunk::toHTML ()
for (it = _entries.begin(); it != _entries.end(); ++it)
s += (*it)->toHTML (suffix);
s += suffix;
return s;
return "<p>" + s + "</p>";
}
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