#include <boost/crc.hpp>
+#include <QBoxLayout>
#include <QSettings>
#include <QTextCursor>
#include <QTextDocument>
updatePB, SLOT(setDisabled(bool)));
connect(autoUpdateCB, SIGNAL(toggled(bool)),
this, SLOT(updateView()));
+ connect(masterPerspectiveCB, SIGNAL(toggled(bool)),
+ this, SLOT(updateView()));
connect(updatePB, SIGNAL(clicked()),
this, SLOT(updateView()));
connect(outputFormatCO, SIGNAL(activated(int)),
///dialog_->viewSourceTV->setAcceptRichText(false);
// this is personal. I think source code should be in fixed-size font
QFont font(guiApp->typewriterFontName());
- font.setKerning(false);
font.setFixedPitch(true);
font.setStyleHint(QFont::TypeWriter);
viewSourceTV->setFont(font);
\return true if the content has changed since last call.
*/
static bool getContent(BufferView const * view, Buffer::OutputWhat output,
- QString & qstr, string const format, bool force_getcontent)
+ QString & qstr, string const & format, bool force_getcontent,
+ bool master)
{
// get the *top* level paragraphs that contain the cursor,
// or the selected text
if (par_begin > par_end)
swap(par_begin, par_end);
odocstringstream ostr;
- view->buffer().getSourceCode(ostr, format, par_begin, par_end + 1, output);
+ view->buffer().getSourceCode(ostr, format, par_begin, par_end + 1,
+ output, master);
docstring s = ostr.str();
+ // FIXME THREAD
+ // Could this be private to this particular dialog? We could have
+ // more than one of these, in different windows.
static size_t crc = 0;
size_t newcrc = crcCheck(s);
if (newcrc == crc && !force_getcontent)
updateView();
}
+
void ViewSourceWidget::updateView()
{
if (!bv_) {
else if (contentsCO->currentIndex() == 3)
output = Buffer::OnlyBody;
- if (getContent(bv_, output, content, format, force_getcontent_))
+ if (getContent(bv_, output, content, format,
+ force_getcontent_, masterPerspectiveCB->isChecked()))
document_->setPlainText(content);
CursorSlice beg = bv_->cursor().selectionBegin().bottom();
outputFormatCO->addItem(qt_("Default"),
QVariant(QString("default")));
+ int index = 0;
vector<string> tmp = bv_->buffer().params().backends();
vector<string>::const_iterator it = tmp.begin();
vector<string>::const_iterator en = tmp.end();
for (; it != en; ++it) {
string const format = *it;
Format const * fmt = formats.getFormat(format);
- if (!fmt)
+ if (!fmt) {
LYXERR0("Can't find format for backend " << format << "!");
- else if (fmt->name() == "lyx")
- // we can't presently display the LyX format itself
continue;
+ }
- QString const pretty =
- fmt ? qt_(fmt->prettyname()) : toqstr(format);
- outputFormatCO->addItem(pretty, QVariant(toqstr(format)));
+ QString const pretty = qt_(fmt->prettyname());
+ QString const qformat = toqstr(format);
+ outputFormatCO->addItem(pretty, QVariant(qformat));
+ if (qformat == view_format_)
+ index = outputFormatCO->count() -1;
}
+ outputFormatCO->setCurrentIndex(index);
outputFormatCO->blockSignals(false);
}
+void ViewSourceWidget::resizeEvent (QResizeEvent * event)
+{
+ QSize const & formSize = formLayout->sizeHint();
+ // minimize the size of the part that contains the buttons
+ if (width() * formSize.height() < height() * formSize.width()) {
+ layout_->setDirection(QBoxLayout::TopToBottom);
+ } else {
+ layout_->setDirection(QBoxLayout::LeftToRight);
+ }
+ QWidget::resizeEvent(event);
+}
+
+
GuiViewSource::GuiViewSource(GuiView & parent,
Qt::DockWidgetArea area, Qt::WindowFlags flags)
: DockView(parent, "view-source", qt_("LaTeX Source"), area, flags)
{
- widget_ = new ViewSourceWidget();
+ widget_ = new ViewSourceWidget;
setWidget(widget_);
}
widget_->setBufferView(bufferview());
widget_->updateView();
}
+ widget_->masterPerspectiveCB->setEnabled(buffer().parent());
}
case LITERATE:
return qt_("Literate Source");
}
- LASSERT(false, /**/);
+ LATTEST(false);
return QString();
}