From 3837ae8cf961f989d9b05df466f525d272355505 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Tue, 17 Mar 2026 06:10:05 +0300
Subject: Calculate UI colors to mark items in lists

Before that to mark currently processing/queued files predefined colors
were used. This were creating problems especially in darker with
schemas where white next was basically unreadable. Instead of using a
predefined color it now shifts the default color towards red/yellow.

Note: this solution ignores edge case of purely yellow/red backgrounds.

Closes: https://mirror.git.trinitydesktop.org/gitea/TDE/soundkonverter/issues/34
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 src/filelist.cpp           | 28 ++++++++-----------------
 src/filelist.h             | 18 ++++++++++++++++
 src/logviewer.cpp          | 30 +++++++++------------------
 src/replaygainfilelist.cpp | 51 ++++++++++++++++------------------------------
 4 files changed, 54 insertions(+), 73 deletions(-)

diff --git a/src/filelist.cpp b/src/filelist.cpp
index eb8b973..a198346 100644
--- a/src/filelist.cpp
+++ b/src/filelist.cpp
@@ -62,10 +62,6 @@ FileListItem::~FileListItem()
 void FileListItem::paintCell( TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment )
 {
     // NOTE speed up this function
-    // NOTE calculate the red color
-
-    TQColorGroup _cg( cg );
-    TQColor c;
 
     if( column == ((FileList*)listView())->columnByName(i18n("Input")) || column == ((FileList*)listView())->columnByName(i18n("Output")) )
     {
@@ -88,23 +84,17 @@ void FileListItem::paintCell( TQPainter *p, const TQColorGroup &cg, int column,
         }*/
     }
 
-    if( isSelected() && converting ) {
-        _cg.setColor( TQColorGroup::Highlight, TQColor( 215, 62, 62 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( converting && column != listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 255, 234, 234 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( converting && column == listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 247, 227, 227 ) );
+    if( converting ) {
+        TQColorGroup _cg( cg );
+        if ( isSelected() ) {
+            _cg.setColor( TQColorGroup::Highlight, shiftColorToRed(_cg.highlight(), 40) );
+        } else {
+            _cg.setColor( TQColorGroup::Base, shiftColorToRed(backgroundColor(column), 40));
+        }
         TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
+    } else {
+        TDEListViewItem::paintCell( p, cg, column, width, alignment );
     }
-
-    TDEListViewItem::paintCell( p, _cg, column, width, alignment );
 }
 
 /*void FileListItem::updateOutputCell()
diff --git a/src/filelist.h b/src/filelist.h
index 5122caa..e3e7071 100644
--- a/src/filelist.h
+++ b/src/filelist.h
@@ -5,6 +5,8 @@
 
 #include <tdelistview.h>
 
+#include <cstdint>
+
 #include "conversionoptions.h"
 
 class CDManager;
@@ -233,4 +235,20 @@ signals:
     void finished( float );
 };
 
+inline TQColor shiftColorToRed(TQColor c, uint8_t strength) {
+    int r = c.red() + strength * (255 - c.red()) / 255;
+    int g = c.green() * (255 - strength) / 255;
+    int b = c.blue() * (255 - strength) / 255;
+
+    return TQColor(r, g, b);
+}
+
+inline TQColor shiftColorToYellow(TQColor c, uint8_t strength) {
+    int r = c.red() + strength * (255 - c.red()) / 255;
+    int g = c.green() + strength * (255 - c.green()) / 255;
+    int b = c.blue() * (255 - strength) / 255;
+
+    return TQColor(r, g, b);
+}
+
 #endif // FILELIST_H
diff --git a/src/logviewer.cpp b/src/logviewer.cpp
index 21f9881..f965592 100644
--- a/src/logviewer.cpp
+++ b/src/logviewer.cpp
@@ -1,6 +1,7 @@
 
 #include "logviewer.h"
 #include "logger.h"
+#include "filelist.h" //< for color shift functions
 
 #include <tqlayout.h>
 #include <tqstring.h>
@@ -33,28 +34,17 @@ LogViewerItem::~LogViewerItem()
 
 void LogViewerItem::paintCell( TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment )
 {
-    // NOTE calculate the red color
-
-    TQColorGroup _cg( cg );
-    TQColor c;
-
-    if( isSelected() && converting ) {
-        _cg.setColor( TQColorGroup::Highlight, TQColor( 215, 62, 62 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( converting && column != listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 255, 234, 234 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( converting && column == listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 247, 227, 227 ) );
+    if( converting ) {
+        TQColorGroup _cg( cg );
+        if ( isSelected() ) {
+            _cg.setColor( TQColorGroup::Highlight, shiftColorToRed(_cg.highlight(), 40) );
+        } else {
+            _cg.setColor( TQColorGroup::Base, shiftColorToRed(backgroundColor(column), 40));
+        }
         TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
+    } else {
+        TDEListViewItem::paintCell( p, cg, column, width, alignment );
     }
-
-    TDEListViewItem::paintCell( p, _cg, column, width, alignment );
 }
 
 
diff --git a/src/replaygainfilelist.cpp b/src/replaygainfilelist.cpp
index 0a7c88b..8b5952b 100644
--- a/src/replaygainfilelist.cpp
+++ b/src/replaygainfilelist.cpp
@@ -5,6 +5,7 @@
 #include "configuration.h"
 #include "replaygain.h"
 #include "replaygainpluginloader.h"
+#include "filelist.h" //< for color shift functions
 
 #include <tqdir.h>
 #include <tqpainter.h>
@@ -66,10 +67,6 @@ ReplayGainFileListItem::~ReplayGainFileListItem()
 void ReplayGainFileListItem::paintCell( TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment )
 {
     // NOTE speed up this function
-    // NOTE calculate the red color
-
-    TQColorGroup _cg( cg );
-    TQColor c;
 
     if( column == ((ReplayGainFileList*)listView())->columnByName(i18n("File")) )
     {
@@ -83,39 +80,25 @@ void ReplayGainFileListItem::paintCell( TQPainter *p, const TQColorGroup &cg, in
         }
     }
 
-    if( isSelected() && addingReplayGain ) {
-        _cg.setColor( TQColorGroup::Highlight, TQColor( 215, 62, 62 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( addingReplayGain && column != listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 255, 234, 234 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( addingReplayGain && column == listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 247, 227, 227 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-
-    if( isSelected() && queued ) {
-        _cg.setColor( TQColorGroup::Highlight, TQColor( 230, 232, 100 ) );
-        TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( queued && column != listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 255, 255, 190 ) );
+    if( addingReplayGain ) {
+        TQColorGroup _cg( cg );
+        if ( isSelected() ) {
+            _cg.setColor( TQColorGroup::Highlight, shiftColorToRed(_cg.highlight(), 40) );
+        } else {
+            _cg.setColor( TQColorGroup::Base, shiftColorToRed(backgroundColor(column), 40));
+        }
         TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
-    }
-    else if( queued && column == listView()->sortColumn() ) {
-        _cg.setColor( TQColorGroup::Base, TQColor( 255, 243, 168 ) );
+    } else if (queued) {
+        TQColorGroup _cg( cg );
+        if ( isSelected() ) {
+            _cg.setColor( TQColorGroup::Highlight, shiftColorToYellow(_cg.highlight(), 40) );
+        } else {
+            _cg.setColor( TQColorGroup::Base, shiftColorToYellow(backgroundColor(column), 40));
+        }
         TQListViewItem::paintCell( p, _cg, column, width, alignment );
-        return;
+    } else {
+        TDEListViewItem::paintCell( p, cg, column, width, alignment );
     }
-
-    TDEListViewItem::paintCell( p, _cg, column, width, alignment );
 }
 
 void ReplayGainFileListItem::setType( Type type )
-- 
cgit v1.2.3

