3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
16 #include "qt_helpers.h"
18 #include "frontends/Application.h"
20 #include <QCloseEvent>
21 #include <QTextBrowser>
22 #include <QTextBrowser>
27 /////////////////////////////////////////////////////////////////////
31 /////////////////////////////////////////////////////////////////////
34 GuiLogDialog::GuiLogDialog(GuiLog * form)
39 connect(closePB, SIGNAL(clicked()),
40 form, SLOT(slotClose()));
41 connect( updatePB, SIGNAL( clicked() ),
42 this, SLOT( updateClicked() ) );
46 void GuiLogDialog::closeEvent(QCloseEvent * e)
53 void GuiLogDialog::updateClicked()
55 form_->update_contents();
59 /////////////////////////////////////////////////////////////////////
63 /////////////////////////////////////////////////////////////////////
65 LogHighlighter::LogHighlighter(QTextDocument * parent)
66 : QSyntaxHighlighter(parent)
68 infoFormat.setForeground(Qt::darkGray);
69 warningFormat.setForeground(Qt::darkBlue);
70 errorFormat.setForeground(Qt::red);
74 void LogHighlighter::highlightBlock(QString const & text)
77 QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$");
78 int index = text.indexOf(exprInfo);
80 int length = exprInfo.matchedLength();
81 setFormat(index, length, infoFormat);
82 index = text.indexOf(exprInfo, index + length);
85 QRegExp exprWarning("^LaTeX Warning.*$");
86 index = text.indexOf(exprWarning);
88 int length = exprWarning.matchedLength();
89 setFormat(index, length, warningFormat);
90 index = text.indexOf(exprWarning, index + length);
93 QRegExp exprError("^!.*$");
94 index = text.indexOf(exprError);
96 int length = exprError.matchedLength();
97 setFormat(index, length, errorFormat);
98 index = text.indexOf(exprError, index + length);
103 /////////////////////////////////////////////////////////////////////
107 /////////////////////////////////////////////////////////////////////
110 GuiLog::GuiLog(GuiDialog & parent)
111 : GuiView<GuiLogDialog>(parent, docstring())
115 void GuiLog::build_dialog()
117 dialog_.reset(new GuiLogDialog(this));
118 // set syntax highlighting
119 highlighter = new LogHighlighter(dialog_->logTB->document());
121 dialog_->logTB->setReadOnly(true);
122 QFont font(toqstr(theApp()->typewriterFontName()));
123 font.setKerning(false);
124 font.setFixedPitch(true);
125 font.setStyleHint(QFont::TypeWriter);
126 dialog_->logTB->setFont(font);
130 void GuiLog::update_contents()
132 setTitle(controller().title());
134 std::ostringstream ss;
135 controller().getContents(ss);
137 dialog_->logTB->setPlainText(toqstr(ss.str()));
140 } // namespace frontend
143 #include "GuiLog_moc.cpp"