~aleteoryx/muditaos

60c96c6ecd911ce82af454976b76b0bc081d1deb — Mateusz Grzegorzek 4 years ago 076c3cb
[EGD-2631] Create window for entering connection code

Create only window.
Business logic will be added later.
A image/assets/images/bluetooth_W_G.vpi => image/assets/images/bluetooth_W_G.vpi +0 -0
M image/assets/lang/English.json => image/assets/lang/English.json +1 -0
@@ 316,6 316,7 @@
  "app_settings_bluetooth_main": "Bluetooth",
  "app_settings_bluetooth_phone_name": "Phone name",
  "app_settings_bluetooth_phone_visibility": "Phone visibility",
  "app_settings_bluetooth_enter_passkey": "Enter passkey:",
  "app_settings_net": "Network",
  "app_settings_disp_key": "Display and keypad",
  "app_settings_display_display_light": "Display light",

M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +1 -0
@@ 60,6 60,7 @@ namespace gui::window::name
    inline constexpr auto change_time_zone     = "ChangeTimeZone";

    inline constexpr auto new_apn = "NewApn";
    inline constexpr auto bluetooth_check_passkey = "BluetoothCheckPasskey";

} // namespace gui::window::name


M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +1 -0
@@ 53,6 53,7 @@ target_sources( ${PROJECT_NAME}
        windows/LanguagesWindow.cpp
        windows/DateAndTimeMainWindow.cpp
        windows/ChangeTimeZone.cpp
        windows/BluetoothCheckPasskeyWindow.cpp

    PUBLIC
        ApplicationSettings.hpp

M module-apps/application-settings-new/widgets/SettingsStyle.hpp => module-apps/application-settings-new/widgets/SettingsStyle.hpp +26 -0
@@ 90,6 90,32 @@ namespace style
                inline constexpr uint32_t h = style::window_height - y - style::footer::height;
            } // namespace newApn

            namespace bluetooth
            {
                namespace passkey
                {
                    namespace image
                    {
                        inline constexpr auto x = 176;
                        inline constexpr auto y = 132;
                    } // namespace image

                    namespace label
                    {
                        inline constexpr auto x = 150U;
                        inline constexpr auto y = 300U;
                        inline constexpr auto w = 200U;
                    } // namespace label

                    namespace text
                    {
                        inline constexpr auto x = 40U;
                        inline constexpr auto y = 370U;
                        inline constexpr auto w = style::window_width - 2 * x;
                        inline constexpr auto h = 52;
                    } // namespace text
                }     // namespace passkey
            }         // namespace bluetooth
        }     // namespace window
    };        // namespace settings
} // namespace style

A module-apps/application-settings-new/windows/BluetoothCheckPasskeyWindow.cpp => module-apps/application-settings-new/windows/BluetoothCheckPasskeyWindow.cpp +56 -0
@@ 0,0 1,56 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BluetoothCheckPasskeyWindow.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
#include "application-settings-new/widgets/SettingsStyle.hpp"
#include <widgets/Text.hpp>

namespace gui
{
    namespace
    {
        constexpr auto maxPasskeyCharactersCount = 16U;
    }
    namespace passkey_style = style::settings::window::bluetooth::passkey;

    BluetoothCheckPasskeyWindow::BluetoothCheckPasskeyWindow(app::Application *app)
        : AppWindow(app, window::name::bluetooth_check_passkey)
    {
        buildInterface();
    }

    void BluetoothCheckPasskeyWindow::buildInterface()
    {
        AppWindow::buildInterface();

        setTitle(utils::localize.get("app_settings_bt"));

        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::confirm));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));

        image = new Image(this, passkey_style::image::x, passkey_style::image::y, 0, 0, "bluetooth_W_G");

        label = new Label(this,
                          passkey_style::label::x,
                          passkey_style::label::y,
                          passkey_style::label::w,
                          style::window::label::default_h);
        label->setFont(style::window::font::big);
        label->setEdges(RectangleEdge::None);
        label->setText(utils::localize.get("app_settings_bluetooth_enter_passkey"));

        text = new Text(
            this, passkey_style::text::x, passkey_style::text::y, passkey_style::text::w, passkey_style::text::h);
        text->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top));
        text->setTextLimitType(TextLimitType::MaxSignsCount, maxPasskeyCharactersCount);
        text->setEdges(RectangleEdge::Bottom);
        text->setInputMode(new InputMode({InputMode::digit}));
        text->setPenWidth(style::window::default_border_rect_no_focus);
        text->setFont(style::window::font::largelight);

        setFocusItem(text);
    }
} // namespace gui

A module-apps/application-settings-new/windows/BluetoothCheckPasskeyWindow.hpp => module-apps/application-settings-new/windows/BluetoothCheckPasskeyWindow.hpp +25 -0
@@ 0,0 1,25 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <AppWindow.hpp>

namespace gui
{
    class Image;
    class Label;
    class Text;
    class BluetoothCheckPasskeyWindow : public AppWindow
    {
      public:
        BluetoothCheckPasskeyWindow(app::Application *app);

      private:
        void buildInterface() override;

        Image *image = nullptr;
        Label *label = nullptr;
        Text *text   = nullptr;
    };
} // namespace gui