[UI] Dynamically launch searches while filling in the field

This commit is contained in:
emeric
2015-01-06 13:33:36 +01:00
parent 8d17bf3785
commit 78bfd3a186
4 changed files with 109 additions and 6 deletions
+1
View File
@@ -47,6 +47,7 @@ lms_SOURCES = \
$(srcdir)/ui/audio/TableFilter.cpp \
$(srcdir)/ui/audio/TrackView.cpp \
$(srcdir)/ui/common/DirectoryValidator.cpp \
$(srcdir)/ui/common/LineEdit.cpp \
$(srcdir)/ui/common/SessionData.cpp \
$(srcdir)/ui/resource/AvConvTranscodeStreamResource.cpp \
$(srcdir)/ui/resource/CoverResource.cpp \
+9 -6
View File
@@ -30,16 +30,15 @@
#include <Wt/WLineEdit>
#include <Wt/Auth/Identity>
#include "settings/Settings.hpp"
#include "auth/LmsAuth.hpp"
#include "logger/Logger.hpp"
#include "settings/Settings.hpp"
#include "settings/SettingsFirstConnectionFormView.hpp"
#include "auth/LmsAuth.hpp"
#include "audio/Audio.hpp"
#include "video/VideoWidget.hpp"
#include "common/LineEdit.hpp"
#include "LmsApplication.hpp"
@@ -133,6 +132,8 @@ LmsApplication::handleAuthEvent(void)
LMS_LOG(MOD_UI, SEV_NOTICE) << "User '" << user.identity(Wt::Auth::Identity::LoginName) << "' logged in";
this->root()->setOverflow(Wt::WContainerWidget::OverflowHidden);
// Create a Vertical layout: top is the nav bar, bottom is the contents
Wt::WVBoxLayout *layout = new Wt::WVBoxLayout(this->root());
// Create a navigation bar with a link to a web page.
@@ -143,6 +144,8 @@ LmsApplication::handleAuthEvent(void)
Wt::WStackedWidget *contentsStack = new Wt::WStackedWidget();
contentsStack->setOverflow(Wt::WContainerWidget::OverflowAuto);
// Setup a Left-aligned menu.
Wt::WMenu *leftMenu = new Wt::WMenu(contentsStack);
navigation->addMenu(leftMenu);
@@ -173,10 +176,10 @@ LmsApplication::handleAuthEvent(void)
}, std::placeholders::_1));
// Add a Search control.
Wt::WLineEdit *searchEdit = new Wt::WLineEdit();
LineEdit *searchEdit = new LineEdit(500);
searchEdit->setEmptyText("Search...");
searchEdit->enterPressed().connect(std::bind([=] ()
searchEdit->timedChanged().connect(std::bind([=] ()
{
// TODO: check which view is activated and search into it
audio->search(searchEdit->text().toUTF8());
+55
View File
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2015 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wt/WTimer>
#include "LineEdit.hpp"
namespace UserInterface {
LineEdit::LineEdit(std::size_t ms, Wt::WContainerWidget* parent)
: Wt::WLineEdit(parent)
{
Wt::WTimer *timer = new Wt::WTimer(this);
timer->setSingleShot(true);
timer->setInterval(ms);
this->keyWentUp().connect(std::bind([=] (Wt::WKeyEvent keyEvent)
{
if (timer->isActive())
timer->stop();
if (keyEvent.key() == Wt::Key_Enter)
_sigTimedChanged.emit(this->text());
else
timer->start();
}, std::placeholders::_1));
timer->timeout().connect(std::bind([=] ()
{
_sigTimedChanged.emit(this->text());
}));
}
} // namespace UserInterface
+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2015 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UI_LINE_EDIT_HPP
#define UI_LINE_EDIT_HPP
#include <Wt/WLineEdit>
#include <Wt/WContainerWidget>
#include <Wt/WSignal>
namespace UserInterface {
class LineEdit : public Wt::WLineEdit
{
public:
LineEdit(std::size_t ms, Wt::WContainerWidget* parent = 0);
Wt::Signal<Wt::WString>& timedChanged() { return _sigTimedChanged; }
private:
Wt::Signal<Wt::WString> _sigTimedChanged;
};
} // namespace UserInterface
#endif