| 1 |
From 75a7a1ae11ff12516e7e53ea29662c1eb4d280d5 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Guido Berhoerster <[email protected]> |
| 3 |
Date: Fri, 28 Oct 2022 11:15:19 +0200 |
| 4 |
Subject: [PATCH 2/5] Expose QMLTermWidget foreground and background colors to |
| 5 |
QML |
| 6 |
|
| 7 |
Signed-off-by: Mike Gabriel <[email protected]> |
| 8 |
--- |
| 9 |
lib/TerminalDisplay.cpp | 12 +++++++++++- |
| 10 |
lib/TerminalDisplay.h | 7 +++++++ |
| 11 |
2 files changed, 18 insertions(+), 1 deletion(-) |
| 12 |
|
| 13 |
diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp |
| 14 |
index d84cb87..f90af51 100644 |
| 15 |
--- a/lib/TerminalDisplay.cpp |
| 16 |
+++ b/lib/TerminalDisplay.cpp |
| 17 |
@@ -162,20 +162,30 @@ void TerminalDisplay::setBackgroundColor(const QColor& color) |
| 18 |
// Avoid propagating the palette change to the scroll bar |
| 19 |
_scrollBar->setPalette( QApplication::palette() ); |
| 20 |
|
| 21 |
+ emit backgroundColorChanged(); |
| 22 |
update(); |
| 23 |
} |
| 24 |
void TerminalDisplay::setForegroundColor(const QColor& color) |
| 25 |
{ |
| 26 |
_colorTable[DEFAULT_FORE_COLOR].color = color; |
| 27 |
- |
| 28 |
+ emit foregroundColorChanged(); |
| 29 |
update(); |
| 30 |
} |
| 31 |
+QColor TerminalDisplay::backgroundColor() const |
| 32 |
+{ |
| 33 |
+ return _colorTable[DEFAULT_BACK_COLOR].color; |
| 34 |
+} |
| 35 |
+QColor TerminalDisplay::foregroundColor() const |
| 36 |
+{ |
| 37 |
+ return _colorTable[DEFAULT_FORE_COLOR].color; |
| 38 |
+} |
| 39 |
void TerminalDisplay::setColorTable(const ColorEntry table[]) |
| 40 |
{ |
| 41 |
for (int i = 0; i < TABLE_COLORS; i++) |
| 42 |
_colorTable[i] = table[i]; |
| 43 |
|
| 44 |
setBackgroundColor(_colorTable[DEFAULT_BACK_COLOR].color); |
| 45 |
+ setForegroundColor(_colorTable[DEFAULT_FORE_COLOR].color); |
| 46 |
} |
| 47 |
|
| 48 |
/* ------------------------------------------------------------------------- */ |
| 49 |
diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h |
| 50 |
index 8e97a5d..dda130d 100644 |
| 51 |
--- a/lib/TerminalDisplay.h |
| 52 |
+++ b/lib/TerminalDisplay.h |
| 53 |
@@ -94,6 +94,8 @@ class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QQuickPaintedItem |
| 54 |
Q_PROPERTY(KSession* session READ getSession WRITE setSession NOTIFY sessionChanged ) |
| 55 |
Q_PROPERTY(QFont font READ getVTFont WRITE setVTFont NOTIFY vtFontChanged ) |
| 56 |
Q_PROPERTY(QString colorScheme READ colorScheme WRITE setColorScheme NOTIFY colorSchemeChanged ) |
| 57 |
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundColorChanged ) |
| 58 |
+ Q_PROPERTY(QColor foregroundColor READ foregroundColor NOTIFY foregroundColorChanged ) |
| 59 |
Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY changedContentSizeSignal) |
| 60 |
Q_PROPERTY(int lineSpacing READ lineSpacing WRITE setLineSpacing NOTIFY lineSpacingChanged ) |
| 61 |
Q_PROPERTY(bool terminalUsesMouse READ getUsesMouse NOTIFY usesMouseChanged ) |
| 62 |
@@ -564,6 +566,9 @@ public slots: |
| 63 |
*/ |
| 64 |
void setForegroundColor(const QColor& color); |
| 65 |
|
| 66 |
+ QColor backgroundColor() const; |
| 67 |
+ QColor foregroundColor() const; |
| 68 |
+ |
| 69 |
void selectionChanged(); |
| 70 |
|
| 71 |
// QMLTermWidget |
| 72 |
@@ -637,6 +642,8 @@ signals: |
| 73 |
void lineSpacingChanged(); |
| 74 |
void availableColorSchemesChanged(); |
| 75 |
void colorSchemeChanged(); |
| 76 |
+ void backgroundColorChanged(); |
| 77 |
+ void foregroundColorChanged(); |
| 78 |
void fullCursorHeightChanged(); |
| 79 |
void blinkingCursorStateChanged(); |
| 80 |
void boldIntenseChanged(); |
| 81 |
-- |
| 82 |
2.30.2 |
| 83 |
|