Skip to content

Commit

Permalink
Merge pull request musescore#26189 from Eism/score_popup_focus_fix
Browse files Browse the repository at this point in the history
Score popups focus fix
  • Loading branch information
Eism authored Jan 28, 2025
2 parents 3b75797 + 940352b commit 257c2ff
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
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
10 changes: 5 additions & 5 deletions src/notation/view/internal/dynamicpopupmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ static const QList<QList<DynamicPopupModel::PageItem> > DYN_POPUP_PAGES = {
{ DynamicType::PPPPPP, 74, 2.0, DynamicPopupModel::Dynamic },
{ DynamicType::FFFFFF, 60, 2.5, DynamicPopupModel::Dynamic },
},
{ // Page 6
{ // Page 6 - Hairpins
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Crescendo },
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Decrescendo },
},
{ // Page 7
{ DynamicType::PPPPP, 64, 2.0, DynamicPopupModel::Dynamic },
{ DynamicType::PPPP, 52, 2.0, DynamicPopupModel::Dynamic },
{ DynamicType::PPP, 44, 2.0, DynamicPopupModel::Dynamic },
},
{ // Page 7 - Hairpins
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Crescendo },
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Decrescendo },
},
};

DynamicPopupModel::DynamicPopupModel(QObject* parent)
Expand Down

0 comments on commit 257c2ff

Please sign in to comment.