From d8096a3695fe0fde70dbd9419827fb1915c316ae Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Mon, 21 Jan 2019 16:48:09 -0600 Subject: [PATCH] Added some keystrokes for audio playback. Read changelog for more references --- changelog.md | 5 +++++ src/wxUI/mainWindow.py | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 661504b..0c3576a 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,11 @@ * Fixed an error in Socializer that was making it unable to detect unread messages properly. * Socializer should save all tracebacks directly to error.log instead of displaying an error message during exit. ([#27,](https://code.manuelcortez.net/manuelcortez/socializer/issues/27)) * When displaying user profiles, fixed an error where a married person without specifing relation partner would cause an error in the program. ([#29,](https://code.manuelcortez.net/manuelcortez/socializer/issues/29)) +* Added new global keystrokes, available in the main window of Socializer. + * Alt + up/down arrows: Increase / decrease volume. + * Alt + Left/down arrows: Play previous and next song if playing an audios buffer. + * Control + P: Play/pause. + * control+Shift+P: Play all. ## Changes in version 0.18 (21.01.2019) diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index ae1eccb..20a7fa0 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -39,9 +39,8 @@ class mainWindow(wx.Frame): mb.Append(me, _("Me")) mb.Append(buffer, _("Buffer")) player = wx.Menu() - self.player_play = player.Append(wx.NewId(), _("Play")) + self.player_play = player.Append(wx.NewId(), _("Play/Pause")) self.player_play_all = player.Append(wx.NewId(), _("Play all")) - self.player_stop = player.Append(wx.NewId(), _("Stop")) self.player_previous = player.Append(wx.NewId(), _("Previous")) self.player_next = player.Append(wx.NewId(), _("Next")) self.player_shuffle = player.AppendCheckItem(wx.NewId(), _("Shuffle")) @@ -57,6 +56,17 @@ class mainWindow(wx.Frame): mb.Append(player, _("Audio player")) mb.Append(help_, _("Help")) self.SetMenuBar(mb) + self.accel_tbl = wx.AcceleratorTable([ + # Assign keystrokes to control the player object. + (wx.ACCEL_ALT, wx.WXK_LEFT, self.player_previous.GetId()), + (wx.ACCEL_ALT, wx.WXK_RIGHT, self.player_next.GetId()), + (wx.ACCEL_ALT, wx.WXK_DOWN, self.player_volume_down.GetId()), + (wx.ACCEL_ALT, wx.WXK_UP, self.player_volume_up.GetId()), + # Translators: Keystroke used to play/pause the current item in the playback queue. Use the latin alphabet, but you can match a different key here. For example if you want to assign this to the key "П", use G. + (wx.ACCEL_CTRL, ord(_("P")), self.player_play.GetId()), + (wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord(_("P")), self.player_play_all.GetId()), + ]) + self.SetAcceleratorTable(self.accel_tbl) def __init__(self): super(mainWindow, self).__init__(parent=None, id=wx.NewId(), title=application.name) @@ -129,8 +139,5 @@ class mainWindow(wx.Frame): self.tb.DeletePage(pos) def notify(self, title, text): - try: - self.notification = wx.adv.NotificationMessage(title, text, parent=self) - except AttributeError: - self.notification = wx.NotificationMessage(title, text) + self.notification = wx.adv.NotificationMessage(title, text, parent=self) self.notification.Show() \ No newline at end of file