From 264cc1139cc3163c4ca61802eed972d97fd38d8d Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 9 Dec 2011 19:48:50 +0000 Subject: [PATCH] The View->Source pane resets the format every time you click into a new paragraph, which is very annoying. This commit fixes this bug. If anyone has a better idea, please let me know. I posted to devel about it but got no response. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40456 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiViewSource.cpp | 23 ++++++++++++++++++----- src/frontends/qt4/GuiViewSource.h | 6 +++++- src/frontends/qt4/ui/ViewSourceUi.ui | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index 289a54a5a2..8a2309d75d 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -58,7 +58,7 @@ ViewSourceWidget::ViewSourceWidget() connect(updatePB, SIGNAL(clicked()), this, SLOT(updateView())); connect(outputFormatCO, SIGNAL(activated(int)), - this, SLOT(updateView())); + this, SLOT(setViewFormat())); // setting a document at this point trigger an assertion in Qt // so we disable the signals here: @@ -136,6 +136,13 @@ void ViewSourceWidget::contentsChanged() } +void ViewSourceWidget::setViewFormat() +{ + view_format_ = outputFormatCO->itemData( + outputFormatCO->currentIndex()).toString(); + updateView(); +} + void ViewSourceWidget::updateView() { if (!bv_) { @@ -146,8 +153,7 @@ void ViewSourceWidget::updateView() setEnabled(true); - string const format = fromqstr(outputFormatCO->itemData( - outputFormatCO->currentIndex()).toString()); + string const format = fromqstr(view_format_); QString content; Buffer::OutputWhat output = Buffer::CurrentParagraph; @@ -190,13 +196,20 @@ void ViewSourceWidget::updateDefaultFormat() outputFormatCO->clear(); outputFormatCO->addItem(qt_("Default"), QVariant(QString("default"))); + + int index = 0; typedef vector Formats; Formats formats = bv_->buffer().params().exportableFormats(true); Formats::const_iterator cit = formats.begin(); Formats::const_iterator end = formats.end(); - for (; cit != end; ++cit) + for (; cit != end; ++cit) { + QString const fname = toqstr((*cit)->name()); outputFormatCO->addItem(qt_((*cit)->prettyname()), - QVariant(toqstr((*cit)->name()))); + QVariant(fname)); + if (fname == view_format_) + index = outputFormatCO->count() -1; + } + outputFormatCO->setCurrentIndex(index); outputFormatCO->blockSignals(false); } diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 697198301b..d42c1161af 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -42,9 +42,11 @@ public: void setBufferView(BufferView const * bv); public Q_SLOTS: - // update content + /// update content void updateView(); /// + void setViewFormat(); + /// void updateDefaultFormat(); /// void contentsChanged(); @@ -58,6 +60,8 @@ private: LaTeXHighlighter * highlighter_; /// bool force_getcontent_; + /// + QString view_format_; }; diff --git a/src/frontends/qt4/ui/ViewSourceUi.ui b/src/frontends/qt4/ui/ViewSourceUi.ui index b9708e60f9..286703c7db 100644 --- a/src/frontends/qt4/ui/ViewSourceUi.ui +++ b/src/frontends/qt4/ui/ViewSourceUi.ui @@ -45,6 +45,9 @@ Select the output format + + QComboBox::AdjustToContents + -- 2.39.5