From 75a7a1ae11ff12516e7e53ea29662c1eb4d280d5 Mon Sep 17 00:00:00 2001 From: Guido Berhoerster Date: Fri, 28 Oct 2022 11:15:19 +0200 Subject: [PATCH 2/5] Expose QMLTermWidget foreground and background colors to QML Signed-off-by: Mike Gabriel --- lib/TerminalDisplay.cpp | 12 +++++++++++- lib/TerminalDisplay.h | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index d84cb87..f90af51 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -162,20 +162,30 @@ void TerminalDisplay::setBackgroundColor(const QColor& color) // Avoid propagating the palette change to the scroll bar _scrollBar->setPalette( QApplication::palette() ); + emit backgroundColorChanged(); update(); } void TerminalDisplay::setForegroundColor(const QColor& color) { _colorTable[DEFAULT_FORE_COLOR].color = color; - + emit foregroundColorChanged(); update(); } +QColor TerminalDisplay::backgroundColor() const +{ + return _colorTable[DEFAULT_BACK_COLOR].color; +} +QColor TerminalDisplay::foregroundColor() const +{ + return _colorTable[DEFAULT_FORE_COLOR].color; +} void TerminalDisplay::setColorTable(const ColorEntry table[]) { for (int i = 0; i < TABLE_COLORS; i++) _colorTable[i] = table[i]; setBackgroundColor(_colorTable[DEFAULT_BACK_COLOR].color); + setForegroundColor(_colorTable[DEFAULT_FORE_COLOR].color); } /* ------------------------------------------------------------------------- */ diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h index 8e97a5d..dda130d 100644 --- a/lib/TerminalDisplay.h +++ b/lib/TerminalDisplay.h @@ -94,6 +94,8 @@ class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QQuickPaintedItem Q_PROPERTY(KSession* session READ getSession WRITE setSession NOTIFY sessionChanged ) Q_PROPERTY(QFont font READ getVTFont WRITE setVTFont NOTIFY vtFontChanged ) Q_PROPERTY(QString colorScheme READ colorScheme WRITE setColorScheme NOTIFY colorSchemeChanged ) + Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundColorChanged ) + Q_PROPERTY(QColor foregroundColor READ foregroundColor NOTIFY foregroundColorChanged ) Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY changedContentSizeSignal) Q_PROPERTY(int lineSpacing READ lineSpacing WRITE setLineSpacing NOTIFY lineSpacingChanged ) Q_PROPERTY(bool terminalUsesMouse READ getUsesMouse NOTIFY usesMouseChanged ) @@ -564,6 +566,9 @@ public slots: */ void setForegroundColor(const QColor& color); + QColor backgroundColor() const; + QColor foregroundColor() const; + void selectionChanged(); // QMLTermWidget @@ -637,6 +642,8 @@ signals: void lineSpacingChanged(); void availableColorSchemesChanged(); void colorSchemeChanged(); + void backgroundColorChanged(); + void foregroundColorChanged(); void fullCursorHeightChanged(); void blinkingCursorStateChanged(); void boldIntenseChanged(); -- 2.30.2