commit/StationPlaylist: josephsl: Instant profile switching (6.0-dev): Handle rename and delete operations.

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Thu, 23 Jul 2015 01:29:34 -0000

1 new commit in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/cafb6839083c/
Changeset: cafb6839083c
Branch: master
User: josephsl
Date: 2015-07-23 01:29:20+00:00
Summary: Instant profile switching (6.0-dev): Handle rename and delete
operations.

When an instant profile is set, make sure:
* When renamed, store the new name.
* When deleting, set switch profile flag to None.
Also catch a case where user presses Cancel after selecting a different
profile. Hopefully this should be robust enough to catch another case where
user clicks Cancel button after enabling or disabling instant switch.
This completes instant profile switching feature, ready for 6.0.

Affected #: 1 file

diff --git a/addon/appModules/splstudio/splconfig.py
b/addon/appModules/splstudio/splconfig.py
index 12f8eaa..05091d9 100755
--- a/addon/appModules/splstudio/splconfig.py
+++ b/addon/appModules/splstudio/splconfig.py
@@ -245,6 +245,7 @@ class SPLConfigDialog(gui.SettingsDialog):
item = self.instantSwitchButton = wx.Button(self,
label=switchLabel)
item.Bind(wx.EVT_BUTTON, self.onInstantSwitch)
self.switchProfile = SPLSwitchProfile
+ self.activeProfile = SPLActiveProfile
sizer.Add(item)
if SPLConfigPool.index(SPLConfig) == 0:
self.renameButton.Disable()
@@ -409,7 +410,7 @@ class SPLConfigDialog(gui.SettingsDialog):
SPLConfig["SayScheduledFor"] = self.scheduledForCheckbox.Value
SPLConfig["SayListenerCount"] = self.listenerCountCheckbox.Value
SPLConfig["SayPlayingCartName"] = self.cartNameCheckbox.Value
- SPLActiveProfile = SPLConfigPool[selectedProfile].name
+ SPLActiveProfile = SPLConfig.name
SPLSwitchProfile = self.switchProfile
# Without nullifying prev profile while switch profile is
undefined, NVDA will assume it can switch back to that profile when it can't.
# It also causes NVDA to display wrong label for switch button.
@@ -419,7 +420,9 @@ class SPLConfigDialog(gui.SettingsDialog):
super(SPLConfigDialog, self).onOk(evt)

def onCancel(self, evt):
- global _configDialogOpened
+ global _configDialogOpened, SPLActiveProfile, SPLSwitchProfile
+ SPLActiveProfile = self.activeProfile
+ SPLSwitchProfile = self.switchProfile
_configDialogOpened = False
super(SPLConfigDialog, self).onCancel(evt)

@@ -502,6 +505,10 @@ class SPLConfigDialog(gui.SettingsDialog):
oldNamePath = oldName + ".ini"
oldProfile = os.path.join(SPLProfiles, oldNamePath)
os.rename(oldProfile, newProfile)
+ if self.switchProfile == oldName:
+ self.switchProfile = newName
+ if self.activeProfile == oldName:
+ self.activeProfile = newName
SPLConfigPool[index].name = newName
SPLConfigPool[index].filename = newProfile
self.profiles.SetString(index, newName)
@@ -518,7 +525,7 @@ class SPLConfigDialog(gui.SettingsDialog):
wx.YES | wx.NO | wx.ICON_QUESTION, self
) == wx.NO:
return
- global SPLConfigPool
+ global SPLConfigPool, SPLSwitchProfile, SPLPrevProfile
name = SPLConfigPool[index].name
path = SPLConfigPool[index].filename
del SPLConfigPool[index]
@@ -526,8 +533,12 @@ class SPLConfigDialog(gui.SettingsDialog):
os.remove(path)
except WindowsError:
pass
+ if name == self.switchProfile:
+ self.switchProfile = None
+ SPLPrevProfile = None
self.profiles.Delete(index)
self.profiles.SetString(0, SPLConfigPool[0].name)
+ self.activeProfile = SPLConfigPool[0].name
self.profiles.Selection = 0
self.onProfileSelection(None)
self.profiles.SetFocus()

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: Instant profile switching (6.0-dev): Handle rename and delete operations. - commits-noreply