def setupUi(self): """create all other widgets we could make the scene view the central widget but I did not figure out how to correctly draw the background with QGraphicsView/QGraphicsScene. QGraphicsView.drawBackground always wants a pixmap for a huge rect like 4000x3000 where my screen only has 1920x1200""" # pylint: disable=too-many-statements GameScene.setupUi(self) self.setObjectName("PlayingField") self.discardBoard = DiscardBoard() self.addItem(self.discardBoard) self.adjustSceneView()
def setupUi(self): """create all other widgets we could make the scene view the central widget but I did not figure out how to correctly draw the background with QGraphicsView/QGraphicsScene. QGraphicsView.drawBackground always wants a pixmap for a huge rect like 4000x3000 where my screen only has 1920x1200""" # pylint: disable=R0915 self.setObjectName("MainWindow") centralWidget = QWidget() scene = MJScene() self.centralScene = scene self.centralView = FittingView() layout = QGridLayout(centralWidget) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.centralView) self.tileset = None # just for pylint self.background = None # just for pylint self.tilesetName = Preferences.tilesetName self.windTileset = Tileset(Preferences.windTilesetName) self.discardBoard = DiscardBoard() self.discardBoard.setVisible(False) scene.addItem(self.discardBoard) self.selectorBoard = SelectorBoard() self.selectorBoard.setVisible(False) scene.addItem(self.selectorBoard) self.setCentralWidget(centralWidget) self.centralView.setScene(scene) self.centralView.setFocusPolicy(Qt.StrongFocus) self.adjustView() self.actionScoreGame = self.__kajonggAction("scoreGame", "draw-freehand", self.scoreGame, Qt.Key_C) self.actionPlayGame = self.__kajonggAction("play", "arrow-right", self.playGame, Qt.Key_N) self.actionAbortGame = self.__kajonggAction("abort", "dialog-close", self.abortAction, Qt.Key_W) self.actionAbortGame.setEnabled(False) self.actionQuit = self.__kajonggAction("quit", "application-exit", self.close, Qt.Key_Q) self.actionPlayers = self.__kajonggAction("players", "im-user", self.slotPlayers) self.actionRulesets = self.__kajonggAction("rulesets", "games-kajongg-law", self.slotRulesets) self.actionChat = self.__kajonggToggleAction("chat", "call-start", shortcut=Qt.Key_H, actionData=ChatWindow) game = self.game self.actionChat.setEnabled( bool(game) and bool(game.client) and not game.client.hasLocalServer()) self.actionChat.setChecked( bool(game) and bool(game.client) and bool(game.client.table.chatWindow)) self.actionScoring = self.__kajonggToggleAction( "scoring", "draw-freehand", shortcut=Qt.Key_S, actionData=ScoringDialog) self.actionScoring.setEnabled(False) self.actionAngle = self.__kajonggAction("angle", "object-rotate-left", self.changeAngle, Qt.Key_G) self.actionAngle.setEnabled(False) self.actionFullscreen = KToggleFullScreenAction( self.actionCollection()) self.actionFullscreen.setShortcut(Qt.CTRL + Qt.Key_F) self.actionFullscreen.setShortcutContext(Qt.ApplicationShortcut) self.actionFullscreen.setWindow(self) self.actionCollection().addAction("fullscreen", self.actionFullscreen) self.actionFullscreen.toggled.connect(self.fullScreen) self.actionScoreTable = self.__kajonggToggleAction( "scoreTable", "format-list-ordered", Qt.Key_T, actionData=ScoreTable) self.actionExplain = self.__kajonggToggleAction( "explain", "applications-education", Qt.Key_E, actionData=ExplainView) self.actionAutoPlay = self.__kajonggAction("demoMode", "arrow-right-double", None, Qt.Key_D) self.actionAutoPlay.setCheckable(True) self.actionAutoPlay.toggled.connect(self.__toggleDemoMode) self.actionAutoPlay.setChecked(Internal.autoPlay) QMetaObject.connectSlotsByName(self)