Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is possible to change the title bar color for toggle active state for a dock widget? #56

Closed
tlaemmlein opened this issue Aug 6, 2020 · 3 comments

Comments

@tlaemmlein
Copy link

Hi,
my goal is to have a different title bar color if the dock widget is "active".
I (re)implemented the "MyTitleBar" in the kddockwidgets example:

void paintEvent(QPaintEvent*) override
	{
		QPainter p(this);
		QColor c = isActiveWindow() ? QColor("#F28D26") : Qt::gray;
		p.fillRect(rect(), c);
		p.drawText(rect().adjusted(5, 0, 0, 0), Qt::AlignLeading | Qt::AlignVCenter, title());
	}

But this is not right. It changes the title bar color if the whole window is active. I would like to change the color for dock widget.

The following animation shows that only the whole window is changing the color and not the dock widget.

active_dock_widget

In Visual Studio it is possible to change the "active" color of each docking window.
active_dock_widget_visual_studio

Greetings,
Thomas

@iamsergio
Copy link
Contributor

I'll see what I can do :)

iamsergio added a commit that referenced this issue Aug 8, 2020
Github issue #56 is not a KDDW bug, it's how Qt works. QtWidgets don't
have focus scope. But let's workaround and handroll our own FocusScope.

Now the title bar can be colored differently if the dock widget it controls
contains any focused children.

This just implements half of the story. You have to focus a child
for the title bar to change color. Clicking the title bar directly
isn't done yet. Needs to be figured out. What do we focus when clicking it?
TitleBars usually don't care about keyboard focus. Probably we
just use the user's widget as a focus proxy.
@tlaemmlein
Copy link
Author

Thank you!

@tlaemmlein
Copy link
Author

We need a notify mechanism (Qt signal), that the active/focus state has changed. Is there still something available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants