Skip to content

Commit 257c2ff

Browse files
authored
Merge pull request #26189 from Eism/score_popup_focus_fix
Score popups focus fix
2 parents 3b75797 + 940352b commit 257c2ff

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

src/framework/uicomponents/view/popupview.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ void PopupView::init()
150150
}
151151
});
152152

153+
navigationController()->navigationChanged().onNotify(this, [this]() {
154+
ui::INavigationPanel* navigationPanel = navigationController()->activePanel();
155+
if (!navigationPanel) {
156+
return;
157+
}
158+
159+
if (navigationPanel->window() == m_window->qWindow() && !m_window->hasActiveFocus()) {
160+
m_window->forceActiveFocus();
161+
}
162+
});
163+
153164
emit windowChanged();
154165
}
155166

src/framework/uicomponents/view/popupview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class PopupView : public QObject, public QQmlParserStatus, public Injectable, pu
9393
public:
9494
Inject<ui::IMainWindow> mainWindow = { this };
9595
Inject<ui::IUiConfiguration> uiConfiguration = { this };
96-
Inject<ui::INavigationController> navigationController= { this };
96+
Inject<ui::INavigationController> navigationController = { this };
9797

9898
public:
9999

src/framework/uicomponents/view/popupwindow/ipopupwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class IPopupWindow : public QObject
6161

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

64+
virtual bool hasActiveFocus() const = 0;
6465
virtual void forceActiveFocus() = 0;
6566

6667
virtual void setOnHidden(const std::function<void()>& callback) = 0;

src/framework/uicomponents/view/popupwindow/popupwindow_qquickview.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ void PopupWindow_QQuickView::forceActiveFocus()
136136
return;
137137
}
138138

139+
m_view->setFlags(m_view->flags() & (~Qt::WindowDoesNotAcceptFocus));
140+
m_view->requestActivate();
141+
139142
QQuickItem* rootObject = m_view->rootObject();
140143
if (!rootObject) {
141144
return;
@@ -244,6 +247,11 @@ void PopupWindow_QQuickView::setPosition(const QPoint& position) const
244247
m_view->setPosition(position);
245248
}
246249

250+
bool PopupWindow_QQuickView::hasActiveFocus() const
251+
{
252+
return m_view && m_view->activeFocusItem() != nullptr;
253+
}
254+
247255
void PopupWindow_QQuickView::setOnHidden(const std::function<void()>& callback)
248256
{
249257
m_onHidden = callback;

src/framework/uicomponents/view/popupwindow/popupwindow_qquickview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class PopupWindow_QQuickView : public IPopupWindow, public muse::Injectable, pub
6868

6969
void setPosition(const QPoint& position) const override;
7070

71+
bool hasActiveFocus() const override;
7172
void forceActiveFocus() override;
7273

7374
void setOnHidden(const std::function<void()>& callback) override;

src/notation/qml/MuseScore/NotationScene/internal/ElementPopupLoader.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Item {
118118
// This is necessary so that popups do not activate navigation in the new section,
119119
// but at the same time, when clicking on the component (text input), the focus in popup's window should be activated
120120
popup.navigationSection = null
121+
popup.openPolicies = PopupView.NoActivateFocus
121122

122123
popup.notationViewNavigationSection = container.notationViewNavigationSection
123124
popup.navigationOrderStart = container.navigationOrderStart

src/notation/view/internal/dynamicpopupmodel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ static const QList<QList<DynamicPopupModel::PageItem> > DYN_POPUP_PAGES = {
6464
{ DynamicType::PPPPPP, 74, 2.0, DynamicPopupModel::Dynamic },
6565
{ DynamicType::FFFFFF, 60, 2.5, DynamicPopupModel::Dynamic },
6666
},
67-
{ // Page 6
67+
{ // Page 6 - Hairpins
68+
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Crescendo },
69+
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Decrescendo },
70+
},
71+
{ // Page 7
6872
{ DynamicType::PPPPP, 64, 2.0, DynamicPopupModel::Dynamic },
6973
{ DynamicType::PPPP, 52, 2.0, DynamicPopupModel::Dynamic },
7074
{ DynamicType::PPP, 44, 2.0, DynamicPopupModel::Dynamic },
7175
},
72-
{ // Page 7 - Hairpins
73-
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Crescendo },
74-
{ DynamicType::OTHER, 62, 0.0, DynamicPopupModel::Decrescendo },
75-
},
7676
};
7777

7878
DynamicPopupModel::DynamicPopupModel(QObject* parent)

0 commit comments

Comments
 (0)