Debian Codegraph @

debian/patches/0005_Apply-color-scheme-if-changed.patch

raw
1 From ffc6b2b2a20ca785f93300eca93c25c4b74ece17 Mon Sep 17 00:00:00 2001
2 From: Guido Berhoerster <[email protected]>
3 Date: Fri, 28 Oct 2022 13:32:35 +0200
4 Subject: [PATCH 5/5] Apply color scheme if changed
5
6 Signed-off-by: Mike Gabriel <[email protected]>
7 ---
8 lib/TerminalDisplay.cpp | 30 +++++++++++++++++++++---------
9 lib/TerminalDisplay.h | 2 ++
10 2 files changed, 23 insertions(+), 9 deletions(-)
11
12 diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp
13 index e2d75a2..6ce8055 100644
14 --- a/lib/TerminalDisplay.cpp
15 +++ b/lib/TerminalDisplay.cpp
16 @@ -372,6 +372,7 @@ TerminalDisplay::TerminalDisplay(QQuickItem *parent)
17 ,_flowControlWarningEnabled(false)
18 ,_outputSuspendedLabel(nullptr)
19 ,_lineSpacing(0)
20 +,_colorSchemeRef(0)
21 ,_colorsInverted(false)
22 ,_opacity(static_cast<qreal>(1))
23 ,_backgroundMode(None)
24 @@ -3505,24 +3506,24 @@ QStringList TerminalDisplay::availableColorSchemes()
25 void TerminalDisplay::setColorScheme(const QString &name)
26 {
27 if ( name != _colorScheme ) {
28 - const ColorScheme *cs;
29 + if (_colorSchemeRef) {
30 + disconnect(_colorSchemeRef, 0, this, 0);
31 + }
32 // avoid legacy (int) solution
33 if (!availableColorSchemes().contains(name))
34 - cs = ColorSchemeManager::instance()->defaultColorScheme();
35 + _colorSchemeRef = ColorSchemeManager::instance()->defaultColorScheme();
36 else
37 - cs = ColorSchemeManager::instance()->findColorScheme(name);
38 + _colorSchemeRef = ColorSchemeManager::instance()->findColorScheme(name);
39
40 - if (! cs)
41 + if (! _colorSchemeRef)
42 {
43 qDebug() << "Cannot load color scheme: " << name;
44 return;
45 }
46
47 - ColorEntry table[TABLE_COLORS];
48 - cs->getColorTable(table);
49 - setColorTable(table);
50 -
51 - setFillColor(cs->backgroundColor());
52 + connect(_colorSchemeRef, SIGNAL(colorChanged(int)), this, SLOT(applyColorScheme()));
53 + connect(_colorSchemeRef, SIGNAL(opacityChanged()), this, SLOT(applyColorScheme()));
54 + applyColorScheme();
55 _colorScheme = name;
56 emit colorSchemeChanged();
57 }
58 @@ -3533,6 +3534,17 @@ QString TerminalDisplay::colorScheme() const
59 return _colorScheme;
60 }
61
62 +void TerminalDisplay::applyColorScheme()
63 +{
64 + ColorEntry table[TABLE_COLORS];
65 + _colorSchemeRef->getColorTable(table);
66 + setColorTable(table);
67 + QColor backgroundColor = _colorTable[DEFAULT_BACK_COLOR].color;
68 + backgroundColor.setAlphaF(_colorSchemeRef->opacity());
69 + setBackgroundColor(backgroundColor);
70 + setFillColor(backgroundColor);
71 +}
72 +
73 void TerminalDisplay::simulateKeyPress(int key, int modifiers, bool pressed, quint32 nativeScanCode, const QString &text)
74 {
75 Q_UNUSED(nativeScanCode);
76 diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h
77 index 5b99da3..ec329f2 100644
78 --- a/lib/TerminalDisplay.h
79 +++ b/lib/TerminalDisplay.h
80 @@ -717,6 +717,7 @@ protected slots:
81 //Renables bell noises and visuals. Used to disable further bells for a short period of time
82 //after emitting the first in a sequence of bell events.
83 void enableBell();
84 + void applyColorScheme();
85
86 private slots:
87
88 @@ -893,6 +894,7 @@ private:
89
90 uint _lineSpacing;
91 QString _colorScheme;
92 + const ColorScheme* _colorSchemeRef;
93 bool _colorsInverted; // true during visual bell
94
95 QSize _size;
96 --
97 2.30.2
98