merging from keyboard
commit
a117da3842
|
@ -110,6 +110,7 @@ class GameBoard(BoxBoard):
|
||||||
|
|
||||||
self.gamegrid.buttonClicked.connect(self.show_number_ring)
|
self.gamegrid.buttonClicked.connect(self.show_number_ring)
|
||||||
self.numring.connect_button_signals(self.select_ring_number)
|
self.numring.connect_button_signals(self.select_ring_number)
|
||||||
|
self.numring.keyPressed.connect(self.select_ring_number)
|
||||||
|
|
||||||
self.gamegrid.setFocus(Qt.MouseFocusReason)
|
self.gamegrid.setFocus(Qt.MouseFocusReason)
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ class AnimBox(QGraphicsObject):
|
||||||
super().hoverLeaveEvent(event)
|
super().hoverLeaveEvent(event)
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
self.length = 0
|
self.toggle_anim(False)
|
||||||
self.buttonClicked.emit(self.text)
|
self.buttonClicked.emit(self.text)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,8 @@ class SudokuGrid(BaseSudokuItem):
|
||||||
self.selection_pen.setWidth(self.selection_unit)
|
self.selection_pen.setWidth(self.selection_unit)
|
||||||
self.selection_box = QRectF(0, 0, self.cell_width, self.cell_height)
|
self.selection_box = QRectF(0, 0, self.cell_width, self.cell_height)
|
||||||
|
|
||||||
|
self.setAcceptHoverEvents(True)
|
||||||
|
self.setAcceptedMouseButtons(Qt.LeftButton)
|
||||||
self.setFlag(QGraphicsItem.ItemIsFocusable, True)
|
self.setFlag(QGraphicsItem.ItemIsFocusable, True)
|
||||||
self.set_disabled(False)
|
self.set_disabled(False)
|
||||||
|
|
||||||
|
@ -193,7 +195,7 @@ class SudokuGrid(BaseSudokuItem):
|
||||||
painter.drawRect(self.selection_box)
|
painter.drawRect(self.selection_box)
|
||||||
|
|
||||||
def hoverMoveEvent(self, event):
|
def hoverMoveEvent(self, event):
|
||||||
if self.drawn:
|
if not (self.freeze and self.drawn):
|
||||||
box_w = bound_value(0, int(event.pos().x()/self.cell_width), 8)
|
box_w = bound_value(0, int(event.pos().x()/self.cell_width), 8)
|
||||||
box_h = bound_value(0, int(event.pos().y() / self.cell_height), 8)
|
box_h = bound_value(0, int(event.pos().y() / self.cell_height), 8)
|
||||||
if box_w != self.mouse_w or box_h != self.mouse_h:
|
if box_w != self.mouse_w or box_h != self.mouse_h:
|
||||||
|
@ -242,8 +244,11 @@ class SudokuGrid(BaseSudokuItem):
|
||||||
|
|
||||||
|
|
||||||
class NumberRing(BaseSudokuItem):
|
class NumberRing(BaseSudokuItem):
|
||||||
|
# TODO: Add functions to animated the ring appearing
|
||||||
|
# TODO: Adjust the positioning of each element
|
||||||
# TODO: Make it transparent when mouse is out of range
|
# TODO: Make it transparent when mouse is out of range
|
||||||
loseFocus = pyqtSignal()
|
loseFocus = pyqtSignal()
|
||||||
|
keyPressed = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
|
@ -352,6 +357,15 @@ class NumberRing(BaseSudokuItem):
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
txt = event.text()
|
||||||
|
if not txt == '' and txt in 'x123456789':
|
||||||
|
if txt == 'x':
|
||||||
|
txt = 'X'
|
||||||
|
print('keypress:', txt)
|
||||||
|
self.keyPressed.emit(txt)
|
||||||
|
self.clearFocus()
|
||||||
|
|
||||||
|
|
||||||
class PlayMenu(BaseSudokuItem):
|
class PlayMenu(BaseSudokuItem):
|
||||||
buttonClicked = pyqtSignal(str)
|
buttonClicked = pyqtSignal(str)
|
||||||
|
|
Loading…
Reference in New Issue