don't play audio twice when changing templates (#472)

- setting current tab index triggered the function, so we don't need to call
  it manually
- no need to set index after adding card either, as it defaults to the most
  recently added tab
This commit is contained in:
Damien Elmes 2013-04-11 15:07:50 +09:00
parent 65c9830bac
commit 5e8f45f7e5

View File

@ -52,7 +52,6 @@ class CardLayout(QDialog):
self.redrawing = True self.redrawing = True
self.updateTabs() self.updateTabs()
self.redrawing = False self.redrawing = False
self.selectCard(self.ord)
def setupTabs(self): def setupTabs(self):
c = self.connect c = self.connect
@ -66,7 +65,7 @@ class CardLayout(QDialog):
add.setToolTip(_("Add new card")) add.setToolTip(_("Add new card"))
c(add, SIGNAL("clicked()"), self.onAddCard) c(add, SIGNAL("clicked()"), self.onAddCard)
self.tabs.setCornerWidget(add) self.tabs.setCornerWidget(add)
c(self.tabs, SIGNAL("currentChanged(int)"), self.selectCard) c(self.tabs, SIGNAL("currentChanged(int)"), self.onCardSelected)
c(self.tabs, SIGNAL("tabCloseRequested(int)"), self.onRemoveTab) c(self.tabs, SIGNAL("tabCloseRequested(int)"), self.onRemoveTab)
def updateTabs(self): def updateTabs(self):
@ -176,6 +175,9 @@ Please create a new card type first."""))
########################################################################## ##########################################################################
def selectCard(self, idx): def selectCard(self, idx):
self.tabs.setCurrentIndex(idx)
def onCardSelected(self, idx):
if self.redrawing: if self.redrawing:
return return
self.ord = idx self.ord = idx