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

Score popups focus fix #26189

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/framework/uicomponents/view/popupview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ void PopupView::init()
}
});

navigationController()->navigationChanged().onNotify(this, [this]() {
ui::INavigationPanel* navigationPanel = navigationController()->activePanel();
if (!navigationPanel) {
return;
}

if (navigationPanel->window() == m_window->qWindow() && !m_window->hasActiveFocus()) {
m_window->forceActiveFocus();
}
});

emit windowChanged();
}

Expand Down
2 changes: 1 addition & 1 deletion src/framework/uicomponents/view/popupview.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PopupView : public QObject, public QQmlParserStatus, public Injectable, pu
public:
Inject<ui::IMainWindow> mainWindow = { this };
Inject<ui::IUiConfiguration> uiConfiguration = { this };
Inject<ui::INavigationController> navigationController= { this };
Inject<ui::INavigationController> navigationController = { this };

public:

Expand Down
1 change: 1 addition & 0 deletions src/framework/uicomponents/view/popupwindow/ipopupwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class IPopupWindow : public QObject

virtual void setPosition(const QPoint& position) const = 0;

virtual bool hasActiveFocus() const = 0;
virtual void forceActiveFocus() = 0;

virtual void setOnHidden(const std::function<void()>& callback) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ void PopupWindow_QQuickView::forceActiveFocus()
return;
}

m_view->setFlags(m_view->flags() & (~Qt::WindowDoesNotAcceptFocus));
m_view->requestActivate();

QQuickItem* rootObject = m_view->rootObject();
if (!rootObject) {
return;
Expand Down Expand Up @@ -244,6 +247,11 @@ void PopupWindow_QQuickView::setPosition(const QPoint& position) const
m_view->setPosition(position);
}

bool PopupWindow_QQuickView::hasActiveFocus() const
{
return m_view && m_view->activeFocusItem() != nullptr;
}

void PopupWindow_QQuickView::setOnHidden(const std::function<void()>& callback)
{
m_onHidden = callback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class PopupWindow_QQuickView : public IPopupWindow, public muse::Injectable, pub

void setPosition(const QPoint& position) const override;

bool hasActiveFocus() const override;
void forceActiveFocus() override;

void setOnHidden(const std::function<void()>& callback) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Item {
// This is necessary so that popups do not activate navigation in the new section,
// but at the same time, when clicking on the component (text input), the focus in popup's window should be activated
popup.navigationSection = null
popup.openPolicies = PopupView.NoActivateFocus

popup.notationViewNavigationSection = container.notationViewNavigationSection
popup.navigationOrderStart = container.navigationOrderStart
Expand Down