mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-10-25 07:58:29 -04:00
Keyboard mode was not displayed in the search windows. Now its fixed, both in Phonebook and Messages search. Additionaly code of the Phonebook Search window is cleaned up.
55 lines
2.2 KiB
C++
55 lines
2.2 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "SearchStart.hpp"
|
|
#include "../ApplicationMessages.hpp"
|
|
#include <i18n/i18n.hpp>
|
|
#include <widgets/InputBox.hpp>
|
|
#include <cassert>
|
|
|
|
namespace gui
|
|
{
|
|
|
|
SMSSearch::SMSSearch(app::Application *app) : AppWindow(app, name::window::thread_sms_search)
|
|
{
|
|
buildInterface();
|
|
setTitle(utils::localize.get("app_messages_title_main"));
|
|
bottomBar->setActive(BottomBar::Side::CENTER, true);
|
|
bottomBar->setActive(BottomBar::Side::RIGHT, true);
|
|
bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::search));
|
|
bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));
|
|
body = new gui::Item();
|
|
body->setBoundingBox(bodySize());
|
|
addWidget(body);
|
|
auto text = inputBox(this, utils::localize.get("common_search_uc"), "search");
|
|
text->setInputMode(new InputMode(
|
|
{InputMode::ABC, InputMode::abc, InputMode::digit},
|
|
[=](const UTF8 &Text) { application->getCurrentWindow()->bottomBarTemporaryMode(Text); },
|
|
[=]() { application->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); },
|
|
[=]() { application->getCurrentWindow()->selectSpecialCharacter(); }));
|
|
|
|
inputCallback = [=](Item &, const InputEvent &inputEvent) -> bool {
|
|
auto app = dynamic_cast<app::ApplicationMessages *>(application);
|
|
assert(app);
|
|
if (inputEvent.state != InputEvent::State::keyReleasedShort) {
|
|
return false;
|
|
}
|
|
if (inputEvent.keyCode == KeyCode::KEY_ENTER) {
|
|
auto search_text = text->getText();
|
|
app->showSearchResults(utils::localize.get("common_search_results") + ": " + std::string(search_text),
|
|
search_text);
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
setFocusItem(text);
|
|
}
|
|
|
|
bool SMSSearch::onInput(const InputEvent &inputEvent)
|
|
{
|
|
return AppWindow::onInput(inputEvent) || (inputCallback && inputCallback(*this, inputEvent));
|
|
}
|
|
|
|
} // namespace gui
|