def __init__(self):
self._messages = []
- icon = QtGui.QIcon.fromTheme("gtk-dialog-error")
- self._severityIcon = icon.pixmap(32, 32)
+ errorIcon = QtGui.QIcon.fromTheme("app_install_error")
+ if errorIcon.isNull():
+ errorIcon = QtGui.QIcon.fromTheme("gtk-dialog-error")
+ self._severityIcon = errorIcon.pixmap(32, 32)
self._severityLabel = QtGui.QLabel()
self._severityLabel.setPixmap(self._severityIcon)
self._message = QtGui.QLabel()
self._message.setText("Boo")
- icon = QtGui.QIcon.fromTheme("gtk-close")
- self._closeLabel = QtGui.QPushButton(icon, "")
+ closeIcon = QtGui.QIcon.fromTheme("general_close")
+ if closeIcon.isNull():
+ closeIcon = QtGui.QIcon.fromTheme("gtk-close")
+ self._closeLabel = QtGui.QPushButton(closeIcon, "")
self._closeLabel.clicked.connect(self._on_close)
self._controlLayout = QtGui.QHBoxLayout()
maeqt.set_stackable(self._window, True)
self._window.setWindowTitle("%s" % constants.__pretty_app_name__)
self._window.setCentralWidget(centralWidget)
- self._window.destroyed.connect(self._on_close_window)
+ self._window.destroyed.connect(self._on_window_closed)
self._copyItemAction = QtGui.QAction(None)
self._copyItemAction.setText("Copy")
self._closeWindowAction.setShortcut(QtGui.QKeySequence("CTRL+w"))
self._closeWindowAction.triggered.connect(self._on_close_window)
- if IS_MAEMO:
- #fileMenu = self._window.menuBar().addMenu("&File")
-
- #viewMenu = self._window.menuBar().addMenu("&View")
-
- self._window.addAction(self._copyItemAction)
- self._window.addAction(self._pasteItemAction)
- self._window.addAction(self._closeWindowAction)
- self._window.addAction(self._app.quitAction)
- self._window.addAction(self._app.fullscreenAction)
- else:
- fileMenu = self._window.menuBar().addMenu("&Units")
- fileMenu.addAction(self._closeWindowAction)
- fileMenu.addAction(self._app.quitAction)
-
- viewMenu = self._window.menuBar().addMenu("&View")
- viewMenu.addAction(self._app.fullscreenAction)
+ self._window.addAction(self._copyItemAction)
+ self._window.addAction(self._pasteItemAction)
+ self._window.addAction(self._closeWindowAction)
+ self._window.addAction(self._app.quitAction)
+ self._window.addAction(self._app.fullscreenAction)
self._window.addAction(self._app.logAction)
self.set_fullscreen(self._app.fullscreenAction.isChecked())
self._window.show()
- self._set_plugin_kb(0)
@property
def window(self):
else:
self._keyboardTabs.addTab(pluginKeyboard.toplevel, icon, "")
- def _set_plugin_kb(self, pluginIndex):
- plugin = self._activeKeyboards[pluginIndex]
-
- # @todo Switch the keyboard tab
- pluginKeyboard = plugin["pluginKeyboard"]
-
def _load_history(self):
serialized = []
try:
self._history.clear()
@misc_utils.log_exception(_moduleLogger)
- def _on_close_window(self, checked = True):
+ def _on_window_closed(self, checked = True):
self._save_history()
+ @misc_utils.log_exception(_moduleLogger)
+ def _on_close_window(self, checked = True):
+ self.close()
+
def run():
app = QtGui.QApplication([])
class PieFiling(object):
- INNER_RADIUS_DEFAULT = 32
- OUTER_RADIUS_DEFAULT = 128
+ INNER_RADIUS_DEFAULT = 64
+ OUTER_RADIUS_DEFAULT = 192
SELECTION_CENTER = -1
SELECTION_NONE = -2
class PieArtist(object):
- ICON_SIZE_DEFAULT = 32
+ ICON_SIZE_DEFAULT = 48
+
+ SHAPE_CIRCLE = "circle"
+ SHAPE_SQUARE = "square"
+ DEFAULT_SHAPE = SHAPE_SQUARE
def __init__(self, filing):
self._filing = filing
painter = QtGui.QPainter(mask)
painter.setPen(QtCore.Qt.color1)
painter.setBrush(QtCore.Qt.color1)
- painter.drawEllipse(mask.rect().adjusted(0, 0, -1, -1))
+ if self.DEFAULT_SHAPE == self.SHAPE_SQUARE:
+ painter.drawRect(mask.rect())
+ elif self.DEFAULT_SHAPE == self.SHAPE_CIRCLE:
+ painter.drawEllipse(mask.rect().adjusted(0, 0, -1, -1))
+ else:
+ raise NotImplementedError(self.DEFAULT_SHAPE)
def _paint_slice_background(self, painter, adjustmentRect, i, selectionIndex):
+ if self.DEFAULT_SHAPE == self.SHAPE_SQUARE:
+ currentWidth = adjustmentRect.width()
+ newWidth = math.sqrt(2) * currentWidth
+ dx = (newWidth - currentWidth) / 2
+ adjustmentRect = adjustmentRect.adjusted(-dx, -dx, dx, dx)
+ elif self.DEFAULT_SHAPE == self.SHAPE_CIRCLE:
+ pass
+ else:
+ raise NotImplementedError(self.DEFAULT_SHAPE)
+
if i == selectionIndex and self._filing[i].isEnabled():
painter.setBrush(self.palette.highlight())
else:
painter.drawText(leftX, topY, text)
def _paint_center_background(self, painter, adjustmentRect, selectionIndex):
- dark = self.palette.dark().color()
+ dark = self.palette.mid().color()
light = self.palette.light().color()
if selectionIndex == PieFiling.SELECTION_CENTER and self._filing.center().isEnabled():
background = self.palette.highlight().color()
painter.setBrush(QtCore.Qt.NoBrush)
painter.drawEllipse(innerRect)
- painter.setPen(QtGui.QPen(dark, 1))
- painter.setBrush(QtCore.Qt.NoBrush)
- painter.drawEllipse(adjustmentRect)
-
- r = QtCore.QRect(innerRect)
- innerCenter = r.center()
- innerRect.setLeft(innerCenter.x() + ((r.left() - innerCenter.x()) / 3) * 1)
- innerRect.setRight(innerCenter.x() + ((r.right() - innerCenter.x()) / 3) * 1)
- innerRect.setTop(innerCenter.y() + ((r.top() - innerCenter.y()) / 3) * 1)
- innerRect.setBottom(innerCenter.y() + ((r.bottom() - innerCenter.y()) / 3) * 1)
+ if self.DEFAULT_SHAPE == self.SHAPE_SQUARE:
+ pass
+ elif self.DEFAULT_SHAPE == self.SHAPE_CIRCLE:
+ painter.setPen(QtGui.QPen(dark, 1))
+ painter.setBrush(QtCore.Qt.NoBrush)
+ painter.drawEllipse(adjustmentRect)
+ else:
+ raise NotImplementedError(self.DEFAULT_SHAPE)
def _paint_center_foreground(self, painter, selectionIndex):
centerPos = self._canvas.rect().center()
self._buttonFiling = PieFiling()
self._buttonFiling.set_center(buttonSlice)
- # @todo Figure out how to make the button auto-fill to content
self._buttonFiling.setOuterRadius(self.BUTTON_RADIUS)
self._buttonArtist = PieArtist(self._buttonFiling)
self._poppedUp = False
def setButtonRadius(self, radius):
self._buttonFiling.setOuterRadius(radius)
+ self._buttonArtist.show(self.palette())
- def sizeHint(self):
- return self._buttonArtist.pieSize()
+ def minimumSizeHint(self):
+ return self._buttonArtist.centerSize()
@misc_utils.log_exception(_moduleLogger)
def mousePressEvent(self, mouseEvent):
self._update_selection(lastMousePos)
else:
# Relative
- self._update_selection(self._cachedCenterPosition + (lastMousePos - self._mousePosition))
+ self._update_selection(
+ self._cachedCenterPosition + (lastMousePos - self._mousePosition),
+ ignoreOuter = True,
+ )
if lastSelection != self._selectionIndex:
self.highlighted.emit(self._selectionIndex)
self._update_selection(lastMousePos)
else:
# Relative
- self._update_selection(self._cachedCenterPosition + (lastMousePos - self._mousePosition))
+ self._update_selection(
+ self._cachedCenterPosition + (lastMousePos - self._mousePosition),
+ ignoreOuter = True,
+ )
self._mousePosition = None
self._activate_at(self._selectionIndex)
QtGui.QWidget.keyPressEvent(self, keyEvent)
@misc_utils.log_exception(_moduleLogger)
+ def resizeEvent(self, resizeEvent):
+ self.setButtonRadius(min(resizeEvent.size().width(), resizeEvent.size().height()) / 2 - 1)
+ QtGui.QWidget.resizeEvent(self, resizeEvent)
+
+ @misc_utils.log_exception(_moduleLogger)
def showEvent(self, showEvent):
self._buttonArtist.show(self.palette())
self._cachedCenterPosition = self.rect().center()
@misc_utils.log_exception(_moduleLogger)
def paintEvent(self, paintEvent):
+ self.setButtonRadius(min(self.rect().width(), self.rect().height()) / 2 - 1)
if self._poppedUp:
canvas = self._buttonArtist.paint(PieFiling.SELECTION_CENTER)
else:
def _select_at(self, index):
self._selectionIndex = index
- def _update_selection(self, lastMousePos):
+ def _update_selection(self, lastMousePos, ignoreOuter = False):
radius = _radius_at(self._cachedCenterPosition, lastMousePos)
if radius < self._filing.innerRadius():
self._select_at(PieFiling.SELECTION_CENTER)
- elif radius <= self._filing.outerRadius():
+ elif radius <= self._filing.outerRadius() or ignoreOuter:
self._select_at(self.indexAt(lastMousePos))
else:
self._select_at(PieFiling.SELECTION_NONE)