View Single Post
Old 11-20-2023, 09:22 AM   #44
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,917
Karma: 6240958
Join Date: Nov 2009
Device: many
Well it seems with multiple main windows on macOS, the visibleRegion().isEmpty() test failed sometimes and so no raise was done but needed.

I think the safest way to handle this is to use raise() called immediately after FocusOn call and before the specific internal subwidget is given focus. This should not hurt anything and works on macOS as well.

I also added a nullptr check for each to make sure the QDockWidget in question has not been deleted yet for safety in case someone deletes a main Window and shortcut keys or key events are waiting to be flushed out. This is more of a concern on macOS with its multiple main windows but is safer for everyone.

I have pushed this master. If you get a chance please make sure I have not hurt anything on Windows. It should all be okay but just to make sure.

I think with this change, we should consider this new feature as complete.

Glad people find it useful.

KevinH


Quote:
Originally Posted by BeckyEbook View Post
I checked via Debug that the widget can be checked for visibility before raise().
When the widget is in the foreground then raise() will not be called.

So an extra test shouldn't hurt, here an example:

Code:
void MainWindow::FocusOnTOC()
{
    FocusOn(m_TableOfContents);
    m_TableOfContents->SetFocusOnTOC();
    DBG qDebug() << "Focus";
    if (m_TableOfContents->visibleRegion().isEmpty()) {
        DBG qDebug() << "Here raise";
        m_TableOfContents->raise();
    }
    ShowMessageOnStatusBar(tr("Focus changed to Table Of Contents window."));
}
KevinH is offline   Reply With Quote