From 98cb236220dc23ba41db56468a37679132f36ad7 Mon Sep 17 00:00:00 2001 From: Timothy Rae Date: Sat, 21 Jan 2017 08:36:22 +0900 Subject: [PATCH] Fix backwards compatibility with SelectPlaylist --- src/library/librarycontrol.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index d8920456cdee..2a0c239272a3 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -415,10 +415,23 @@ void LibraryControl::setLibraryFocus() { } void LibraryControl::slotSelectSidebarItem(double v) { - if (v != 0) { - const auto key = (v < 0) ? Qt::Key_Up : Qt::Key_Down; - emitKeyEvent(QKeyEvent{QEvent::KeyPress, key, Qt::NoModifier}); - emitKeyEvent(QKeyEvent{QEvent::KeyRelease, key, Qt::NoModifier}); + if (m_pSidebarWidget == NULL) { + return; + } + if (v > 0) { + QApplication::postEvent(m_pSidebarWidget, new QKeyEvent( + QEvent::KeyPress, + (int)Qt::Key_Down, Qt::NoModifier, QString(), true)); + QApplication::postEvent(m_pSidebarWidget, new QKeyEvent( + QEvent::KeyRelease, + (int)Qt::Key_Down, Qt::NoModifier, QString(), true)); + } else if (v < 0) { + QApplication::postEvent(m_pSidebarWidget, new QKeyEvent( + QEvent::KeyPress, + (int)Qt::Key_Up, Qt::NoModifier, QString(), true)); + QApplication::postEvent(m_pSidebarWidget, new QKeyEvent( + QEvent::KeyRelease, + (int)Qt::Key_Up, Qt::NoModifier, QString(), true)); } }