|
34 | 34 |
|
35 | 35 | #include "control/controlproxy.h" |
36 | 36 | #include "control/controlpushbutton.h" |
| 37 | +#include "controllers/keyboard/keyboardeventfilter.h" |
37 | 38 | #include "library/library.h" |
38 | 39 | #include "library/library_prefs.h" |
39 | 40 | #include "mixer/playermanager.h" |
@@ -88,6 +89,15 @@ SchemeStyle getActiveSchemeStyle() { |
88 | 89 |
|
89 | 90 | QmlLegacyLibraryItem::~QmlLegacyLibraryItem() = default; |
90 | 91 |
|
| 92 | +void QmlLegacyLibraryItem::focusSearch() { |
| 93 | + VERIFY_OR_DEBUG_ASSERT(m_pSearchLineEdit) { |
| 94 | + return; |
| 95 | + } |
| 96 | + forceActiveFocus(Qt::ShortcutFocusReason); |
| 97 | + updateEmbeddedFocus(m_pSearchLineEdit, Qt::ShortcutFocusReason); |
| 98 | + requestRender(); |
| 99 | +} |
| 100 | + |
91 | 101 | QmlLegacyLibraryItem::QmlLegacyLibraryItem(QQuickItem* pParent) |
92 | 102 | : QQuickPaintedItem(pParent), |
93 | 103 | m_pRootWidget(std::make_unique<QWidget>()) { |
@@ -191,10 +201,15 @@ QmlLegacyLibraryItem::QmlLegacyLibraryItem(QQuickItem* pParent) |
191 | 201 | VERIFY_OR_DEBUG_ASSERT(pLibrary) { |
192 | 202 | return; |
193 | 203 | } |
| 204 | + KeyboardEventFilter* pKeyboard = QmlLibraryProxy::getKeyboard(); |
| 205 | + VERIFY_OR_DEBUG_ASSERT(pKeyboard) { |
| 206 | + return; |
| 207 | + } |
194 | 208 |
|
| 209 | + pKeyboard->registerSearchBar(m_pSearchLineEdit); |
195 | 210 | pLibrary->bindSearchboxWidget(m_pSearchLineEdit); |
196 | 211 | pLibrary->bindSidebarWidget(m_pSidebar); |
197 | | - pLibrary->bindLibraryWidget(m_pLibraryWidget, QmlLibraryProxy::getKeyboard()); |
| 212 | + pLibrary->bindLibraryWidget(m_pLibraryWidget, pKeyboard); |
198 | 213 |
|
199 | 214 | // The legacy skin parser makes this connection in parseLibrary(). |
200 | 215 | // Without it the search signal never reaches WLibrary and the |
@@ -1412,6 +1427,16 @@ void QmlLegacyLibraryItem::updateEmbeddedFocus( |
1412 | 1427 | pFocusTarget = pFocusTarget->parentWidget(); |
1413 | 1428 | } |
1414 | 1429 |
|
| 1430 | + if (m_pSearchLineEdit) { |
| 1431 | + const bool searchFocused = pFocusTarget == m_pSearchLineEdit; |
| 1432 | + if (m_pSearchLineEdit->property("qmlBridgeFocused").toBool() != searchFocused) { |
| 1433 | + m_pSearchLineEdit->setProperty("qmlBridgeFocused", searchFocused); |
| 1434 | + m_pSearchLineEdit->style()->unpolish(m_pSearchLineEdit); |
| 1435 | + m_pSearchLineEdit->style()->polish(m_pSearchLineEdit); |
| 1436 | + m_pSearchLineEdit->update(); |
| 1437 | + } |
| 1438 | + } |
| 1439 | + |
1415 | 1440 | if (pFocusTarget == m_pFocusedWidget) { |
1416 | 1441 | return; |
1417 | 1442 | } |
|
0 commit comments