lyx_mirror/src/frontends/qt3/QViewSource.C
Bo Peng 3002118616 Add more controls to the view-source dialog.
* src/buffer.[nC]: can write full source, separaet/rename makeXXXFile.
	* src/graphics/PreviewLoader.C: rename maleLaTeXFile to writeLaTeXSource
	* src/frontends/qt3/QViewSourceDialog.h, ui/QViewSourceDialogBase.ui,
		QViewSource.[hC], QViewSourceDialog.[hC]: qt3 frontend
	* src/frontends/qt4/QViewSource.[hC], ui/QViewSourceUi.ui,
		QViewSourceDialog.[hC]: qt4 frontend
	* src/frontends/controllers/ControlViewSource.[hC]: controller


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14539 a592a061-630c-0410-9148-cb99ea01b6c8
2006-08-04 13:59:12 +00:00

68 lines
1.5 KiB
C

/**
* \file QViewSource.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Bo Peng
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "QViewSource.h"
#include "QViewSourceDialog.h"
#include "qt_helpers.h"
#include "lyx_gui.h"
#include "controllers/ControlViewSource.h"
#include <sstream>
#include <qtextview.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
namespace lyx {
namespace frontend {
typedef QController<ControlViewSource, QView<QViewSourceDialog> > base_class;
QViewSource::QViewSource(Dialog & parent)
: base_class(parent, "")
{}
void QViewSource::build_dialog()
{
dialog_.reset(new QViewSourceDialog(this));
dialog_->viewSourceTV->setReadOnly(true);
dialog_->viewSourceTV->setTextFormat(Qt::PlainText);
// this is personal. I think source code should be in fixed-size font
QFont font(toqstr(lyx_gui::typewriter_font_name()));
font.setFixedPitch(true);
font.setStyleHint(QFont::TypeWriter);
dialog_->viewSourceTV->setFont(font);
// again, personal taste
dialog_->viewSourceTV->setWordWrap(QTextEdit::NoWrap);
}
void QViewSource::update_source()
{
bool fullSource = dialog_->viewFullSourceCB->isChecked();
dialog_->viewSourceTV->setText(toqstr(controller().updateContent(fullSource)));
}
void QViewSource::update_contents()
{
setTitle(controller().title());
if (dialog_->autoUpdateCB->isChecked())
update_source();
}
} // namespace frontend
} // namespace lyx