Add user option for keyboard shortcuts

master
François-Xavier Thomas 9 years ago
parent 8006d62f55
commit fccf2a013d
No known key found for this signature in database
GPG Key ID: 64337406D2DD45CE
  1. 9
      libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java
  2. 1
      libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java
  3. 2
      libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java
  4. 5
      libresonic-main/src/main/java/org/libresonic/player/dao/UserDao.java
  5. 6
      libresonic-main/src/main/java/org/libresonic/player/dao/schema/hsql/Schema61.java
  6. 9
      libresonic-main/src/main/java/org/libresonic/player/domain/UserSettings.java
  7. 1
      libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java
  8. 1
      libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_de.properties
  9. 1
      libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties
  10. 19
      libresonic-main/src/main/webapp/WEB-INF/jsp/head.jsp
  11. 9
      libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp

@ -52,6 +52,7 @@ public class PersonalSettingsCommand {
private boolean showArtistInfoEnabled;
private boolean nowPlayingAllowed;
private boolean autoHidePlayQueue;
private boolean keyboardShortcutsEnabled;
private boolean finalVersionNotificationEnabled;
private boolean betaVersionNotificationEnabled;
private boolean songNotificationEnabled;
@ -230,6 +231,14 @@ public class PersonalSettingsCommand {
this.autoHidePlayQueue = autoHidePlayQueue;
}
public boolean isKeyboardShortcutsEnabled() {
return keyboardShortcutsEnabled;
}
public void setKeyboardShortcutsEnabled(boolean keyboardShortcutsEnabled) {
this.keyboardShortcutsEnabled = keyboardShortcutsEnabled;
}
public boolean isLastFmEnabled() {
return lastFmEnabled;
}

@ -238,6 +238,7 @@ public class MultiController extends MultiActionController {
map.put("showRight", userSettings.isShowNowPlayingEnabled() || userSettings.isShowChatEnabled());
map.put("autoHidePlayQueue", userSettings.isAutoHidePlayQueue());
map.put("listReloadDelay", userSettings.getListReloadDelay());
map.put("keyboardShortcutsEnabled", userSettings.isKeyboardShortcutsEnabled());
map.put("showSideBar", userSettings.isShowSideBar());
map.put("brand", settingsService.getBrand());
return new ModelAndView("index", "model", map);

@ -74,6 +74,7 @@ public class PersonalSettingsController extends SimpleFormController {
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());
@ -137,6 +138,7 @@ public class PersonalSettingsController extends SimpleFormController {
settings.setSongNotificationEnabled(command.isSongNotificationEnabled());
settings.setAutoHidePlayQueue(command.isAutoHidePlayQueue());
settings.setListReloadDelay(command.getListReloadDelay());
settings.setKeyboardShortcutsEnabled(command.isKeyboardShortcutsEnabled());
settings.setLastFmEnabled(command.isLastFmEnabled());
settings.setLastFmUsername(command.getLastFmUsername());
settings.setSystemAvatarId(getSystemAvatarId(command));

@ -44,7 +44,7 @@ public class UserDao extends AbstractDao {
"playlist_year, playlist_bit_rate, playlist_duration, playlist_format, playlist_file_size, " +
"last_fm_enabled, last_fm_username, last_fm_password, transcode_scheme, show_now_playing, selected_music_folder_id, " +
"party_mode_enabled, now_playing_allowed, avatar_scheme, system_avatar_id, changed, show_chat, show_artist_info, auto_hide_play_queue, " +
"view_as_list, default_album_list, queue_following_songs, show_side_bar, list_reload_delay";
"view_as_list, default_album_list, queue_following_songs, show_side_bar, list_reload_delay, keyboard_shortcuts_enabled";
private static final Integer ROLE_ID_ADMIN = 1;
private static final Integer ROLE_ID_DOWNLOAD = 2;
@ -188,7 +188,7 @@ public class UserDao extends AbstractDao {
settings.getAvatarScheme().name(), settings.getSystemAvatarId(), settings.getChanged(),
settings.isShowChatEnabled(), settings.isShowArtistInfoEnabled(), settings.isAutoHidePlayQueue(),
settings.isViewAsList(), settings.getDefaultAlbumList().getId(), settings.isQueueFollowingSongs(),
settings.isShowSideBar(), settings.getListReloadDelay()});
settings.isShowSideBar(), settings.getListReloadDelay(), settings.isKeyboardShortcutsEnabled()});
}
private static String encrypt(String s) {
@ -350,6 +350,7 @@ public class UserDao extends AbstractDao {
settings.setQueueFollowingSongs(rs.getBoolean(col++));
settings.setShowSideBar(rs.getBoolean(col++));
settings.setListReloadDelay((Integer) rs.getObject(col++));
settings.setKeyboardShortcutsEnabled(rs.getBoolean(col++));
return settings;
}

@ -44,5 +44,11 @@ public class Schema61 extends Schema {
template.execute("alter table user_settings add list_reload_delay int default 60 not null");
LOG.info("Database column 'user_settings.list_reload_delay' was added successfully.");
}
if (!columnExists(template, "keyboard_shortcuts_enabled", "user_settings")) {
LOG.info("Database column 'user_settings.keyboard_shortcuts_enabled' not found. Creating it.");
template.execute("alter table user_settings add keyboard_shortcuts_enabled boolean default false not null");
LOG.info("Database column 'user_settings.keyboard_shortcuts_enabled' was added successfully.");
}
}
}

