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.
14 #include "qt_helpers.h"
16 #include "frontends/Application.h"
18 #include <QCloseEvent>
19 #include <QTextBrowser>
20 #include <QTextBrowser>
25 /////////////////////////////////////////////////////////////////////
29 /////////////////////////////////////////////////////////////////////
32 GuiLogDialog::GuiLogDialog(GuiLog * form)
37 connect(closePB, SIGNAL(clicked()),
38 form, SLOT(slotClose()));
39 connect( updatePB, SIGNAL( clicked() ),
40 this, SLOT( updateClicked() ) );
44 void GuiLogDialog::closeEvent(QCloseEvent * e)
51 void GuiLogDialog::updateClicked()
53 form_->update_contents();
57 /////////////////////////////////////////////////////////////////////
61 /////////////////////////////////////////////////////////////////////
63 LogHighlighter::LogHighlighter(QTextDocument * parent)
64 : QSyntaxHighlighter(parent)
66 infoFormat.setForeground(Qt::darkGray);
67 warningFormat.setForeground(Qt::darkBlue);
68 errorFormat.setForeground(Qt::red);
72 void LogHighlighter::highlightBlock(QString const & text)
75 QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$");
76 int index = text.indexOf(exprInfo);
78 int length = exprInfo.matchedLength();
79 setFormat(index, length, infoFormat);
80 index = text.indexOf(exprInfo, index + length);
83 QRegExp exprWarning("^LaTeX Warning.*$");
84 index = text.indexOf(exprWarning);
86 int length = exprWarning.matchedLength();
87 setFormat(index, length, warningFormat);
88 index = text.indexOf(exprWarning, index + length);
91 QRegExp exprError("^!.*$");
92 index = text.indexOf(exprError);
94 int length = exprError.matchedLength();
95 setFormat(index, length, errorFormat);
96 index = text.indexOf(exprError, index + length);
101 /////////////////////////////////////////////////////////////////////
105 /////////////////////////////////////////////////////////////////////
108 GuiLog::GuiLog(Dialog & parent)
109 : GuiView<GuiLogDialog>(parent, docstring())
113 void GuiLog::build_dialog()
115 dialog_.reset(new GuiLogDialog(this));
116 // set syntax highlighting
117 highlighter = new LogHighlighter(dialog_->logTB->document());
119 dialog_->logTB->setReadOnly(true);
120 QFont font(toqstr(theApp()->typewriterFontName()));
121 font.setKerning(false);
122 font.setFixedPitch(true);
123 font.setStyleHint(QFont::TypeWriter);
124 dialog_->logTB->setFont(font);
128 void GuiLog::update_contents()
130 setTitle(controller().title());
132 std::ostringstream ss;
133 controller().getContents(ss);
135 dialog_->logTB->setPlainText(toqstr(ss.str()));
138 } // namespace frontend
141 #include "GuiLog_moc.cpp"