clearAction.setText("Clear")
clearAction.triggered.connect(self._on_clear_text)
clearPieItem = qtpie.QActionPieItem(clearAction)
+ backSlices = [
+ qtpie.PieFiling.NULL_CENTER,
+ clearPieItem,
+ qtpie.PieFiling.NULL_CENTER,
+ qtpie.PieFiling.NULL_CENTER,
+ ]
self._back = qtpie.QPieButton(backPieItem)
self._back.set_center(backPieItem)
- self._back.insertItem(qtpie.PieFiling.NULL_CENTER)
- self._back.insertItem(clearPieItem)
- self._back.insertItem(qtpie.PieFiling.NULL_CENTER)
- self._back.insertItem(qtpie.PieFiling.NULL_CENTER)
+ for slice in backSlices:
+ self._back.insertItem(slice)
self._entryLayout = QtGui.QHBoxLayout()
self._entryLayout.addWidget(self._plus, 0, QtCore.Qt.AlignCenter)
def _generate_key_button(self, center, letters):
centerPieItem = self._generate_button_slice(center)
+ pieItems = [
+ pieItem
+ for pieItem in self._generate_button_slices(letters)
+ ]
+
button = qtpie.QPieButton(centerPieItem)
button.set_center(centerPieItem)
+ for item in pieItems:
+ button.insertItem(item)
+ return button
+
+ def _generate_button_slices(self, letters):
if len(letters) == 0:
for i in xrange(8):
pieItem = qtpie.PieFiling.NULL_CENTER
- button.insertItem(pieItem)
+ yield pieItem
elif len(letters) in [3, 4]:
for i in xrange(6 - len(letters)):
pieItem = qtpie.PieFiling.NULL_CENTER
- button.insertItem(pieItem)
+ yield pieItem
for letter in letters:
pieItem = self._generate_button_slice(letter)
- button.insertItem(pieItem)
+ yield pieItem
for i in xrange(2):
pieItem = qtpie.PieFiling.NULL_CENTER
- button.insertItem(pieItem)
+ yield pieItem
else:
raise NotImplementedError("Cannot handle %r" % letters)
- return button
def _generate_button_slice(self, letter):
action = QtGui.QAction(None)
BUTTON_RADIUS = 24
DELAY = 250
- def __init__(self, buttonSlice, parent = None):
+ def __init__(self, buttonSlice, parent = None, buttonSlices = None):
# @bug Artifacts on Maemo 5 due to window 3D effects, find way to disable them for just these?
# @bug The pie's are being pushed back on screen on Maemo, leading to coordinate issues
QtGui.QWidget.__init__(self, parent)
self._buttonFiling = PieFiling()
self._buttonFiling.set_center(buttonSlice)
+ if buttonSlices is not None:
+ for slice in buttonSlices:
+ self._buttonFiling.insertItem(slice)
self._buttonFiling.setOuterRadius(self.BUTTON_RADIUS)
self._buttonArtist = PieArtist(self._buttonFiling)
self._poppedUp = False
def setButtonRadius(self, radius):
self._buttonFiling.setOuterRadius(radius)
+ self._buttonFiling.setInnerRadius(radius / 2)
self._buttonArtist.show(self.palette())
def sizeHint(self):