~aleteoryx/muditaos

ref: 9c41f6f592b5bf2527a60d802673b10cc9065439 muditaos/module-apps/application-settings-new/windows/SettingsMainWindow.cpp -rw-r--r-- 2.7 KiB
9c41f6f5 — Jakub Pyszczak [EGD-6350] Added bluetooth device volume control 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SettingsMainWindow.hpp"
#include "application-settings-new/ApplicationSettings.hpp"

#include <i18n/i18n.hpp>
#include <log/log.hpp>
#include <service-appmgr/Controller.hpp>

std::list<gui::Option> mainWindowOptionsNew(app::Application *app)
{
    std::list<gui::Option> l;

    auto i18     = [](const std::string &text) { return utils::localize.get(text); };
    auto addMenu = [&l, &app](UTF8 name, const std::string &window = "") {
        l.emplace_back(gui::Option{name,
                                   [=](gui::Item &item) {
                                       if (window.empty()) {
                                           return false;
                                       }
                                       LOG_INFO("switching to %s page", window.c_str());
                                       app->switchWindow(window, nullptr);
                                       return true;
                                   },
                                   gui::option::Arrow::Enabled});
    };
    auto addApp = [&l, &app](UTF8 name, const std::string &window = "") {
        l.emplace_back(gui::Option{name,
                                   [=](gui::Item &item) {
                                       if (window.empty()) {
                                           return false;
                                       }
                                       LOG_INFO("switching to %s page", window.c_str());
                                       app::manager::Controller::sendAction(
                                           app,
                                           app::manager::actions::Launch,
                                           std::make_unique<app::ApplicationLaunchData>("ApplicationSettings"));
                                       app->switchWindow(window, nullptr);
                                       return true;
                                   },
                                   gui::option::Arrow::Enabled});
    };

    addApp(i18("app_desktop_menu_settings"), "Settings");
    addMenu(i18("app_settings_bt"), gui::window::name::bluetooth);
    addMenu(i18("app_settings_net"), gui::window::name::network);
    addMenu(i18("app_settings_disp_key"), gui::window::name::display_and_keypad);
    addMenu(i18("app_settings_phone_modes"), gui::window::name::phone_modes);
    addMenu(i18("app_settings_apps_tools"), gui::window::name::apps_and_tools);
    addMenu(i18("app_settings_security"), gui::window::name::security);
    addMenu(i18("app_settings_system"), gui::window::name::system);
    return l;
}