Skip to contentSkip to conversation

Fix KernelShark appearance on dark color schemes

PATCH In review Mikhail Rudenko 3 participants 8 messages Oct 10, 2019 – Oct 11, 2019

lore
Share & tools
lore
#0 lore raw

cover Fix KernelShark appearance on dark color schemes

Currently a few widgets in Kernel Shark UI use custom stylesheets, unconditionally setting their background or text color (but not both!) to hard-coded values. This has a side effect of widget text being poorly readable on some color schemes (e.g. Breeze Dark, and dark schemes in general). This patch series tries to address this issue.

The first three patches are trivial: they ensure that whenever the background color of a widget is set to white via stylesheet, its text color is set to black.

The fourth one changes "inactive" marker selection button style to system default, making it look clickable on all color schemes.

Mikhail Rudenko (4):
kernel-shark: Set text color to black in KsDualMarker's QLabels
kernel-shark: Set text color to black in pointer position QLabel
kernel-shark: Set text color to black in KsTraceGraph's axes labels
kernel-shark: Change KsDualMarker's inactive button style to default

 kernel-shark/src/KsDualMarker.cpp | 11 ++---------
 kernel-shark/src/KsTraceGraph.cpp |  6 ++++--
 2 files changed, 6 insertions(+), 11 deletions(-)

--
2.23.0

#1 lore raw

PATCH 1/4 kernel-shark: Set text color to black in KsDualMarker's QLabels

At present, background color of marker position QLabels is forced to white with a stylesheet, but the text color stays unchanged. As a result, the text is barely visible when using dark color schemes. This patch forces the text color to black for these QLabels, making it readable on all color schemes.

---
 kernel-shark/src/KsDualMarker.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/src/KsDualMarker.cpp +1 -1
index 755e246..0070777 100644
@@ -156,7 +156,7 @@ KsDualMarkerSM::KsDualMarkerSM(QWidget *parent)
 
 	for (auto const &l: {&_labelMA, &_labelMB, &_labelDelta}) {
 		l->setFrameStyle(QFrame::Panel | QFrame::Sunken);
-		l->setStyleSheet("QLabel {background-color : white;}");
+		l->setStyleSheet("QLabel {background-color : white; color : black}");
 		l->setTextInteractionFlags(Qt::TextSelectableByMouse);
 		l->setFixedWidth(FONT_WIDTH * 16);
 	}

--
2.23.0

#2 lore raw

PATCH 2/4 kernel-shark: Set text color to black in pointer position QLabel

In reply to Mikhail Rudenko

At present, the background color of the pointer position QLabel is forced to white with a stylesheet, but the text color stays unchanged. As a result, the text is barely visible when using dark color schemes. This patch forces the text color to black for this QLabel, making it readable on all color schemes.

---
 kernel-shark/src/KsTraceGraph.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/src/KsTraceGraph.cpp +1 -1
index 2e48372..73e7577 100644
@@ -62,7 +62,7 @@ KsTraceGraph::KsTraceGraph(QWidget *parent)
 
 	_pointerBar.addWidget(&_labelP1);
 	_labelP2.setFrameStyle(QFrame::Panel | QFrame::Sunken);
-	_labelP2.setStyleSheet("QLabel { background-color : white;}");
+	_labelP2.setStyleSheet("QLabel { background-color : white; color: black}");
 	_labelP2.setTextInteractionFlags(Qt::TextSelectableByMouse);
 	_labelP2.setFixedWidth(FONT_WIDTH * 16);
 	_pointerBar.addWidget(&_labelP2);

--
2.23.0

#3 lore raw

PATCH 3/4 kernel-shark: Set text color to black in KsTraceGraph's axes labels

In reply to Mikhail Rudenko

At present, background color of axes labels of the plot is forced to white with a stylesheet, but the text color stays unchanged. As a result, text is barely visible when using dark color schemes. This patch forces the text color to black for these labels, making them readable on all color schemes.

---
 kernel-shark/src/KsTraceGraph.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel-shark/src/KsTraceGraph.cpp +3 -1
index 73e7577..90f83f3 100644
@@ -96,6 +96,8 @@ KsTraceGraph::KsTraceGraph(QWidget *parent)
 	_legendAxisX.layout()->addWidget(&_labelXMin);
 	_legendAxisX.layout()->addWidget(&_labelXMid);
 	_legendAxisX.layout()->addWidget(&_labelXMax);
+	_legendAxisX.setStyleSheet("QLabel { background-color : white; color: black}");
+
 	_drawWindow.setMinimumSize(100, 100);
 	_drawWindow.setStyleSheet("QWidget {background-color : white;}");
 
@@ -580,7 +582,7 @@ void KsTraceGraph::_updateGraphLegends()
 			width = STRING_WIDTH(graphName);
 
 		name->setAlignment(Qt::AlignBottom);
-		name->setStyleSheet("QLabel {background-color : white;}");
+		name->setStyleSheet("QLabel {background-color : white; color : black}");
 		name->setFixedHeight(KS_GRAPH_HEIGHT);
 		layout->addWidget(name);
 	};

--
2.23.0

#4 lore raw

PATCH 4/4 kernel-shark: Change KsDualMarker's inactive button style to default

