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

CDockManager with flag "FocusHighlighting" - "Stealing" focus #334

Closed
ix07 opened this issue Jul 20, 2021 · 6 comments
Closed

CDockManager with flag "FocusHighlighting" - "Stealing" focus #334

ix07 opened this issue Jul 20, 2021 · 6 comments
Assignees

Comments

@ix07
Copy link

ix07 commented Jul 20, 2021

Hi.

In December I created an issue about a specific problem and more information was requested on that issue. Unfortunately I was very busy at that time and didn't react in time, so that issue was understandably closed. The issue is still a problem for us though, and I hope it is OK if I add it here again - this time with more information.

The problem is, that when using the config flag "CDockManager::FocusHighlighting" and adding a new tab, that tab automatically receives the focus by ADS source code:

`
void CDockWidgetTab::setActiveTab(bool active)
{
d->updateCloseButtonVisibility(active);

// Focus related stuff
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
{
	bool UpdateFocusStyle = false;
	if (active && !hasFocus())
	{
		setFocus(Qt::OtherFocusReason);
		UpdateFocusStyle = true;
	}

`
The stack looks like this:
'
qtadvanceddockingd.dll!ads::CDockWidgetTab::setActiveTab
qtadvanceddockingd.dll!ads::DockAreaTabBarPrivate::updateTabs
qtadvanceddockingd.dll!ads::CDockAreaTabBar::setCurrentIndex
qtadvanceddockingd.dll!ads::CDockAreaTabBar::insertTab
qtadvanceddockingd.dll!ads::CDockAreaWidget::insertDockWidget
qtadvanceddockingd.dll!ads::CDockAreaWidget::addDockWidget
'

The problem is as follows:

In our software we have a selection tree view which displays a list of files in which you can select a file by clicking on it or by using the arrow keys (like in Visual Studio if the "Preview selected files" option is active). When focussing a file the software opens a new tab in the dock manager in which the contents are displayed (again like Visual Studio). When the user changes the focus in the file list, another tab is opened and so on. With the current behavior of the dock manager, if "FocusHighlighting" is active, the focus is "transferred" to the newly created dock. So imagine a user trying to use the arrow keys to open some files - this is not possible, because the first created dock will "steal" the focus away.

A simple solution would be to add another config flag like "AutoFocusOnSetActiveTab" or something similar.

Thanks.

@githubuser0xFFFF
Copy link
Owner

I will try to fix this

@ix07
Copy link
Author

ix07 commented Jul 26, 2021

Much appreciated. Didn't you have a Paypal-Account?

@githubuser0xFFFF
Copy link
Owner

Please test the improve_focus_highlighting branch if it solves your problem. Please test it carefully and check if you see any focus highlighting issues that where not present in the current implementation.

If you do not see any issues, I will merge the branch into master.

@ix07
Copy link
Author

ix07 commented Jul 27, 2021

Tested it just now and it works great. Thank you very much!

Would you consider accepting two changes we did into the library?

  • Added a qtranslator instance to the dockmanager so context menus integrated into ADS can be translated
  • Added a qstring parameter ("Suffix") to "loadPerspectives" and "savePerspectives') so multiple perspectives can be saved into one QSettings-instance (defaulting to "" - so it will not break any code)

@githubuser0xFFFF
Copy link
Owner

Thank you for testing. Could you please open two separate pull request for your proposed changes so that we can discuss about the changes there?

@ix07
Copy link
Author

ix07 commented Jul 27, 2021

Hm. I have never done that before - I will have to find out how to do that first. I think we can close this issue. Thanks for your assistance!

@ix07 ix07 closed this as completed Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants