diff --git a/src/Makefile.am b/src/Makefile.am index b8480855..ada8b7ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp index ad803ae6..ba7cfc42 100644 --- a/src/ui/LmsApplication.cpp +++ b/src/ui/LmsApplication.cpp @@ -30,16 +30,15 @@ #include #include -#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()); diff --git a/src/ui/common/LineEdit.cpp b/src/ui/common/LineEdit.cpp new file mode 100644 index 00000000..d5f21fda --- /dev/null +++ b/src/ui/common/LineEdit.cpp @@ -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 . + */ + +#include + +#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 + + diff --git a/src/ui/common/LineEdit.hpp b/src/ui/common/LineEdit.hpp new file mode 100644 index 00000000..9d27c43a --- /dev/null +++ b/src/ui/common/LineEdit.hpp @@ -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 . + */ + +#ifndef UI_LINE_EDIT_HPP +#define UI_LINE_EDIT_HPP + +#include +#include +#include + +namespace UserInterface { + +class LineEdit : public Wt::WLineEdit +{ + public: + LineEdit(std::size_t ms, Wt::WContainerWidget* parent = 0); + + Wt::Signal& timedChanged() { return _sigTimedChanged; } + + private: + + Wt::Signal _sigTimedChanged; +}; + +} // namespace UserInterface + +#endif +