~aleteoryx/muditaos

ref: 321f56e7744bc9f2cb487f1612cf77eb1ca6e3c7 muditaos/module-apps/application-settings/windows/system/SystemMainWindow.cpp -rw-r--r-- 2.9 KiB
321f56e7 — Lefucjusz [MOS-1032] Fix misleading 'Save' button behavior when setting time 2 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
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SystemMainWindow.hpp"

#include <application-settings/windows/WindowNames.hpp>

#include <DialogMetadataMessage.hpp>
#include <OptionSetting.hpp>
#include <service-desktop/DesktopMessages.hpp>

namespace gui
{
    SystemMainWindow::SystemMainWindow(app::ApplicationCommon *app) : BaseSettingsWindow(app, window::name::system)
    {
        setTitle(utils::translate("app_settings_system"));
    }

    auto SystemMainWindow::buildOptionsList() -> std::list<Option>
    {
        std::list<Option> optionList;
        auto addOption = [&](UTF8 name, const std::string &window) {
            optionList.emplace_back(std::make_unique<option::OptionSettings>(
                utils::translate(name),
                [=](Item &item) {
                    LOG_INFO("switching to %s page", window.c_str());
                    application->switchWindow(window, nullptr);
                    return true;
                },
                nullptr,
                nullptr,
                option::SettingRightItem::ArrowWhite));
        };

        auto addFactoryResetOption = [&](UTF8 name, const std::string &window) {
            optionList.emplace_back(std::make_unique<option::OptionSettings>(
                utils::translate(name),
                [=](Item &item) {
                    auto metaData = std::make_unique<gui::DialogMetadataMessage>(
                        gui::DialogMetadata{utils::translate("app_settings_factory_reset"),
                                            "info_128px_W_G",
                                            utils::translate("app_settings_display_factory_reset_confirmation"),
                                            "",
                                            [this]() {
                                                sys::SystemManagerCommon::FactoryReset(application);
                                                return true;
                                            }});
                    LOG_INFO("switching to %s page", window.c_str());
                    application->switchWindow(window, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
                    return true;
                },
                nullptr,
                this,
                option::SettingRightItem::Disabled));
        };

        addOption("app_settings_about_your_pure", gui::window::name::technical_information);
        addOption("app_settings_language", gui::window::name::languages);
        addOption("app_settings_date_and_time", gui::window::name::date_and_time);
        addOption("app_settings_certification", gui::window::name::certification);
        addOption("app_settings_sar", gui::window::name::sar);
        addFactoryResetOption("app_settings_factory_reset", gui::window::name::factory_reset);

        return optionList;
    }
} // namespace gui