Add Shift for Scribbling mode
parent
e89c727e11
commit
f1a4337d64
|
@ -131,7 +131,7 @@ class GameBoard(BoxBoard):
|
||||||
if val == 'X':
|
if val == 'X':
|
||||||
val = 0
|
val = 0
|
||||||
self.gamegrid.replace_cell_number(int(val))
|
self.gamegrid.replace_cell_number(int(val))
|
||||||
self.game_refocus()
|
#self.game_refocus()
|
||||||
|
|
||||||
def game_refocus(self):
|
def game_refocus(self):
|
||||||
self.gamegrid.set_disabled(False)
|
self.gamegrid.set_disabled(False)
|
||||||
|
|
|
@ -82,6 +82,7 @@ class NumberPainter(BaseSudokuItem):
|
||||||
painter.drawText(QRectF(num_x, num_y, self.parent.cell_width, self.parent.cell_height),
|
painter.drawText(QRectF(num_x, num_y, self.parent.cell_width, self.parent.cell_height),
|
||||||
Qt.AlignCenter, scrib)
|
Qt.AlignCenter, scrib)
|
||||||
|
|
||||||
|
|
||||||
class SudokuGrid(BaseSudokuItem):
|
class SudokuGrid(BaseSudokuItem):
|
||||||
# TODO: Add functions to animated the grid lines
|
# TODO: Add functions to animated the grid lines
|
||||||
buttonClicked = pyqtSignal(float, float)
|
buttonClicked = pyqtSignal(float, float)
|
||||||
|
@ -241,8 +242,6 @@ 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()
|
||||||
|
|
||||||
|
@ -276,6 +275,7 @@ class NumberRing(BaseSudokuItem):
|
||||||
self.setFlag(QGraphicsItem.ItemIsFocusable, True)
|
self.setFlag(QGraphicsItem.ItemIsFocusable, True)
|
||||||
|
|
||||||
self.freeze_buttons(True)
|
self.freeze_buttons(True)
|
||||||
|
self.scribbling = False
|
||||||
|
|
||||||
def finish_animation(self):
|
def finish_animation(self):
|
||||||
if self.radius == 0:
|
if self.radius == 0:
|
||||||
|
@ -307,7 +307,6 @@ class NumberRing(BaseSudokuItem):
|
||||||
for btn in self.cell_buttons:
|
for btn in self.cell_buttons:
|
||||||
btn.buttonClicked.connect(func)
|
btn.buttonClicked.connect(func)
|
||||||
btn.buttonClicked.connect(self.close_menu)
|
btn.buttonClicked.connect(self.close_menu)
|
||||||
print('Buttons Connected')
|
|
||||||
|
|
||||||
def freeze_buttons(self, freeze):
|
def freeze_buttons(self, freeze):
|
||||||
for btn in self.cell_buttons:
|
for btn in self.cell_buttons:
|
||||||
|
@ -315,12 +314,24 @@ class NumberRing(BaseSudokuItem):
|
||||||
|
|
||||||
def focusOutEvent(self, event):
|
def focusOutEvent(self, event):
|
||||||
if not any(btn.isUnderMouse() for btn in self.cell_buttons):
|
if not any(btn.isUnderMouse() for btn in self.cell_buttons):
|
||||||
self.close_menu()
|
self.toggle_anim(False)
|
||||||
else:
|
else:
|
||||||
self.setFocus()
|
self.setFocus()
|
||||||
|
|
||||||
def close_menu(self):
|
def close_menu(self):
|
||||||
self.toggle_anim(False)
|
if not self.scribbling:
|
||||||
|
self.toggle_anim(False)
|
||||||
|
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
if (Qt.ShiftModifier & event.modifiers()) and not self.scribbling:
|
||||||
|
|
||||||
|
print('Scribbling On')
|
||||||
|
self.scribbling = True
|
||||||
|
|
||||||
|
def keyReleaseEvent(self, event):
|
||||||
|
if not (Qt.ShiftModifier & event.modifiers()) and self.scribbling:
|
||||||
|
print('Scribbling Off')
|
||||||
|
self.scribbling = False
|
||||||
|
|
||||||
# Defining the length to be drawn as a pyqtProperty
|
# Defining the length to be drawn as a pyqtProperty
|
||||||
@pyqtProperty(float)
|
@pyqtProperty(float)
|
||||||
|
|
Loading…
Reference in New Issue