]> git.lyx.org Git - features.git/commitdiff
Fix bug #11781. Patch from Daniel.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 27 Nov 2022 18:16:00 +0000 (13:16 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 27 Nov 2022 18:20:17 +0000 (13:20 -0500)
src/BufferParams.cpp
src/Changes.cpp
src/Color.cpp
src/ColorCode.h
src/Compare.cpp
src/Compare.h
src/frontends/qt/GuiCompare.cpp
src/frontends/qt/ui/CompareUi.ui

index 6bb90d0be0b1a8d323d8946254757fab67b8bac6..f1425b83354277384b7e38e39554b3a97df7d461 100644 (file)
@@ -370,6 +370,9 @@ BufferParams::Impl::Impl()
        authorlist.record(Author(from_utf8(lyxrc.user_name),
                                 from_utf8(lyxrc.user_email),
                                 from_utf8(lyxrc.user_initials)));
+       // set comparison author
+       authorlist.record(Author(from_utf8("Document Comparison"),
+                                docstring(), docstring()));
 }
 
 
index 1bdbbf34ffeb53135d263649de99e960045e8eeb..16bbb2fdd64452f0bbe789cda3097fff50a86bb0 100644 (file)
@@ -71,22 +71,25 @@ bool Change::isSimilarTo(Change const & change) const
 Color Change::color() const
 {
        Color color = Color_none;
-       switch (author % 5) {
-               case 0:
-                       color = Color_changedtext_workarea_author1;
-                       break;
-               case 1:
-                       color = Color_changedtext_workarea_author2;
-                       break;
-               case 2:
-                       color = Color_changedtext_workarea_author3;
-                       break;
-               case 3:
-                       color = Color_changedtext_workarea_author4;
-                       break;
-               case 4:
-                       color = Color_changedtext_workarea_author5;
-                       break;
+       if (author == 0)
+               color = Color_changedtext_workarea_author1;
+       else if (author == 1)
+               color = Color_changedtext_workarea_comparison;
+       else {
+               switch ((author - 2) % 4) {
+                       case 0:
+                               color = Color_changedtext_workarea_author2;
+                               break;
+                       case 1:
+                               color = Color_changedtext_workarea_author3;
+                               break;
+                       case 2:
+                               color = Color_changedtext_workarea_author4;
+                               break;
+                       case 3:
+                               color = Color_changedtext_workarea_author5;
+                               break;
+               }
        }
 
        if (deleted())
index 7cb520d27896db59ce04c52c2dae0066a1e736ee..aaa7d0208f5bd54078eb9c5ad5bfe297d960806d 100644 (file)
@@ -329,6 +329,7 @@ ColorSet::ColorSet()
        { Color_changedtext_workarea_author3, N_("changed text (workarea, 3rd author)"), "changedtextauthor3", "#ff0000", "#ea8989", "changedtextauthor3" },
        { Color_changedtext_workarea_author4, N_("changed text (workarea, 4th author)"), "changedtextauthor4", "#aa00ff", "#c371ec", "changedtextauthor4" },
        { Color_changedtext_workarea_author5, N_("changed text (workarea, 5th author)"), "changedtextauthor5", "#55aa00", "#acd780", "changedtextauthor5" },
+       { Color_changedtext_workarea_comparison, N_("changed text (workarea, document comparison)"), "changedtextcomparison", "#008080", "#719FB0", "changedtextcomparison" },
        { Color_deletedtext_workarea_modifier, N_("deleted text modifier (workarea)"), "deletedtextmodifier", white, white, "deletedtextmodifier" },
        { Color_added_space, N_("added space markers"), "added_space", Brown, Brown, "added_space" },
        { Color_tabularline, N_("table line"), "tabularline", black, Linen, "tabularline" },
index e1a6b0aaa1292f5de860826263115c8012f40494..f2d0f68a292e52b7b542324b0c0524ef4d0a5f42 100644 (file)
@@ -196,6 +196,8 @@ enum ColorCode {
        Color_changedtext_workarea_author4,
        /// Changed text color author 5 (workarea)
        Color_changedtext_workarea_author5,
+       /// Changed text color document comparison (workarea)
+       Color_changedtext_workarea_comparison,
        /// Deleted text modifying color (workarea)
        Color_deletedtext_workarea_modifier,
        /// Table line color
index 17bd0120647843603cdf7e19e205d3042dedf483..82236aa8de7f5eea7af0d69ec15d2ff8bf2b6290 100644 (file)
@@ -866,7 +866,7 @@ void Compare::Impl::writeToDestBuffer(DocRange const & range,
        // Set the change
        ParagraphList::iterator it = pars.begin();
        for (; it != pars.end(); ++it) {
-               it->setChange(Change(type));
+               it->setChange(Change(type, compare_.options_.author));
                size += it->size();
        }
 
index 1c93fb58cee64c17ca8f0a1dfd7ce3a58ecee5c4..df2c7facd53f24f02f155e4bced14cdb732f26cc 100644 (file)
@@ -30,11 +30,13 @@ class CompareOptions {
 public:
        ///
        CompareOptions()
-               : settings_from_new(0)
+               : settings_from_new(0), author(0)
        {}
 
        /// Copy the settings from the new or old document
        bool settings_from_new;
+       /// Author id for change tracking
+       bool author;
 };
 
 /**
index 7f6b00f44a096a484da594c938624a4ea8a23468..e485ec0a548c6de028a6ae5ed6952dfcfd8a84b4 100644 (file)
 
 #include "GuiCompare.h"
 
+#include "GuiApplication.h"
+
 #include "Buffer.h"
 #include "BufferView.h"
 #include "BufferList.h"
 #include "buffer_funcs.h"
+#include "ColorCache.h"
 #include "Compare.h"
 #include "FuncRequest.h"
 #include "GuiView.h"
@@ -329,6 +332,7 @@ int GuiCompare::run(bool blocking_mode)
        // get the options from the dialog
        CompareOptions options;
        options.settings_from_new = newSettingsRB->isChecked();
+       options.author = authorCO->currentIndex();
 
        // init the compare object and start it
 
@@ -385,6 +389,19 @@ bool GuiCompare::initialiseParams(std::string const &par)
        progressBar->setEnabled(false);
        progressBar->setMaximum(1);
 
+       // If empty fill the author combobox with the current and the comparison
+       // author and their respective colors
+       if (authorCO->count() == 0) {
+               authorCO->clear();
+               QPixmap colorIcon(32, 32);
+               colorIcon.fill(guiApp->colorCache().get(
+                       Color(Color_changedtext_workarea_author1)));
+               authorCO->addItem(colorIcon, qt_("Current Author"));
+               colorIcon.fill(guiApp->colorCache().get(
+                       Color(Color_changedtext_workarea_comparison)));
+               authorCO->addItem(colorIcon, qt_("Document Comparison"));
+       }
+
        return true;
 }
 
index 31519323ce01dbba9ce6c3456e89c5b8b3855d0f..d8da529eb7c9c368abd76af365b2235865179556 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>622</width>
-    <height>288</height>
+    <height>299</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -17,7 +17,7 @@
    <bool>true</bool>
   </property>
   <layout class="QGridLayout" name="gridLayout_2">
-   <item row="5" column="0">
+   <item row="10" column="0">
     <widget class="QProgressBar" name="progressBar">
      <property name="value">
       <number>24</number>
      </property>
     </widget>
    </item>
+   <item row="1" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>4</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="0" colspan="2">
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QGroupBox" name="groupBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="toolTip">
+        <string>Select the document from which the settings should be taken</string>
+       </property>
+       <property name="title">
+        <string>Document Settings</string>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <item>
+         <widget class="QRadioButton" name="oldSettingsRB">
+          <property name="text">
+           <string>O&amp;ld Document</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="newSettingsRB">
+          <property name="text">
+           <string>New Docu&amp;ment</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="7" column="0" colspan="2">
+    <widget class="QCheckBox" name="trackingCB">
+     <property name="toolTip">
+      <string>Turns on the change tracking and showing changes in LaTeX output for the resulting document</string>
+     </property>
+     <property name="text">
+      <string>&amp;Enable change tracking features in the output</string>
+     </property>
+     <property name="checked">
+      <bool>false</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="8" column="0">
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>4</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
    <item row="0" column="0" colspan="2">
     <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0">
      </item>
     </layout>
    </item>
-   <item row="2" column="0" colspan="2">
-    <layout class="QHBoxLayout" name="horizontalLayout_3">
-     <item>
-      <widget class="QGroupBox" name="groupBox">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="toolTip">
-        <string>Select the document from which the settings should be taken</string>
-       </property>
-       <property name="title">
-        <string>Document Settings</string>
-       </property>
-       <property name="flat">
-        <bool>true</bool>
-       </property>
-       <layout class="QHBoxLayout" name="horizontalLayout">
-        <item>
-         <widget class="QRadioButton" name="oldSettingsRB">
-          <property name="text">
-           <string>O&amp;ld Document</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QRadioButton" name="newSettingsRB">
-          <property name="text">
-           <string>New Docu&amp;ment</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>40</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item row="6" column="0" colspan="2">
+   <item row="11" column="0" colspan="2">
     <layout class="QHBoxLayout">
      <item>
       <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0">
      </item>
     </layout>
    </item>
-   <item row="3" column="0" colspan="2">
-    <widget class="QCheckBox" name="trackingCB">
-     <property name="toolTip">
-      <string>Turns on the change tracking and showing changes in LaTeX output for the resulting document</string>
-     </property>
-     <property name="text">
-      <string>&amp;Enable change tracking features in the output</string>
-     </property>
-     <property name="checked">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="0">
-    <spacer name="verticalSpacer_2">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>4</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="1" column="0">
-    <spacer name="verticalSpacer">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeType">
-      <enum>QSizePolicy::Fixed</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>4</height>
-      </size>
-     </property>
-    </spacer>
+   <item row="3" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout_5">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Mark changes in the workarea as </string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="authorCO"/>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </spacer>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>