@ -49,8 +49,9 @@ def wrapCallDeactivateMidIn(self):
Submenu . __call__ = wrapCallDeactivateMidIn
class CombinedTickWidget ( QtWidgets . QFrame ) :
def __init__ ( self ) :
super ( ) . __init__ ( )
def __init__ ( self , mainWindow ) :
super ( ) . __init__ ( mainWindow )
self . mainWindow = mainWindow
self . setFrameShape ( QtWidgets . QFrame . Box )
self . setFrameShadow ( QtWidgets . QFrame . Sunken )
self . horizontalLayout_3 = QtWidgets . QHBoxLayout ( self )
@ -96,17 +97,28 @@ class CombinedTickWidget(QtWidgets.QFrame):
return self . upbeatSpinBox . value ( )
def callClickWidgetForUpbeat ( self ) :
dialog = TickWidget ( self , initValue = self . upbeatSpinBox . value ( ) )
dialog = TickWidget ( self . mainWindow , initValue = self . upbeatSpinBox . value ( ) )
self . upbeatSpinBox . setValue ( int ( dialog . ui . ticks . value ( ) ) )
class TickWidget ( QtWidgets . QDialog ) :
def __init__ ( self , main Window, initValue = 0 ) :
super ( ) . __init__ ( mainWindow )
def __init__ ( self , parent Window, initValue = 0 ) :
super ( ) . __init__ ( )
#Set up the user interface from Designer.
self . ui = Ui_tickWidget ( )
self . ui . setupUi ( self )
#This without init(parentWindow) will result in a nicely positioned window, that is not accesible :(
"""
self . setParent ( parentWindow )
self . setAutoFillBackground ( True )
self . setModal ( False )
self . raise_ ( )
self . activateWindow ( )
"""
#self.ui.ticks.setValue(initValue)
self . ui . ticks . setValue ( 0 ) #TODO: easier to drawLabel this way. change back to given value when drawLabel is autogenerated and does not work by keeping track anymore.
@ -116,7 +128,8 @@ class TickWidget(QtWidgets.QDialog):
self . ui . durationLabel . setText ( " " )
self . clickedSoFar = [ ] #keep track
self . clickedSoFar = [ ] #keep track. This is purely cosmetical to remember the click history.
self . multipliers = [ ] #keep track. This is purely cosmetical to remember the click history.
self . ui . D1 . clicked . connect ( lambda : self . addDuration ( api . D1 ) )
self . ui . D2 . clicked . connect ( lambda : self . addDuration ( api . D2 ) )
@ -130,6 +143,12 @@ class TickWidget(QtWidgets.QDialog):
self . ui . DB . clicked . connect ( lambda : self . addDuration ( api . DB ) )
self . ui . DL . clicked . connect ( lambda : self . addDuration ( api . DL ) )
self . ui . x2 . clicked . connect ( lambda : self . multiply ( 2 ) )
self . ui . x3 . clicked . connect ( lambda : self . multiply ( 3 ) )
self . ui . x5 . clicked . connect ( lambda : self . multiply ( 5 ) )
self . ui . x7 . clicked . connect ( lambda : self . multiply ( 7 ) )
self . ui . ticks . valueChanged . connect ( self . drawLabel )
self . exec ( ) #blocks until the dialog gets closed
@ -139,14 +158,23 @@ class TickWidget(QtWidgets.QDialog):
def reset ( self ) :
self . ui . ticks . setValue ( 0 )
self . clickedSoFar = [ ]
self . multipliers = [ ]
self . ui . durationLabel . setText ( " " )
def addDuration ( self , duration ) :
def addDuration ( self , duration : int ) :
self . clickedSoFar . append ( duration )
nowTicks = self . ui . ticks . value ( )
self . ui . ticks . setValue ( nowTicks + duration )
def multiply ( self , times : int ) :
self . multipliers . append ( " x " + str ( times ) )
nowTicks = self . ui . ticks . value ( )
self . ui . ticks . setValue ( nowTicks * times )
def drawLabel ( self ) :
""" This is purely cosmetical """
#TODO: with nice partitions of real note icons.
#Error handling. A too complex or wrong duration (off by one, not equal to a partition etc.) blocks the "OK" button. No, just gives a warning.
#backendDurationInstance = api.items.Duration.createByGuessing(self.ui.ticks.value())
@ -159,7 +187,7 @@ class TickWidget(QtWidgets.QDialog):
part = str ( times ) + " x " + symbol
text . append ( part )
self . ui . durationLabel . setText ( " + " . join ( text ) )
self . ui . durationLabel . setText ( " ( " + " + " . join ( text ) + " ) " + " " . join ( self . multipliers ) )
class SecondaryClefMenu ( Submenu ) :
@ -345,7 +373,7 @@ class BlockPropertiesEdit(Submenu):
self . layout . addRow ( translate ( " submenus " , " name " ) , self . name )
#self.minimumInTicks = QtWidgets.QSpinBox()
self . minimumInTicks = CombinedTickWidget ( )
self . minimumInTicks = CombinedTickWidget ( mainWindow )
self . minimumInTicks . setValue ( self . staticExportItem [ " minimumInTicks " ] )
self . layout . addRow ( translate ( " submenus " , " minimum in ticks " ) , self . minimumInTicks )
@ -372,7 +400,7 @@ class TempoBlockPropertiesEdit(Submenu):
self . name . selectAll ( )
self . layout . addRow ( translate ( " submenus " , " name " ) , self . name )
self . duration = CombinedTickWidget ( )
self . duration = CombinedTickWidget ( mainWindow )
self . duration . setValue ( self . staticExportItem [ " duration " ] )
self . layout . addRow ( translate ( " submenus " , " duration in ticks " ) , self . duration )
@ -514,7 +542,7 @@ class GridRhytmEdit(Submenu):
self . mainWindow = mainWindow
self . layout . insertRow ( 0 , QtWidgets . QLabel ( translate ( " submenus " , " Edit Grid " ) ) )
self . duration = CombinedTickWidget ( )
self . duration = CombinedTickWidget ( mainWindow )
self . duration . setValue ( constantsAndConfigs . gridRhythm )
self . layout . addRow ( translate ( " submenus " , " duration in ticks " ) , self . duration )