@ -38,6 +38,7 @@ public class UserSettings {
private boolean finalVersionNotificationEnabled;
private boolean betaVersionNotificationEnabled;
private boolean songNotificationEnabled;
private boolean keyboardShortcutsEnabled;
private boolean autoHidePlayQueue;
private boolean showSideBar;
private boolean viewAsList;
@ -221,6 +222,14 @@ public class UserSettings {
this.autoHidePlayQueue = autoHidePlayQueue;
}
public boolean isKeyboardShortcutsEnabled() {
return keyboardShortcutsEnabled;
}
public void setKeyboardShortcutsEnabled(boolean keyboardShortcutsEnabled) {
this.keyboardShortcutsEnabled = keyboardShortcutsEnabled;
}
public boolean isShowSideBar() {
return showSideBar;
}

@ -1264,6 +1264,7 @@ public class SettingsService {
settings.setPartyModeEnabled(false);
settings.setNowPlayingAllowed(true);
settings.setAutoHidePlayQueue(true);
settings.setKeyboardShortcutsEnabled(false);
settings.setShowSideBar(true);
settings.setShowArtistInfoEnabled(true);
settings.setViewAsList(false);

@ -350,6 +350,7 @@ personalsettings.nowplayingallowed = Zeige anderen was ich h\u00F6re
personalsettings.showchat = Zeige Chat Nachrichten
personalsettings.showartistinfo = Zeige Artisten-Info
personalsettings.autohideplayqueue = Playlist automatisch ausblenden
personalsettings.keyboardshortcutsenabled = Tastaturk\u00FCrzeln aktivieren
personalsettings.finalversionnotification = Informiere mich \u00FCber neue Versionen
personalsettings.betaversionnotification = Informiere mich \u00FCber neue Beta Versionen
personalsettings.songnotification = Benachrichtigen Sie mich, wenn neue Songs gespielt werden (nicht von allen Browsern unterst\u00FCtzt)

@ -375,6 +375,7 @@ personalsettings.nowplayingallowed = Let others see what I am playing
personalsettings.showchat = Show chat messages
personalsettings.showartistinfo = Show artist info
personalsettings.autohideplayqueue = Auto-hide play queue
personalsettings.keyboardshortcutsenabled = Enable keyboard shortcuts
personalsettings.finalversionnotification = Notify me about new versions
personalsettings.betaversionnotification = Notify me about new beta versions
personalsettings.songnotification = Notify me when new songs are played (not supported by all browsers)

@ -11,9 +11,21 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,300,400italic,500,300italic,500italic,700,700italic,100,100italic" type="text/css"/>
<title>Libresonic</title>
<!-- Import Mousetrap and enable shortcuts if necessary -->
<script>
function isKeyboardShortcutsEnabled() {
if (window === parent.frames.top) {
return ${model.keyboardShortcutsEnabled ? 'true' : 'false'};
} else {
return parent.frames.top.isKeyboardShortcutsEnabled();
}
}
</script>
<!-- Bind shortcuts if enabled -->
<script type="text/javascript" src="<c:url value="/script/mousetrap-1.6.0.js"/>"></script>
<script type="text/javascript">
if (isKeyboardShortcutsEnabled()) {
Mousetrap.bind('space', function() { parent.frames.playQueue.onToggleStartStop(); return false; });
Mousetrap.bind('left', function() { parent.frames.playQueue.onPrevious(); });
Mousetrap.bind('right', function() { parent.frames.playQueue.onNext(); });
@ -33,8 +45,5 @@
Mousetrap.bind('g r', function() { parent.frames.main.location.href = "more.view?"; });
Mousetrap.bind('g a', function() { parent.frames.main.location.href = "help.view?"; });
Mousetrap.bind('?', function() { parent.frames.main.location.href = "more.view#shortcuts"; });
// Mousetrap.bind('shift+left', function() { getPlayerWindow().keyboardShortcut("seekBackward") });
// Mousetrap.bind('shift+right', function() { getPlayerWindow().keyboardShortcut("seekForward") });
}
</script>

@ -179,6 +179,13 @@
</tr>
</table>
<table class="indent">
<tr>
<td><form:checkbox path="keyboardShortcutsEnabled" id="keyboardShortcutsEnabled" cssClass="checkbox"/></td>
<td><label for="keyboardShortcutsEnabled"><fmt:message key="personalsettings.keyboardshortcutsenabled"/></label></td>
</tr>
</table>
<table class="indent">
<tr>
<td><fmt:message key="personalsettings.listreloaddelay"/></td>
@ -253,4 +260,4 @@
</script>
</c:if>
</body></html>
</body></html>

Loading…
Cancel
Save