mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-21 13:35:04 -04:00
Sound selection GUI used to change ringtone, message sound and notification sound in settings.
67 lines
2.3 KiB
C++
67 lines
2.3 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 "CalendarWindow.hpp"
|
|
|
|
#include <application-settings-new/data/SoundSelectData.hpp>
|
|
#include <application-settings-new/ApplicationSettings.hpp>
|
|
#include <i18n/i18n.hpp>
|
|
#include "BaseSettingsWindow.hpp"
|
|
#include <OptionSetting.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
CalendarWindow::CalendarWindow(app::Application *app,
|
|
std::unique_ptr<audio_settings::AbstractAudioSettingsModel> &&audioModel)
|
|
: BaseSettingsWindow(app, gui::window::name::calendar), mWidgetMaker(this), mAudioModel(std::move(audioModel))
|
|
{
|
|
setTitle(utils::translate("app_settings_apps_calendar"));
|
|
}
|
|
|
|
std::list<Option> CalendarWindow::buildOptionsList()
|
|
{
|
|
std::list<gui::Option> optionList;
|
|
mVibrationsEnabled = mAudioModel->isVibrationEnabled();
|
|
mSoundEnabled = mAudioModel->isSoundEnabled();
|
|
|
|
mWidgetMaker.addSwitchOption(optionList, utils::translate("app_settings_vibration"), mVibrationsEnabled, [&]() {
|
|
switchVibrationState();
|
|
});
|
|
|
|
mWidgetMaker.addSwitchOption(
|
|
optionList, utils::translate("app_settings_sound"), mSoundEnabled, [&]() { switchSoundState(); });
|
|
|
|
if (mSoundEnabled) {
|
|
mWidgetMaker.addSelectOption(
|
|
optionList,
|
|
utils::translate("app_settings_notification_sound"),
|
|
[&]() { openNoticicationSoundWindow(); },
|
|
true);
|
|
}
|
|
|
|
return optionList;
|
|
}
|
|
|
|
void CalendarWindow::switchVibrationState()
|
|
{
|
|
(mVibrationsEnabled) ? mAudioModel->setVibrationDisabled() : mAudioModel->setVibrationEnabled();
|
|
refreshOptionsList();
|
|
}
|
|
|
|
void CalendarWindow::switchSoundState()
|
|
{
|
|
mSoundEnabled ? mAudioModel->setSoundDisabled() : mAudioModel->setSoundEnabled();
|
|
refreshOptionsList();
|
|
}
|
|
|
|
void CalendarWindow::openNoticicationSoundWindow()
|
|
{
|
|
SoundSelectData::Info info;
|
|
info.windowTitle = utils::translate("app_settings_notification_sound");
|
|
info.audioModel = mAudioModel.get();
|
|
|
|
application->switchWindow(gui::window::name::sound_select, std::make_unique<SoundSelectData>(info));
|
|
}
|
|
|
|
} // namespace gui
|