In reply to Mikhail Rudenko

At present, the style of an "inactive" KsDualMarker toolbar button is set to "system default background + rgb(70,70,70) text color". As a result, on dark qt color schemes (e.g. Breeze Dark) inactive button looks disabled ("gray on gray").

This patch addresses the issue by changing "inactive" button style to system default. This makes the UI intuitive across different color schemes.

QStateMachine::setGlobalRestorePolicy is used for reducing the boilerplate of manually resetting button style when it becomes "inactive".

---
 kernel-shark/src/KsDualMarker.cpp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
kernel-shark/src/KsDualMarker.cpp +1 -8
index 0070777..90c5373 100644
@@ -171,20 +171,12 @@ KsDualMarkerSM::KsDualMarkerSM(QWidget *parent)
 				"styleSheet",
 				styleSheetA);
 
-	_stateA->assignProperty(&_buttonB,
-				"styleSheet",
-				"color : rgb(70, 70, 70)");
-
 	styleSheetB = "background : " +
 		      _markB._color.name() +
 		      "; color : white";
 
 	_stateB = new QState;
 	_stateB->setObjectName("B");
-	_stateB->assignProperty(&_buttonA,
-				"styleSheet",
-				"color : rgb(70, 70, 70)");
-
 	_stateB->assignProperty(&_buttonB,
 				"styleSheet",
 				styleSheetB);
@@ -223,6 +215,7 @@ KsDualMarkerSM::KsDualMarkerSM(QWidget *parent)
 	connect(&_buttonA,	&KsMarkerButton::deselect,
 		this,		&KsDualMarkerSM::deselectA);
 
+	_machine.setGlobalRestorePolicy(QState::RestoreProperties);
 	_machine.addState(_stateA);
 	_machine.addState(_stateB);
 	_machine.setInitialState(_stateA);

--
2.23.0

Acked-by on the v1 series
#5 lore raw
In reply to Mikhail Rudenko
Quoted 19 lines · On Fri, 11 Oct 2019 00:24:25 +0300 Mikhail Rudenko <[email protected]>…

Currently a few widgets in Kernel Shark UI use custom stylesheets, unconditionally setting their background or text color (but not both!) to hard-coded values. This has a side effect of widget text being poorly readable on some color schemes (e.g. Breeze Dark, and dark schemes in general). This patch series tries to address this issue.

The first three patches are trivial: they ensure that whenever the background color of a widget is set to white via stylesheet, its text color is set to black.

The fourth one changes "inactive" marker selection button style to system default, making it look clickable on all color schemes.

Mikhail Rudenko (4):
kernel-shark: Set text color to black in KsDualMarker's QLabels
kernel-shark: Set text color to black in pointer position QLabel
kernel-shark: Set text color to black in KsTraceGraph's axes labels
kernel-shark: Change KsDualMarker's inactive button style to default

Quoted 3 lines
 kernel-shark/src/KsDualMarker.cpp | 11 ++---------
 kernel-shark/src/KsTraceGraph.cpp |  6 ++++--
 2 files changed, 6 insertions(+), 11 deletions(-)

Yordan,

If you are fine with these patches, could you pull them in and push them to the repo?

-- Steve

#6 lore raw
Quoted 27 lines · Steven Rostedt
Quoted 19 lines · On Fri, 11 Oct 2019 00:24:25 +0300 Mikhail Rudenko <[email protected]>…

Currently a few widgets in Kernel Shark UI use custom stylesheets, unconditionally setting their background or text color (but not both!) to hard-coded values. This has a side effect of widget text being poorly readable on some color schemes (e.g. Breeze Dark, and dark schemes in general). This patch series tries to address this issue.

The first three patches are trivial: they ensure that whenever the background color of a widget is set to white via stylesheet, its text color is set to black.

The fourth one changes "inactive" marker selection button style to system default, making it look clickable on all color schemes.

Mikhail Rudenko (4):
kernel-shark: Set text color to black in KsDualMarker's QLabels
kernel-shark: Set text color to black in pointer position QLabel
kernel-shark: Set text color to black in KsTraceGraph's axes labels
kernel-shark: Change KsDualMarker's inactive button style to default

Quoted 3 lines
  kernel-shark/src/KsDualMarker.cpp | 11 ++---------
  kernel-shark/src/KsTraceGraph.cpp |  6 ++++--
  2 files changed, 6 insertions(+), 11 deletions(-)
Quoted 6 lines

Yordan,

If you are fine with these patches, could you pull them in and push them to the repo?

Hi Mikhail,

Thanks a lot!
I am pushing the patches.
Is is possible to send us a screenshot? I am curious to see how KernelShark looks on your dark color scheme.

cheers,
Yordan

Quoted 3 lines

-- Steve

#7 lore raw

On 2019-10-11 at 17:11 MSK, Yordan Karadzhov (VMware):

Quoted 6 lines

Hi Mikhail,

Thanks a lot!
I am pushing the patches.
Is is possible to send us a screenshot? I am curious to see how KernelShark looks on your dark color scheme.

You're welcome!

Here are the screenshots with and without the patches applied:
https://imgur.com/a/MyXdiEN

Best regards,
Mikhail