]> git.lyx.org Git - features.git/blob - src/frontends/qt3/QViewSource.C
This commit is purely mechanical and get rid of lyx_gui.[Ch].
[features.git] / src / frontends / qt3 / QViewSource.C
1 /**
2  * \file QViewSource.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Bo Peng
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "QViewSource.h"
15 #include "QViewSourceDialog.h"
16 #include "qt_helpers.h"
17
18 #include "frontends/Application.h"
19
20 #include "controllers/ControlViewSource.h"
21
22 #include <sstream>
23
24 #include <qtextview.h>
25 #include <qpushbutton.h>
26 #include <qcheckbox.h>
27
28 namespace lyx {
29 namespace frontend {
30
31 typedef QController<ControlViewSource, QView<QViewSourceDialog> > base_class;
32
33 QViewSource::QViewSource(Dialog & parent)
34         : base_class(parent, lyx::docstring())
35 {}
36
37
38 void QViewSource::build_dialog()
39 {
40         dialog_.reset(new QViewSourceDialog(this));
41         dialog_->viewSourceTV->setReadOnly(true);
42         dialog_->viewSourceTV->setTextFormat(Qt::PlainText);
43         // this is personal. I think source code should be in fixed-size font
44         QFont font(toqstr(theApp->typewriterFontName()));
45         font.setFixedPitch(true);
46         font.setStyleHint(QFont::TypeWriter);
47         dialog_->viewSourceTV->setFont(font);
48         // again, personal taste
49         dialog_->viewSourceTV->setWordWrap(QTextEdit::NoWrap);
50 }
51
52
53 void QViewSource::update_source()
54 {
55         bool fullSource = dialog_->viewFullSourceCB->isChecked();
56         dialog_->viewSourceTV->setText(toqstr(controller().updateContent(fullSource)));
57 }
58
59
60 void QViewSource::update_contents()
61 {
62         setTitle(controller().title());
63         if (dialog_->autoUpdateCB->isChecked())
64                 update_source();
65 }
66
67 } // namespace frontend
68 } // namespace lyx