From: Richard Heck Date: Mon, 5 Mar 2012 22:51:53 +0000 (+0000) Subject: Backport fix for #7997. X-Git-Tag: 2.0.4~193 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8d3e242755eea5daaebc6e60aa3b35e29e60cdee;p=features.git Backport fix for #7997. 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/branches/BRANCH_2_0_X@40864 a592a061-630c-0410-9148-cb99ea01b6c8 --- 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 + diff --git a/src/frontends/qt4/ui/ViewSourceUi.ui.old b/src/frontends/qt4/ui/ViewSourceUi.ui.old new file mode 100644 index 0000000000..286703c7db --- /dev/null +++ b/src/frontends/qt4/ui/ViewSourceUi.ui.old @@ -0,0 +1,122 @@ + + + ViewSourceUi + + + + 0 + 0 + 528 + 205 + + + + + + + + + + + 0 + 0 + + + + + + + + + + + F&ormat: + + + outputFormatCO + + + + + + + true + + + Select the output format + + + QComboBox::AdjustToContents + + + + + + + + Current Paragraph + + + + + Complete Source + + + + + Preamble Only + + + + + Body Only + + + + + + + + Automatic update + + + true + + + + + + + false + + + &Update + + + + + + + Qt::Vertical + + + + 20 + 85 + + + + + + + + viewSourceTV + autoUpdateCB + updatePB + + + qt_i18n.h + + + + diff --git a/status.20x b/status.20x index 3bfc15d8a4..da525fe2d1 100644 --- a/status.20x +++ b/status.20x @@ -80,6 +80,9 @@ What's new - Fixed stray warning when inserting inserting plaintext file (bug 7916). +- Don't reset the selected format each time we click into a new paragraph + in View>Source (bug 7997). + * DOCUMENTATION AND LOCALIZATION