Commit 5e01f656 authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald
Browse files

pylint: rename Board.hasFocus to Board.hasLogicalFocus

because it should not override QGraphicsItem.hasFocus
parent 86d5a9c9
......@@ -251,7 +251,7 @@ class Board(QGraphicsRectItem, StrMixin):
if self._focusTile and self._focusTile.tile in Debug.focusable:
logDebug('%s: new focus uiTile %s from %s' % (
self.name, self._focusTile.tile if self._focusTile else 'None', stack('')[-1]))
if self.hasFocus:
if self.hasLogicalFocus:
self.scene().focusBoard = self
def setEnabled(self, enabled):
......@@ -268,14 +268,17 @@ class Board(QGraphicsRectItem, StrMixin):
return sorted((x for x in self.uiTiles if x.focusable), key=lambda x: x.sortKey(sortDir))
@property
def hasFocus(self):
def hasLogicalFocus(self):
"""defines if this board should show a focusRect
if another board has focus, setting this to False does
not change scene.focusBoard"""
not change scene.focusBoard
Up to May 2021, this was called hasFocus, overriding QGraphicsItem.hasFocus
but pylint did not like that."""
return self.scene() and self.scene().focusBoard == self and self._focusTile
@hasFocus.setter
def hasFocus(self, value):
@hasLogicalFocus.setter
def hasLogicalFocus(self, value):
"""set focus on this board"""
if isAlive(self):
scene = self.scene()
......@@ -517,7 +520,7 @@ class Board(QGraphicsRectItem, StrMixin):
self.placeTile(uiTile)
uiTile.update()
self.computeRect()
if self.hasFocus:
if self.hasLogicalFocus:
self.scene().focusBoard = self
def focusRectWidth(self): # pylint: disable=no-self-use
......@@ -669,7 +672,7 @@ class SelectorBoard(CourtBoard):
self.__placeAvailable(myTile)
myTile.focusable = True
senderHand.deselect(uiMeld)
(senderHand if senderHand.uiTiles else self).hasFocus = True
(senderHand if senderHand.uiTiles else self).hasLogicalFocus = True
self._noPen()
animate()
......@@ -823,7 +826,7 @@ class FittingView(QGraphicsView):
uiTile = board.mapMouseTile(tiles[0])
if uiTile.focusable:
board.focusTile = uiTile
board.hasFocus = True
board.hasLogicalFocus = True
if hasattr(Internal.scene, 'clientDialog'):
if Internal.scene.clientDialog:
Internal.scene.clientDialog.buttons[0].setFocus()
......@@ -941,7 +944,7 @@ class DiscardBoard(CourtBoard):
uiTile.dark = False
uiTile.focusable = False
self.focusTile = uiTile
self.hasFocus = True
self.hasLogicalFocus = True
self.lastDiscarded = uiTile
def dropEvent(self, event):
......
......@@ -342,7 +342,7 @@ class PlayingHandBoard(HandBoard):
if focusCandidates:
self.focusTile = focusCandidates[0]
Internal.scene.handSelectorChanged(self)
self.hasFocus = bool(adding)
self.hasLogicalFocus = bool(adding)
@Board.focusTile.setter
def focusTile(self, uiTile): # pylint: disable=arguments-differ
......
......@@ -84,7 +84,7 @@ class FocusRect(QGraphicsRectItem, StrMixin):
self.setPos(board.focusTile.pos)
game = Internal.scene.game
self.setVisible(board.isVisible() and bool(board.focusTile)
and board.isEnabled() and board.hasFocus and bool(game) and not game.autoPlay)
and board.isEnabled() and board.hasLogicalFocus and bool(game) and not game.autoPlay)
def __str__(self):
......@@ -455,7 +455,7 @@ class ScoringScene(GameScene):
def __init__(self, parent=None):
self.scoringDialog = None
super().__init__(parent)
self.selectorBoard.hasFocus = True
self.selectorBoard.hasLogicalFocus = True
@GameScene.game.setter
def game(self, value): # pylint: disable=arguments-differ
......@@ -539,7 +539,7 @@ class ScoringScene(GameScene):
currIdx = 0
while tabItems[currIdx] != currentBoard and currIdx < len(tabItems) - 2:
currIdx += 1
tabItems[currIdx + 1].hasFocus = True
tabItems[currIdx + 1].hasLogicalFocus = True
return True
return False
......
......@@ -244,7 +244,7 @@ class ScoringHandBoard(HandBoard):
self.uiMelds.append(uiMeld)
self.player.addMeld(uiMeld.meld)
self.sync()
self.hasFocus = senderBoard == self or not senderBoard.uiTiles
self.hasLogicalFocus = senderBoard == self or not senderBoard.uiTiles
self.checkTiles()
senderBoard.autoSelectTile()
senderBoard.checkTiles()
......@@ -514,7 +514,7 @@ class ScoringGame(Game):
if not self.finished():
selector = Internal.scene.selectorBoard
selector.refill()
selector.hasFocus = True
selector.hasLogicalFocus = True
self.wall.build(shuffleFirst=False)
def nextScoringHand(self):
......
......@@ -122,7 +122,7 @@ class VisiblePlayingPlayer(VisiblePlayer, PlayingPlayer):
def getsFocus(self, unusedResults=None):
"""give this player focus on his handBoard"""
self.handBoard.setEnabled(True)
self.handBoard.hasFocus = True
self.handBoard.hasLogicalFocus = True
def popupMsg(self, msg):
"""shows a yellow message from player"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment