mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 02:49:46 +00:00
Better title for ViewSource
The title is changed to "LaTeX (pdflatex) Preview", etc. depending on the
format. The actual default format is computed.
The menu name "Source Pane" is replaced by "Code Preview Pane" to better reflect
its purpose.
(cherry-picked from ca58674267
)
This commit is contained in:
parent
9ddfa717f2
commit
dfc1ebb480
@ -336,7 +336,7 @@ Menuset
|
|||||||
Item "Fold Math Macro|d" "math-macro-fold"
|
Item "Fold Math Macro|d" "math-macro-fold"
|
||||||
Separator
|
Separator
|
||||||
Item "Outline Pane|u" "dialog-toggle toc"
|
Item "Outline Pane|u" "dialog-toggle toc"
|
||||||
Item "Source Pane|S" "dialog-toggle view-source"
|
Item "Code Preview Pane|P" "dialog-toggle view-source"
|
||||||
Item "Messages Pane|g" "dialog-toggle progress"
|
Item "Messages Pane|g" "dialog-toggle progress"
|
||||||
Submenu "Toolbars|b" "toolbars"
|
Submenu "Toolbars|b" "toolbars"
|
||||||
Separator
|
Separator
|
||||||
|
@ -839,6 +839,7 @@ FlavorTranslator initFlavorTranslator()
|
|||||||
f.addPair(OutputParams::XML, "docbook-xml");
|
f.addPair(OutputParams::XML, "docbook-xml");
|
||||||
f.addPair(OutputParams::HTML, "xhtml");
|
f.addPair(OutputParams::HTML, "xhtml");
|
||||||
f.addPair(OutputParams::TEXT, "text");
|
f.addPair(OutputParams::TEXT, "text");
|
||||||
|
f.addPair(OutputParams::LYX, "lyx");
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,12 @@ void ViewSourceWidget::contentsChanged()
|
|||||||
void ViewSourceWidget::setViewFormat(int const index)
|
void ViewSourceWidget::setViewFormat(int const index)
|
||||||
{
|
{
|
||||||
outputFormatCO->setCurrentIndex(index);
|
outputFormatCO->setCurrentIndex(index);
|
||||||
view_format_ = outputFormatCO->itemData(index).toString();
|
string format = fromqstr(outputFormatCO->itemData(index).toString());
|
||||||
|
if (view_format_ != format) {
|
||||||
|
view_format_ = format;
|
||||||
|
// emit signal
|
||||||
|
formatChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -184,8 +189,6 @@ void ViewSourceWidget::realUpdateView()
|
|||||||
// we will try to preserve this
|
// we will try to preserve this
|
||||||
int const h_scroll = viewSourceTV->horizontalScrollBar()->value();
|
int const h_scroll = viewSourceTV->horizontalScrollBar()->value();
|
||||||
|
|
||||||
string const format = fromqstr(view_format_);
|
|
||||||
|
|
||||||
Buffer::OutputWhat output = Buffer::CurrentParagraph;
|
Buffer::OutputWhat output = Buffer::CurrentParagraph;
|
||||||
if (contentsCO->currentIndex() == 1)
|
if (contentsCO->currentIndex() == 1)
|
||||||
output = Buffer::FullSource;
|
output = Buffer::FullSource;
|
||||||
@ -195,7 +198,8 @@ void ViewSourceWidget::realUpdateView()
|
|||||||
output = Buffer::OnlyBody;
|
output = Buffer::OnlyBody;
|
||||||
|
|
||||||
docstring content;
|
docstring content;
|
||||||
getContent(bv_, output, content, format, masterPerspectiveCB->isChecked());
|
getContent(bv_, output, content, view_format_,
|
||||||
|
masterPerspectiveCB->isChecked());
|
||||||
QString old = document_->toPlainText();
|
QString old = document_->toPlainText();
|
||||||
QString qcontent = toqstr(content);
|
QString qcontent = toqstr(content);
|
||||||
#ifdef DEVEL_VERSION
|
#ifdef DEVEL_VERSION
|
||||||
@ -305,6 +309,16 @@ void ViewSourceWidget::realUpdateView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring ViewSourceWidget::currentFormatName() const
|
||||||
|
{
|
||||||
|
// Compute the actual format used
|
||||||
|
string const format = !bv_ ? ""
|
||||||
|
: flavor2format(bv_->buffer().params().getOutputFlavor(view_format_));
|
||||||
|
Format const * f = formats.getFormat(format.empty() ? view_format_ : format);
|
||||||
|
return from_utf8(f ? f->prettyname() : view_format_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// only used in DEVEL_MODE for debugging
|
// only used in DEVEL_MODE for debugging
|
||||||
// need a proper LFUN if we want to implement it in release mode
|
// need a proper LFUN if we want to implement it in release mode
|
||||||
void ViewSourceWidget::gotoCursor()
|
void ViewSourceWidget::gotoCursor()
|
||||||
@ -340,9 +354,8 @@ void ViewSourceWidget::updateDefaultFormat()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString const pretty = qt_(fmt->prettyname());
|
QString const pretty = qt_(fmt->prettyname());
|
||||||
QString const qformat = toqstr(format);
|
outputFormatCO->addItem(pretty, QVariant(toqstr(format)));
|
||||||
outputFormatCO->addItem(pretty, QVariant(qformat));
|
if (format == view_format_)
|
||||||
if (qformat == view_format_)
|
|
||||||
index = outputFormatCO->count() -1;
|
index = outputFormatCO->count() -1;
|
||||||
}
|
}
|
||||||
setViewFormat(index);
|
setViewFormat(index);
|
||||||
@ -366,7 +379,7 @@ void ViewSourceWidget::resizeEvent (QResizeEvent * event)
|
|||||||
void ViewSourceWidget::saveSession(QString const & session_key) const
|
void ViewSourceWidget::saveSession(QString const & session_key) const
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue(session_key + "/output", view_format_);
|
settings.setValue(session_key + "/output", toqstr(view_format_));
|
||||||
settings.setValue(session_key + "/contents", contentsCO->currentIndex());
|
settings.setValue(session_key + "/contents", contentsCO->currentIndex());
|
||||||
settings.setValue(session_key + "/autoupdate", autoUpdateCB->isChecked());
|
settings.setValue(session_key + "/autoupdate", autoUpdateCB->isChecked());
|
||||||
settings.setValue(session_key + "/masterview",
|
settings.setValue(session_key + "/masterview",
|
||||||
@ -377,7 +390,8 @@ void ViewSourceWidget::saveSession(QString const & session_key) const
|
|||||||
void ViewSourceWidget::restoreSession(QString const & session_key)
|
void ViewSourceWidget::restoreSession(QString const & session_key)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
view_format_ = settings.value(session_key + "/output", 0).toString();
|
view_format_ = fromqstr(settings.value(session_key + "/output", 0)
|
||||||
|
.toString());
|
||||||
contentsCO->setCurrentIndex(settings
|
contentsCO->setCurrentIndex(settings
|
||||||
.value(session_key + "/contents", 0)
|
.value(session_key + "/contents", 0)
|
||||||
.toInt());
|
.toInt());
|
||||||
@ -395,10 +409,11 @@ void ViewSourceWidget::restoreSession(QString const & session_key)
|
|||||||
|
|
||||||
GuiViewSource::GuiViewSource(GuiView & parent,
|
GuiViewSource::GuiViewSource(GuiView & parent,
|
||||||
Qt::DockWidgetArea area, Qt::WindowFlags flags)
|
Qt::DockWidgetArea area, Qt::WindowFlags flags)
|
||||||
: DockView(parent, "view-source", qt_("LaTeX Source"), area, flags)
|
: DockView(parent, "view-source", qt_("Code Preview"), area, flags)
|
||||||
{
|
{
|
||||||
widget_ = new ViewSourceWidget;
|
widget_ = new ViewSourceWidget;
|
||||||
setWidget(widget_);
|
setWidget(widget_);
|
||||||
|
connect(widget_, SIGNAL(formatChanged()), this, SLOT(updateTitle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -415,6 +430,7 @@ void GuiViewSource::updateView()
|
|||||||
widget_->updateView();
|
widget_->updateView();
|
||||||
}
|
}
|
||||||
widget_->masterPerspectiveCB->setEnabled(buffer().parent());
|
widget_->masterPerspectiveCB->setEnabled(buffer().parent());
|
||||||
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -430,24 +446,19 @@ void GuiViewSource::enableView(bool enable)
|
|||||||
|
|
||||||
bool GuiViewSource::initialiseParams(string const & /*source*/)
|
bool GuiViewSource::initialiseParams(string const & /*source*/)
|
||||||
{
|
{
|
||||||
setWindowTitle(title());
|
updateTitle();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GuiViewSource::title() const
|
void GuiViewSource::updateTitle()
|
||||||
{
|
{
|
||||||
switch (docType()) {
|
docstring const format = widget_->currentFormatName();
|
||||||
case LATEX:
|
QString const title = format.empty() ? qt_("Code Preview")
|
||||||
//FIXME: this is shown for LyXHTML source, LyX source, etc.
|
: qt_("%1[[preview format name]] Preview")
|
||||||
return qt_("LaTeX Source");
|
.arg(toqstr(translateIfPossible(format)));
|
||||||
case DOCBOOK:
|
setTitle(title);
|
||||||
return qt_("DocBook Source");
|
setWindowTitle(title);
|
||||||
case LITERATE:
|
|
||||||
return qt_("Literate Source");
|
|
||||||
}
|
|
||||||
LATTEST(false);
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,11 @@ public Q_SLOTS:
|
|||||||
void contentsChanged();
|
void contentsChanged();
|
||||||
///
|
///
|
||||||
void gotoCursor();
|
void gotoCursor();
|
||||||
|
/// Name of the current format. Empty if none.
|
||||||
|
docstring currentFormatName() const;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void formatChanged() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
/// update content
|
/// update content
|
||||||
@ -80,7 +85,7 @@ private:
|
|||||||
/// LaTeX syntax highlighter
|
/// LaTeX syntax highlighter
|
||||||
LaTeXHighlighter * highlighter_;
|
LaTeXHighlighter * highlighter_;
|
||||||
///
|
///
|
||||||
QString view_format_;
|
std::string view_format_;
|
||||||
///
|
///
|
||||||
QTimer * update_timer_;
|
QTimer * update_timer_;
|
||||||
/// TexRow information from the last source view. If TexRow is unavailable
|
/// TexRow information from the last source view. If TexRow is unavailable
|
||||||
@ -116,8 +121,9 @@ public:
|
|||||||
bool wantInitialFocus() const { return false; }
|
bool wantInitialFocus() const { return false; }
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
/// The title displayed by the dialog reflects source type.
|
/// The title displayed by the dialog reflects source type.
|
||||||
QString title() const;
|
void updateTitle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The encapsulated widget.
|
/// The encapsulated widget.
|
||||||
|
Loading…
Reference in New Issue
Block a user