commit 5db9e91f16eed97bd28d5c69cbe6620fe44b35a2
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Sun Nov 27 13:16:00 2022 -0500

    Fix bug #11781. Patch from Daniel.
---
 src/BufferParams.cpp             |    3 +
 src/Changes.cpp                  |   35 ++++---
 src/Color.cpp                    |    1 +
 src/ColorCode.h                  |    2 +
 src/Compare.cpp                  |    2 +-
 src/Compare.h                    |    4 +-
 src/frontends/qt/GuiCompare.cpp  |   17 +++
 src/frontends/qt/ui/CompareUi.ui |  213 +++++++++++++++++++++-----------------
 8 files changed, 163 insertions(+), 114 deletions(-)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 6bb90d0..f1425b8 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -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()));
 }
 
 
diff --git a/src/Changes.cpp b/src/Changes.cpp
index 1bdbbf3..16bbb2f 100644
--- a/src/Changes.cpp
+++ b/src/Changes.cpp
@@ -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())
diff --git a/src/Color.cpp b/src/Color.cpp
index 7cb520d..aaa7d02 100644
--- a/src/Color.cpp
+++ b/src/Color.cpp
@@ -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" },
diff --git a/src/ColorCode.h b/src/ColorCode.h
index e1a6b0a..f2d0f68 100644
--- a/src/ColorCode.h
+++ b/src/ColorCode.h
@@ -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
diff --git a/src/Compare.cpp b/src/Compare.cpp
index 17bd012..82236aa 100644
--- a/src/Compare.cpp
+++ b/src/Compare.cpp
@@ -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();
        }
 
diff --git a/src/Compare.h b/src/Compare.h
index 1c93fb5..df2c7fa 100644
--- a/src/Compare.h
+++ b/src/Compare.h
@@ -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;
 };
 
 /**
diff --git a/src/frontends/qt/GuiCompare.cpp b/src/frontends/qt/GuiCompare.cpp
index 7f6b00f..e485ec0 100644
--- a/src/frontends/qt/GuiCompare.cpp
+++ b/src/frontends/qt/GuiCompare.cpp
@@ -12,10 +12,13 @@
 
 #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;
 }
 
diff --git a/src/frontends/qt/ui/CompareUi.ui b/src/frontends/qt/ui/CompareUi.ui
index 3151932..d8da529 100644
--- a/src/frontends/qt/ui/CompareUi.ui
+++ b/src/frontends/qt/ui/CompareUi.ui
@@ -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>
@@ -27,6 +27,100 @@
      </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">
@@ -103,59 +197,7 @@
      </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">
@@ -177,47 +219,26 @@
      </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>
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to