From 1f581c31a64c4312c618d9eb6a79480622f57c2b Mon Sep 17 00:00:00 2001 From: brayozin Date: Fri, 3 Apr 2026 00:29:11 -0300 Subject: [PATCH 1/2] Fix opacity not applying to text fragment backgrounds Move setOpacity to public slots so it is callable from QML and connectable to signals, add update() so opacity changes repaint immediately, and pass useOpacitySetting=true when drawing text fragment backgrounds so colored backgrounds respect the opacity level --- lib/TerminalDisplay.cpp | 4 +++- lib/TerminalDisplay.h | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index d6c1edfa..5c880e42 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -178,6 +178,7 @@ void TerminalDisplay::setBackgroundColor(const QColor& color) update(); } + void TerminalDisplay::setForegroundColor(const QColor& color) { _colorTable[DEFAULT_FORE_COLOR].color = color; @@ -760,6 +761,7 @@ QColor TerminalDisplay::keyboardCursorColor() const void TerminalDisplay::setOpacity(qreal opacity) { _opacity = qBound(static_cast(0), opacity, static_cast(1)); + update(); } void TerminalDisplay::setBackgroundImage(const QString& backgroundImage) @@ -958,7 +960,7 @@ void TerminalDisplay::drawTextFragment(QPainter& painter , // draw background if different from the display's background color if ( backgroundColor != palette().window().color() ) drawBackground(painter,rect,backgroundColor, - false /* do not use transparency */); + true /* use transparency */); // draw cursor shape if the current character is the cursor // this may alter the foreground and background colors diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h index 6f10aef8..0bc1a2ec 100644 --- a/lib/TerminalDisplay.h +++ b/lib/TerminalDisplay.h @@ -134,9 +134,6 @@ class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QQuickPaintedItem */ uint randomSeed() const; - /** Sets the opacity of the terminal display. */ - void setOpacity(qreal opacity); - /** * This enum describes the location where the scroll bar is positioned in the display widget. */ @@ -596,6 +593,9 @@ public slots: */ void setBackgroundColor(const QColor& color); + /** Sets the opacity of the terminal display. */ + void setOpacity(qreal opacity); + /** * Sets the text of the display to the specified color. * @see setColorTable(), setBackgroundColor() From 739cb9d92c14e9ef79e28dc147281bab9d0a24d4 Mon Sep 17 00:00:00 2001 From: brayozin Date: Fri, 3 Apr 2026 00:35:03 -0300 Subject: [PATCH 2/2] Update text fragment background drawing to disable transparency Changed the background drawing logic in drawTextFragment to not use transparency, ensuring consistent rendering of text backgrounds on different applications --- lib/TerminalDisplay.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 5c880e42..4b812a52 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -178,7 +178,6 @@ void TerminalDisplay::setBackgroundColor(const QColor& color) update(); } - void TerminalDisplay::setForegroundColor(const QColor& color) { _colorTable[DEFAULT_FORE_COLOR].color = color; @@ -960,7 +959,7 @@ void TerminalDisplay::drawTextFragment(QPainter& painter , // draw background if different from the display's background color if ( backgroundColor != palette().window().color() ) drawBackground(painter,rect,backgroundColor, - true /* use transparency */); + false /* do not use transparency */); // draw cursor shape if the current character is the cursor // this may alter the foreground and background colors