ES-DE/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp
Leon Styhre ce9d5c2599 Fixed the screensaver random function so it does not show the same game twice in a row.
Also fixed a bug related to audio playing for the video screensaver and changed its name from 'random video' to simply 'video'.
2020-07-28 11:10:14 +02:00

104 lines
4.2 KiB
C++

//
// GuiSlideshowScreensaverOptions.cpp
//
// User interface for the slideshow screensaver options.
// Submenu to GuiGeneralScreensaverOptions.
//
#include "guis/GuiSlideshowScreensaverOptions.h"
#include "components/SliderComponent.h"
#include "components/SwitchComponent.h"
#include "guis/GuiTextEditPopup.h"
#include "utils/StringUtil.h"
#include "Settings.h"
#include "Window.h"
GuiSlideshowScreensaverOptions::GuiSlideshowScreensaverOptions(Window* window, const char* title)
: GuiScreensaverOptions(window, title)
{
ComponentListRow row;
// Image duration (in seconds).
auto sss_image_sec = std::make_shared<SliderComponent>(mWindow, 1.f, 60.f, 1.f, "s");
sss_image_sec->setValue((float)(Settings::getInstance()->
getInt("ScreenSaverSwapImageTimeout") / (1000)));
addWithLabel(row, "SWAP IMAGE AFTER (SECS)", sss_image_sec);
addSaveFunc([sss_image_sec] {
int playNextTimeout = (int)Math::round(sss_image_sec->getValue()) * (1000);
Settings::getInstance()->setInt("ScreenSaverSwapImageTimeout", playNextTimeout);
PowerSaver::updateTimeouts();
});
// Stretch image.
auto sss_stretch = std::make_shared<SwitchComponent>(mWindow);
sss_stretch->setState(Settings::getInstance()->getBool("ScreenSaverStretchImages"));
addWithLabel(row, "STRETCH IMAGES TO SCREEN RESOLUTION", sss_stretch);
addSaveFunc([sss_stretch] {
Settings::getInstance()->setBool("ScreenSaverStretchImages", sss_stretch->getState());
});
// Background audio file.
auto sss_bg_audio_file = std::make_shared<TextComponent>(mWindow, "",
Font::get(FONT_SIZE_SMALL), 0x777777FF);
addEditableTextComponent(row, "BACKGROUND AUDIO", sss_bg_audio_file,
Settings::getInstance()->getString("SlideshowScreenSaverBackgroundAudioFile"));
addSaveFunc([sss_bg_audio_file] {
Settings::getInstance()->setString("SlideshowScreenSaverBackgroundAudioFile",
sss_bg_audio_file->getValue());
});
// Image source.
auto sss_custom_source = std::make_shared<SwitchComponent>(mWindow);
sss_custom_source->setState(Settings::getInstance()->
getBool("SlideshowScreenSaverCustomImageSource"));
addWithLabel(row, "USE CUSTOM IMAGES", sss_custom_source);
addSaveFunc([sss_custom_source] { Settings::getInstance()->
setBool("SlideshowScreenSaverCustomImageSource", sss_custom_source->getState()); });
// Custom image directory.
auto sss_image_dir = std::make_shared<TextComponent>(mWindow, "",
Font::get(FONT_SIZE_SMALL), 0x777777FF);
addEditableTextComponent(row, "CUSTOM IMAGE DIR", sss_image_dir,
Settings::getInstance()->getString("SlideshowScreenSaverImageDir"));
addSaveFunc([sss_image_dir] {
Settings::getInstance()->setString("SlideshowScreenSaverImageDir",
sss_image_dir->getValue());
});
// Recurse custom image directory.
auto sss_recurse = std::make_shared<SwitchComponent>(mWindow);
sss_recurse->setState(Settings::getInstance()->getBool("SlideshowScreenSaverRecurse"));
addWithLabel(row, "CUSTOM IMAGE DIR RECURSIVE", sss_recurse);
addSaveFunc([sss_recurse] {
Settings::getInstance()->setBool("SlideshowScreenSaverRecurse", sss_recurse->getState());
});
// Custom image filter (file extensions).
auto sss_image_filter = std::make_shared<TextComponent>(mWindow, "",
Font::get(FONT_SIZE_SMALL), 0x777777FF);
addEditableTextComponent(row, "CUSTOM IMAGE FILTER", sss_image_filter,
Settings::getInstance()->getString("SlideshowScreenSaverImageFilter"));
addSaveFunc([sss_image_filter] {
Settings::getInstance()->setString("SlideshowScreenSaverImageFilter",
sss_image_filter->getValue());
});
}
GuiSlideshowScreensaverOptions::~GuiSlideshowScreensaverOptions()
{
}
void GuiSlideshowScreensaverOptions::addWithLabel(ComponentListRow row,
const std::string label, std::shared_ptr<GuiComponent> component)
{
row.elements.clear();
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(label),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
row.addElement(lbl, true); // Label.
row.addElement(component, false, true);
addRow(row);
}