commit/StationPlaylist: josephsl: Merge branches 'master' and '7.0/blackOptimizations' into staging

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Thu, 18 Feb 2016 18:32:05 -0000

1 new commit in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/72041fc966c4/
Changeset:   72041fc966c4
Branch:      staging
User:        josephsl
Date:        2016-02-18 18:30:17+00:00
Summary:     Merge branches 'master' and '7.0/blackOptimizations' into staging

Affected #:  3 files

diff --git a/addon/appModules/splstudio/__init__.py 
b/addon/appModules/splstudio/__init__.py
index dc94ff9..6822af8 100755
--- a/addon/appModules/splstudio/__init__.py
+++ b/addon/appModules/splstudio/__init__.py
@@ -119,12 +119,19 @@ class SPLTrackItem(IAccessible):
                        self.bindGesture("kb:rightArrow", "nextColumn")
                        self.bindGesture("kb:leftArrow", "prevColumn")
 
+       # Locate the real column index for a column header.
+       # This is response to a situation where columns were rearranged yet 
testing shows in-memory arrangement remains the same.
+       # Subclasses must provide this function.
+       def _origIndexOf(self, columnHeader):
+               return 
splconfig._SPLDefaults7["General"]["ExploreColumns"].index(columnHeader)
+
        # Read selected columns.
        # But first, find where the requested column lives.
+       # 8.0: Make this a public function.
        def _indexOf(self, columnHeader):
                # Handle both 5.0x and 5.10 column headers.
                try:
-                       return 
self.appModule._columnHeaderNames.index(columnHeader)
+                       return self._origIndexOf(columnHeader)
                except ValueError:
                        return None
 
@@ -212,9 +219,10 @@ class SPLTrackItem(IAccessible):
                return splmisc._getColumnContent(self, col)
 
        # Announce column content if any.
-       def announceColumnContent(self, colNumber):
-               columnHeader = 
self.appModule._columnHeaders.children[colNumber].name
-               columnContent = self._getColumnContent(colNumber)
+       # 7.0: Add an optional header in order to announce correct header 
information in columns explorer.
+       def announceColumnContent(self, colNumber, header=None):
+               columnHeader = header if header is not None else 
self.appModule._columnHeaderNames[colNumber]
+               columnContent = 
self._getColumnContent(self._indexOf(columnHeader))
                if columnContent:
                        # Translators: Standard message for announcing column 
