Search in sources :

Example 1 with PersonalSettingsCommand

use of org.libresonic.player.command.PersonalSettingsCommand in project libresonic by Libresonic.

the class PersonalSettingsController method formBackingObject.

@ModelAttribute
protected void formBackingObject(HttpServletRequest request, Model model) throws Exception {
    PersonalSettingsCommand command = new PersonalSettingsCommand();
    User user = securityService.getCurrentUser(request);
    UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
    command.setUser(user);
    command.setLocaleIndex("-1");
    command.setThemeIndex("-1");
    command.setAlbumLists(AlbumListType.values());
    command.setAlbumListId(userSettings.getDefaultAlbumList().getId());
    command.setAvatars(settingsService.getAllSystemAvatars());
    command.setCustomAvatar(settingsService.getCustomAvatar(user.getUsername()));
    command.setAvatarId(getAvatarId(userSettings));
    command.setPartyModeEnabled(userSettings.isPartyModeEnabled());
    command.setQueueFollowingSongs(userSettings.isQueueFollowingSongs());
    command.setShowNowPlayingEnabled(userSettings.isShowNowPlayingEnabled());
    command.setShowArtistInfoEnabled(userSettings.isShowArtistInfoEnabled());
    command.setNowPlayingAllowed(userSettings.isNowPlayingAllowed());
    command.setMainVisibility(userSettings.getMainVisibility());
    command.setPlaylistVisibility(userSettings.getPlaylistVisibility());
    command.setFinalVersionNotificationEnabled(userSettings.isFinalVersionNotificationEnabled());
    command.setBetaVersionNotificationEnabled(userSettings.isBetaVersionNotificationEnabled());
    command.setSongNotificationEnabled(userSettings.isSongNotificationEnabled());
    command.setAutoHidePlayQueue(userSettings.isAutoHidePlayQueue());
    command.setListReloadDelay(userSettings.getListReloadDelay());
    command.setKeyboardShortcutsEnabled(userSettings.isKeyboardShortcutsEnabled());
    command.setLastFmEnabled(userSettings.isLastFmEnabled());
    command.setLastFmUsername(userSettings.getLastFmUsername());
    command.setLastFmPassword(userSettings.getLastFmPassword());
    command.setPaginationSize(userSettings.getPaginationSize());
    Locale currentLocale = userSettings.getLocale();
    Locale[] locales = settingsService.getAvailableLocales();
    String[] localeStrings = new String[locales.length];
    for (int i = 0; i < locales.length; i++) {
        localeStrings[i] = locales[i].getDisplayName(locales[i]);
        if (locales[i].equals(currentLocale)) {
            command.setLocaleIndex(String.valueOf(i));
        }
    }
    command.setLocales(localeStrings);
    String currentThemeId = userSettings.getThemeId();
    Theme[] themes = settingsService.getAvailableThemes();
    command.setThemes(themes);
    for (int i = 0; i < themes.length; i++) {
        if (themes[i].getId().equals(currentThemeId)) {
            command.setThemeIndex(String.valueOf(i));
            break;
        }
    }
    model.addAttribute("command", command);
}
Also used : Locale(java.util.Locale) PersonalSettingsCommand(org.libresonic.player.command.PersonalSettingsCommand) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Aggregations

Locale (java.util.Locale)1 PersonalSettingsCommand (org.libresonic.player.command.PersonalSettingsCommand)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1