Exemplo n.º 1
0
def build_one_image_cursor(toolname: str, color: Optional[QColor] = None) -> QCursor:
    hot_x = 8
    hot_y = 8
    target_x = 0
    target_y = 0
    tool_x = 15
    tool_y = 15

    if toolname == "text":
        hot_x = 8 + 15
        hot_y = 8
        target_x = 15
        target_y = 0
        tool_x = 0
        tool_y = 15

    tool = QPixmap(":/icons/" + TOOL_ICON[toolname])
    target = QPixmap(":/icons/target")
    if color:
        target = WImage(target.toImage())
        target.change_color(color)
        target = QPixmap.fromImage(target)
    res = QPixmap(30, 30)
    res.fill(QColor("transparent"))
    p = QPainter(res)

    p.drawPixmap(QPoint(target_x, target_y), target.scaledToWidth(15))
    p.drawPixmap(QPoint(tool_x, tool_y), tool.scaledToWidth(15))

    p.end()
    # res.save("/tmp/cursor_" + toolname + ".png")
    return QCursor(res, hot_x, hot_y)