Commit 2995715e authored by Michael Pyne's avatar Michael Pyne
Browse files

ui: Focus the playlist search line edit on startup.

This helps avoid the new QToolButton in the status bar from being
highlighted for no reason and is more convenient for playing music when
you first start JuK up.

In the process, use the standard Qt focus proxy feature rather than
manually emulating the effect, though this needs me to enable C++14 to
use the nicer qOverload<> instead of QOverload.
parent d4bf5912
......@@ -158,6 +158,10 @@ add_executable(juk ${juk_SRCS})
kde_target_enable_exceptions(juk PRIVATE)
target_compile_definitions(juk PRIVATE QT_USE_QSTRINGBUILDER)
set_target_properties(juk PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
)
if(NOT MSVC AND NOT ( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" ) )
set( LIBMATH m )
......
......@@ -110,7 +110,11 @@ PlaylistInterface *PlaylistSplitter::playlist() const
void PlaylistSplitter::setFocus()
{
m_searchWidget->setFocus();
if(m_searchWidget->isVisible()) {
m_searchWidget->setFocus();
} else {
slotFocusCurrentPlaylist();
}
}
void PlaylistSplitter::slotFocusCurrentPlaylist()
......@@ -217,6 +221,8 @@ void PlaylistSplitter::setupLayout()
// Let interested parties know we're ready
connect(m_playlistBox, SIGNAL(startupComplete()), SIGNAL(guiReady()));
connect(m_playlistBox, &PlaylistBox::startupComplete,
this, &PlaylistSplitter::setFocus);
insertWidget(0, m_playlistBox);
......@@ -244,7 +250,7 @@ void PlaylistSplitter::setupLayout()
connect(ActionCollection::action<KToggleAction>("showSearch"), SIGNAL(toggled(bool)),
m_searchWidget, SLOT(setEnabled(bool)));
connect(m_playlistBox, &PlaylistBox::signalMoveFocusAway,
m_searchWidget, &SearchWidget::setFocus);
m_searchWidget, qOverload<>(&SearchWidget::setFocus));
topLayout->addWidget(m_nowPlaying);
topLayout->addWidget(m_searchWidget);
......
......@@ -60,6 +60,7 @@ SearchLine::SearchLine(QWidget *parent, bool simple)
layout->addWidget(m_lineEdit);
m_lineEdit->setClearButtonEnabled(true);
m_lineEdit->installEventFilter(this);
setFocusProxy(m_lineEdit);
connect(m_lineEdit, SIGNAL(textChanged(QString)),
this, SIGNAL(signalQueryChanged()));
connect(m_lineEdit, SIGNAL(returnPressed()),
......@@ -135,11 +136,6 @@ void SearchLine::clear()
m_lineEdit->clear();
}
void SearchLine::setFocus()
{
m_lineEdit->setFocus();
}
bool SearchLine::eventFilter(QObject *watched, QEvent *e)
{
if(watched != m_lineEdit || e->type() != QEvent::KeyPress)
......@@ -203,6 +199,7 @@ SearchWidget::SearchWidget(QWidget *parent)
m_lineEdit->setPlaceholderText(i18n("Search..."));
connect(m_lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
setFocusProxy(m_lineEdit);
updateColumns();
}
......
......@@ -47,7 +47,6 @@ public:
public slots:
void clear();
virtual void setFocus();
protected:
virtual bool eventFilter(QObject *watched, QEvent *e) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment