mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-23 16:40:22 -04:00
1. Prepare Pure and Bell specific `Application` classes and add them to `app` target: - `products/BellHybrid/apps/Application.cpp` - `products/PurePhone/apps/Application.cpp` 2. Update `CMakeLists.txt` files. 3. Move `ApplicationBell` implementation to Bell-specific `Application` class and remove `ApplicationBell` files. 4. Change Bell apps parent classes from `ApplicationBell` to Bell-specific `Application` class. 5. Rename `Application` to `ApplicationCommon` in the rest of the files.
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "PhoneNameWindow.hpp"
|
|
|
|
#include <application-settings/data/PhoneNameData.hpp>
|
|
#include <application-settings/windows/WindowNames.hpp>
|
|
|
|
#include <widgets/InputBox.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
PhoneNameWindow::PhoneNameWindow(app::ApplicationCommon *app) : AppWindow(app, gui::window::name::phone_name)
|
|
{
|
|
bluetoothSettingsModel = std::make_unique<BluetoothSettingsModel>(application);
|
|
bluetoothSettingsModel->requestDeviceName();
|
|
buildInterface();
|
|
}
|
|
|
|
void PhoneNameWindow::buildInterface()
|
|
{
|
|
AppWindow::buildInterface();
|
|
|
|
setTitle(utils::translate("app_settings_bluetooth_phone_name"));
|
|
|
|
inputField = inputBox(this, utils::translate("app_settings_bluetooth_phone_name"));
|
|
bottomBar->setActive(BottomBar::Side::LEFT, false);
|
|
bottomBar->setActive(BottomBar::Side::CENTER, true);
|
|
bottomBar->setActive(BottomBar::Side::RIGHT, true);
|
|
|
|
bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::save));
|
|
bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));
|
|
|
|
setFocusItem(inputField);
|
|
}
|
|
|
|
void PhoneNameWindow::destroyInterface()
|
|
{
|
|
AppWindow::destroyInterface();
|
|
erase(inputField);
|
|
inputField = nullptr;
|
|
}
|
|
|
|
void PhoneNameWindow::onBeforeShow(ShowMode /*mode*/, SwitchData *data)
|
|
{
|
|
if (const auto newData = dynamic_cast<PhoneNameData *>(data); data != nullptr) {
|
|
inputField->setText(newData->getName());
|
|
inputField->setTextLimitType(gui::TextLimitType::MaxSignsCount, maxNameLength);
|
|
}
|
|
}
|
|
|
|
auto PhoneNameWindow::onInput(const InputEvent &inputEvent) -> bool
|
|
{
|
|
if (AppWindow::onInput(inputEvent)) {
|
|
return true;
|
|
}
|
|
|
|
if (inputEvent.isShortRelease(gui::KeyCode::KEY_ENTER) && !inputField->isEmpty()) {
|
|
bluetoothSettingsModel->setDeviceName(inputField->getText());
|
|
application->returnToPreviousWindow();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} // namespace gui
|