Due to JS lambdas menuItem is being captured by reference, and as such
the call to menuItem.checked returns the checked state of the last item
in the for loop. Instead of adding to the capture this patch uses the
supplied boolean from the QMenuItem::toggled signal.
Also unlike Array.concat Array.splice alters the current array, we don't
want to create a new var.