def show_help_browser(self, path=None): """ Displays the help browser somewhere on screen. Can set a special page if needed. """ # we sometimes wire signals that send parameters for url (mouseevents for example) which we do not like if isinstance(path, str): url = tools.local_url(path) self.help_browser_widget.load(url) self.help_dialog.show()
def load_soundtrack_playlist(): """ Loads the play list of the soundtracks and replaces the file name with the full path. A playlist is a list where each entry is a list of two strings: filepath, title """ global soundtrack_playlist # create playlist soundtrack_playlist = QtMultimedia.QMediaPlaylist() soundtrack_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) # read information file data = utils.read_as_yaml(constants.SOUNDTRACK_INFO_FILE) # add the soundtrack folder to each file name for entry in data: file = constants.extend(constants.SOUNDTRACK_FOLDER, entry[0]) url = tools.local_url(file) media = QtMultimedia.QMediaContent(url) soundtrack_playlist.addMedia(media)
def __init__(self): """ Create the main window, the help browser dialog, the audio player, ... """ # main window self.main_window = ClientMainWindowWidget() # help browser self.help_browser_widget = qt_graphics.BrowserWidget(tools.load_ui_icon) self.help_browser_widget.home_url = tools.local_url(constants.DOCUMENTATION_INDEX_FILE) self.help_browser_widget.home() self.help_dialog = graphics.GameDialog(self.main_window, self.help_browser_widget, title='Help') self.help_dialog.setFixedSize(QtCore.QSize(800, 600)) # move to lower right border, so that overlap with other windows is not that strong self.help_dialog.move(self.main_window.x() + self.main_window.width() - 800, self.main_window.y() + self.main_window.height() - 600) # add help browser keyboard shortcut action = QtWidgets.QAction(self.main_window) action.setShortcut(QtGui.QKeySequence('F1')) action.triggered.connect(self.show_help_browser) self.main_window.addAction(action) # add server monitor keyboard shortcut action = QtWidgets.QAction(self.main_window) action.setShortcut(QtGui.QKeySequence('F2')) action.triggered.connect(self.show_server_monitor) self.main_window.addAction(action) # for the notifications self.pending_notifications = [] self.notification_position_constraint = qt_graphics.RelativeLayoutConstraint().center_horizontal().south(20) self.notification = None # after the player starts, the main window is not active anymore # set it active again or it doesn't get keyboard focus self.main_window.activateWindow()