]> git.lyx.org Git - features.git/commitdiff
Backport fix for #7997.
authorRichard Heck <rgheck@comcast.net>
Mon, 5 Mar 2012 22:51:53 +0000 (22:51 +0000)
committerRichard Heck <rgheck@comcast.net>
Mon, 5 Mar 2012 22:51:53 +0000 (22:51 +0000)
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

src/frontends/qt4/GuiViewSource.cpp
src/frontends/qt4/GuiViewSource.h
src/frontends/qt4/ui/ViewSourceUi.ui
src/frontends/qt4/ui/ViewSourceUi.ui.old [new file with mode: 0644]
status.20x

index 289a54a5a26e2c2ee4dc6a1c87dc01a61e3c5109..8a2309d75dbebe39ca4aef88acfe7b373f78dc63 100644 (file)
@@ -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<Format const *> 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);
 }
 
index 697198301bcef9f7a1d227f09c11150eea123f77..d42c1161af6e05b9efa2812c69c938004026168e 100644 (file)
@@ -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_;
 };
 
 
index b9708e60f9860aee0341c01a1c041603d7608063..286703c7dbfd26d60282f249470fd96c3be1c438 100644 (file)
@@ -45,6 +45,9 @@
      <property name="toolTip">
       <string>Select the output format</string>
      </property>
+     <property name="sizeAdjustPolicy">
+      <enum>QComboBox::AdjustToContents</enum>
+     </property>
     </widget>
    </item>
    <item row="1" column="1" colspan="2">
diff --git a/src/frontends/qt4/ui/ViewSourceUi.ui.old b/src/frontends/qt4/ui/ViewSourceUi.ui.old
new file mode 100644 (file)
index 0000000..286703c
--- /dev/null
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewSourceUi</class>
+ <widget class="QWidget" name="ViewSourceUi">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>528</width>
+    <height>205</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string/>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0" rowspan="5">
+    <widget class="QTextEdit" name="viewSourceTV">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="MinimumExpanding" vsizetype="Ignored">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="whatsThis">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QLabel" name="outputFormatLA">
+     <property name="text">
+      <string>F&amp;ormat:</string>
+     </property>
+     <property name="buddy">
+      <cstring>outputFormatCO</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="2">
+    <widget class="QComboBox" name="outputFormatCO">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
+     <property name="toolTip">
+      <string>Select the output format</string>
+     </property>
+     <property name="sizeAdjustPolicy">
+      <enum>QComboBox::AdjustToContents</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1" colspan="2">
+    <widget class="QComboBox" name="contentsCO">
+     <item>
+      <property name="text">
+       <string>Current Paragraph</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Complete Source</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Preamble Only</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
+       <string>Body Only</string>
+      </property>
+     </item>
+    </widget>
+   </item>
+   <item row="2" column="1" colspan="2">
+    <widget class="QCheckBox" name="autoUpdateCB">
+     <property name="text">
+      <string>Automatic update</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1" colspan="2">
+    <widget class="QPushButton" name="updatePB">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="text">
+      <string>&amp;Update</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="1" colspan="2">
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>85</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>viewSourceTV</tabstop>
+  <tabstop>autoUpdateCB</tabstop>
+  <tabstop>updatePB</tabstop>
+ </tabstops>
+ <includes>
+  <include location="local">qt_i18n.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>
index 3bfc15d8a477cf3293c55f3f3fc01dcc8e77e219..da525fe2d1cadd91311fe74571aeccc0e0e9120d 100644 (file)
@@ -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