class MainWindow(MainWindowCommon, QMainWindow): def __init__(self, parent): QMainWindow.__init__(self, parent, 'PyQt Dosbox Frontend') # setup app pointer self.app = qApp self.myconfig = self.app.myconfig self.resize(*self.myconfig.get_xy('mainwindow', 'mainwindow_size')) # initialize game data self.initActions() self.initMenus() def initActions(self): self.quitAction = QuitAction(self.close, self) self.newGameAction = NewGame(self.slotNewGame, self) self.launchDosboxAction = LaunchDosbox(self.slotLaunchDosbox, self) self.flatViewAction = FlatView(self.slotFlatView, self) self.treeViewAction = TreeView(self.slotTreeView, self) self.nameViewAction = NameView(self.slotNameView, self) self.titleViewAction = TitleView(self.slotTitleView, self) self.prepareAllGamesAction = PrepareAllGames(self.slotPrepareAllGames, self) self.cleanAllGamesAction = CleanAllGames(self.slotCleanAllGames, self) self.archiveAllGamesAction = ArchiveAllGames(self.slotArchiveAllGames, self) self.filterAllGamesAction = FilterAllGames(self.slotFilterAllGames, self) self.filterAvailableGamesAction = \ FilterAvailableGames(self.slotFilterAvailableGames, self) self.filterUnavailableGamesAction = \ FilterUnavailableGames(self.slotFilterUnavailableGames, self) def initMenus(self): mainmenu = QPopupMenu(self) self.newGameAction.addTo(mainmenu) self.launchDosboxAction.addTo(mainmenu) mainmenu.insertSeparator() self.prepareAllGamesAction.addTo(mainmenu) self.cleanAllGamesAction.addTo(mainmenu) self.archiveAllGamesAction.addTo(mainmenu) self.quitAction.addTo(mainmenu) optionmenu = QPopupMenu(self) self.flatViewAction.addTo(optionmenu) self.treeViewAction.addTo(optionmenu) self.nameViewAction.addTo(optionmenu) self.titleViewAction.addTo(optionmenu) optionmenu.insertSeparator() self.filterAllGamesAction.addTo(optionmenu) self.filterAvailableGamesAction.addTo(optionmenu) self.filterUnavailableGamesAction.addTo(optionmenu) menubar = self.menuBar() menubar.insertItem('&Main', mainmenu) menubar.insertItem('&Options', optionmenu)
class MainWindow(MainWindowCommon, QMainWindow): def __init__(self, parent): QMainWindow.__init__(self, parent, 'PyQt Dosbox Frontend') # setup app pointer self.app = qApp self._init_common() self.splitView = QSplitter(self, 'splitView') self.listView = QListView(self.splitView, 'games_view') self.initlistView() x, y = self.config.get_xy('mainwindow', 'mainwindow_size') self.splitView.setSizes([int(.1*x), int(.9*x)]) self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) self.textView = InfoBrowser(self.splitView) self.setCentralWidget(self.splitView) def initActions(self): self.quitAction = QuitAction(self.close, self) self.newGameAction = NewGame(self.slotNewGame, self) self.launchDosboxAction = LaunchDosbox(self.slotLaunchDosbox, self) self.flatViewAction = FlatView(self.slotFlatView, self) self.treeViewAction = TreeView(self.slotTreeView, self) self.nameViewAction = NameView(self.slotNameView, self) self.titleViewAction = TitleView(self.slotTitleView, self) self.prepareAllGamesAction = PrepareAllGames(self.slotPrepareAllGames, self) self.cleanAllGamesAction = CleanAllGames(self.slotCleanAllGames, self) self.archiveAllGamesAction = ArchiveAllGames(self.slotArchiveAllGames, self) self.filterAllGamesAction = FilterAllGames(self.slotFilterAllGames, self) self.filterAvailableGamesAction = \ FilterAvailableGames(self.slotFilterAvailableGames, self) self.filterUnavailableGamesAction = \ FilterUnavailableGames(self.slotFilterUnavailableGames, self) def initMenus(self): mainmenu = QPopupMenu(self) self.newGameAction.addTo(mainmenu) self.launchDosboxAction.addTo(mainmenu) mainmenu.insertSeparator() self.prepareAllGamesAction.addTo(mainmenu) self.cleanAllGamesAction.addTo(mainmenu) self.archiveAllGamesAction.addTo(mainmenu) self.quitAction.addTo(mainmenu) optionmenu = QPopupMenu(self) self.flatViewAction.addTo(optionmenu) self.treeViewAction.addTo(optionmenu) self.nameViewAction.addTo(optionmenu) self.titleViewAction.addTo(optionmenu) optionmenu.insertSeparator() self.filterAllGamesAction.addTo(optionmenu) self.filterAvailableGamesAction.addTo(optionmenu) self.filterUnavailableGamesAction.addTo(optionmenu) menubar = self.menuBar() menubar.insertItem('&Main', mainmenu) menubar.insertItem('&Options', optionmenu) # do nothing here, for now def initToolbar(self): pass def refreshListView(self): self.refreshListView_common(QListViewItem) def _appendListItem(self, parent, name): self._appendListItem_common(parent, name, QListViewItem) def selectGame(self, name, called_externally=False): self.textView.set_game_info(name) def slotLaunchDosbox(self, game=None): if game is None: game = self.listView.currentItem().game if self.app.game_fileshandler.get_game_status(game): self.app.dosbox.run_game(game) else: title = self.game_titles[game] box = QMessageBox.information(self, 'UnavailableGame') box.setText('%s is unavailable' % title)