content.
                        ui.message(unicode(_("{header}: 
{content}")).format(header = columnHeader, content = columnContent))
@@ -227,8 +235,6 @@ class SPLTrackItem(IAccessible):
        # Now the scripts.
 
        def script_nextColumn(self, gesture):
-               if self.appModule._columnHeaders is None:
-                       self.appModule._columnHeaders = self.parent.children[-1]
                if (self.appModule.SPLColNumber+1) == 
self.appModule._columnHeaders.childCount:
                        tones.beep(2000, 100)
                else:
@@ -236,8 +242,6 @@ class SPLTrackItem(IAccessible):
                self.announceColumnContent(self.appModule.SPLColNumber)
 
        def script_prevColumn(self, gesture):
-               if self.appModule._columnHeaders is None:
-                       self.appModule._columnHeaders = self.parent.children[-1]
                if self.appModule.SPLColNumber <= 0:
                        tones.beep(2000, 100)
                else:
@@ -264,6 +268,10 @@ class SPL510TrackItem(SPLTrackItem):
                speech.speakMessage(self.name)
                braille.handler.handleUpdate(self)
 
+       # Studio 5.10 version of original index finder.
+       def _origIndexOf(self, columnHeader):
+               return 
splconfig._SPLDefaults7["ColumnAnnouncement"]["ColumnOrder"].index(columnHeader)+1
+
        # Handle track dial for SPL 5.10.
        def _leftmostcol(self):
                if not self.name:
@@ -768,23 +776,16 @@ class AppModule(appModuleHandler.AppModule):
        # Translators: Input help mode message for a command in Station 
Playlist Studio.
        script_sayCompleteTime.__doc__=_("Announces time including seconds.")
 
-       # Set the end of track alarm time between 1 and 59 seconds.
-       # Make sure one of either settings or alarm dialogs is open.
+       # Invoke the common alarm dialog.
+       # The below invocation function is also used for error handling 
purposes.
 
-       def script_setEndOfTrackTime(self, gesture):
+       def alarmDialog(self, setting, toggleSetting, title, alarmPrompt, 
alarmToggleLabel, min, max):
                if splconfig._configDialogOpened:
                        # Translators: Presented when the add-on config dialog 
is opened.
                        wx.CallAfter(gui.messageBox, _("The add-on settings 
dialog is opened. Please close the settings dialog first."), _("Error"), 
wx.OK|wx.ICON_ERROR)
                        return
                try:
-                       timeVal = 
splconfig.SPLConfig["IntroOutroAlarms"]["EndOfTrackTime"]
-                       d = splconfig.SPLAlarmDialog(gui.mainFrame, 
"EndOfTrackTime", "SayEndOfTrack",
-                       # Translators: The title of end of track alarm dialog.
-                       _("End of track alarm"),
-                       # Translators: A dialog message to set end of track 
alarm (curAlarmSec is the current end of track alarm in seconds).
-                       _("Enter &end of track alarm time in seconds (currently 
{curAlarmSec})").format(curAlarmSec = timeVal),
-                       # Translators: A check box to toggle notification of 
end of track alarm.
-                       _("&Notify when end of track is approaching"), 1, 59)
+                       d = splconfig.SPLAlarmDialog(gui.mainFrame, setting, 
toggleSetting, title, alarmPrompt, alarmToggleLabel, min, max)
                        gui.mainFrame.prePopup()
                        d.Raise()
                        d.Show()
@@ -792,35 +793,36 @@ class AppModule(appModuleHandler.AppModule):
                        splconfig._alarmDialogOpened = True
                except RuntimeError:
                        wx.CallAfter(splconfig._alarmError)
+
+       # Set the end of track alarm time between 1 and 59 seconds.
+
+       def script_setEndOfTrackTime(self, gesture):
+               timeVal = 
splconfig.SPLConfig["IntroOutroAlarms"]["EndOfTrackTime"]
+               self.alarmDialog("EndOfTrackTime", "SayEndOfTrack",
+               # Translators: The title of end of track alarm dialog.
+               _("End of track alarm"),
+               # Translators: A dialog message to set end of track alarm 
(curAlarmSec is the current end of track alarm in seconds).
+               _("Enter &end of track alarm time in seconds (currently 
{curAlarmSec})").format(curAlarmSec = timeVal),
+               # Translators: A check box to toggle notification of end of 
track alarm.
+               _("&Notify when end of track is approaching"), 1, 59)
        # Translators: Input help mode message for a command in Station 
Playlist Studio.
        script_setEndOfTrackTime.__doc__=_("sets end of track alarm (default is 
5 seconds).")
 
        # Set song ramp (introduction) time between 1 and 9 seconds.
 
        def script_setSongRampTime(self, gesture):
-               if splconfig._configDialogOpened:
-                       wx.CallAfter(gui.messageBox, _("The add-on settings 
dialog is opened. Please close the settings dialog first."), _("Error"), 
wx.OK|wx.ICON_ERROR)
-                       return
-               try:
-                       rampVal = 
splconfig.SPLConfig["IntroOutroAlarms"]["SongRampTime"]
-                       d = splconfig.SPLAlarmDialog(gui.mainFrame, 
"SongRampTime", "SaySongRamp",
-                       # Translators: The title of song intro alarm dialog.
-                       _("Song intro alarm"),
-                       # Translators: A dialog message to set song ramp alarm 
(curRampSec is the current intro monitoring alarm in seconds).
-                       _("Enter song &intro alarm time in seconds (currently 
{curRampSec})").format(curRampSec = rampVal),
-                       # Translators: A check box to toggle notification of 
end of intro alarm.
-                       _("&Notify when end of introduction is approaching"), 
1, 9)
-                       gui.mainFrame.prePopup()
-                       d.Raise()
-                       d.Show()
-                       gui.mainFrame.postPopup()
-                       splconfig._alarmDialogOpened = True
-               except RuntimeError:
-                       wx.CallAfter(splconfig._alarmError)
+               rampVal = 
splconfig.SPLConfig["IntroOutroAlarms"]["SongRampTime"]
+               self.alarmDialog("SongRampTime", "SaySongRamp",
+               # Translators: The title of song intro alarm dialog.
+               _("Song intro alarm"),
+               # Translators: A dialog message to set song ramp alarm 
(curRampSec is the current intro monitoring alarm in seconds).
+               _("Enter song &intro alarm time in seconds (currently 
{curRampSec})").format(curRampSec = rampVal),
+               # Translators: A check box to toggle notification of end of 
intro alarm.
+               _("&Notify when end of introduction is approaching"), 1, 9)
        # Translators: Input help mode message for a command in Station 
Playlist Studio.
        script_setSongRampTime.__doc__=_("sets song intro alarm (default is 5 
seconds).")
 
-# Tell NVDA to play a sound when mic was active for a long time.
+       # Tell NVDA to play a sound when mic was active for a long time.
 
        def script_setMicAlarm(self, gesture):
                if splconfig._configDialogOpened:
@@ -1465,8 +1467,6 @@ class AppModule(appModuleHandler.AppModule):
                statusAPI(1, 27, self.announceTime)
 
        def script_sayPlaylistRemainingDuration(self, gesture):
-               # 7.0: Manually go through all tracks, calculationg total 
duration (a bit of discrepancy may result).
-               tones.beep(1024, 30)
                obj = api.getFocusObject()
                if obj.role == controlTypes.ROLE_LIST:
                        ui.message("00:00")
@@ -1676,7 +1676,8 @@ class AppModule(appModuleHandler.AppModule):
                                # Translators: Presented when attempting to 
announce specific columns but the focused item isn't a track.
                                ui.message(_("Not a track"))
                        else:
-                               
focus.announceColumnContent(focus._indexOf(splconfig.SPLConfig["General"]["ExploreColumns"][columnPos]))
+                               header = 
splconfig.SPLConfig["General"]["ExploreColumns"][columnPos]
+                               
focus.announceColumnContent(focus._indexOf(header), header=header)
 
        def script_layerHelp(self, gesture):
                compatibility = 
splconfig.SPLConfig["Advanced"]["CompatibilityLayer"]

diff --git a/addon/appModules/splstudio/splconfig.py 
b/addon/appModules/splstudio/splconfig.py
index 37f96d3..a0dd523 100755
--- a/addon/appModules/splstudio/splconfig.py
+++ b/addon/appModules/splstudio/splconfig.py
@@ -38,7 +38,7 @@ LibraryScanAnnounce = option("off", "ending", "progress", 
"numbers", default="of
 TrackDial = boolean(default=false)
 CategorySounds = boolean(default=false)
 MetadataReminder = option("off", "startup", "instant", default="off")
-TimeHourAnnounce = boolean(default=false)
+TimeHourAnnounce = boolean(default=true)
 ExploreColumns = 
string_list(default=list("Artist","Title","Duration","Intro","Category","Filename","Year","Album","Genre","Time
 Scheduled"))
 [IntroOutroAlarms]
 SayEndOfTrack = boolean(default=true)
@@ -152,6 +152,9 @@ def initConfig():
                        
SPLConfigPool.append(unlockConfig(os.path.join(SPLProfiles, profile), 
profileName=os.path.splitext(profile)[0]))
        except WindowsError:
                pass
+       # Manually set certain options (thankfully, it is cached already, so 
it'll be saved when the app module dies).
+       # To be removed in 7.1.
+       SPLConfigPool[0]["General"]["TimeHourAnnounce"] = True
        # 7.0: Store the config as a dictionary.
        # This opens up many possibilities, including config caching, loading 
specific sections only and others (the latter saves memory).
        SPLConfig = dict(SPLConfigPool[0])
@@ -425,7 +428,10 @@ def saveProfileTriggers():
 
 # Fetch the profile index with a given name.
 def getProfileIndexByName(name):
-       return [profile.name for profile in SPLConfigPool].index(name)
+       try:
+               return [profile.name for profile in SPLConfigPool].index(name)
+       except ValueError:
+               raise ValueError("The specified profile does not exist")
 
 # And:
 def getProfileByName(name):
@@ -961,7 +967,8 @@ class SPLConfigDialog(gui.SettingsDialog):
                sizer.Add(self.libScanList)
                settingsSizer.Add(sizer, border=10, flag=wx.BOTTOM)
 
-               
self.hourAnnounceCheckbox=wx.CheckBox(self,wx.NewId(),label="Include &hours 
when announcing track or playlist duration")
+               # Translators: the label for a setting in SPL add-on settings 
to announce time including hours.
+               
self.hourAnnounceCheckbox=wx.CheckBox(self,wx.NewId(),label=_("Include &hours 
when announcing track or playlist duration"))
                
self.hourAnnounceCheckbox.SetValue(SPLConfig["General"]["TimeHourAnnounce"])
                settingsSizer.Add(self.hourAnnounceCheckbox, 
border=10,flag=wx.BOTTOM)
 

diff --git a/readme.md b/readme.md
index ec44769..3a15ed7 100755
--- a/readme.md
+++ b/readme.md
@@ -177,6 +177,7 @@ If you are using Studio on a touchscreen computer running 
Windows 8 or later and
 * In add-on settings dialog, the controls used to toggle announcement of 
scheduled time, listener count, cart name and track name has been moved to a 
dedicated status announcements dialog (select status announcement button to 
open this dialog).
 * Added a new setting in add-on settings dialog to let NVDA play beep for 
different track categories when moving between tracks in playlist viewer.
 * It is no longer required to stay in the playlist viewer window in order to 
obtain time announcements such as remaining time for the track and broadcaster 
time.
+* When announcing time such as remaining time for the playing track, hours are 
also announced.
 * In encoders, pressing Control+NVDA+0 will present encoder settings dialog 
for configuring various options such as stream label, focusing to Studio when 
connected and so on.
 * In encoders, it is now possible to turn off connection progress tone 
(configurable from encoder settings dialog).

Repository URL: https://bitbucket.org/nvdaaddonteam/stationplaylist/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/StationPlaylist: josephsl: Merge branches 'master' and '7.0/blackOptimizations' into staging - commits-noreply