class PaellaRecordSelector(QSplitter, BasePaellaWidget): def __init__(self, parent, table, fields, idcol, groupfields, mainview, name='PaellaRecordSelector'): #PaellaManagerWidget.__init__(self, parent, mainview, name=name) QSplitter.__init__(self, parent, name) BasePaellaWidget.initPaellaCommon(self) self.current = currentobject() self.table = table self.fields = fields self.idcol = idcol self.groupfields = groupfields self.listView = KListView(self) self.vsplit = QSplitter(self) self.vsplit.setOrientation(self.Vertical) self.mainView = mainview(self.vsplit) self.recordForm = EditableRecordFrame(self, fields) self.connect(self.listView, SIGNAL('selectionChanged()'), self.groupChanged) self.connect(self.recordForm.insButton, SIGNAL('clicked()'), self.insertRecord) self.connect(self.recordForm.updButton, SIGNAL('clicked()'), self.updateRecord) self.initlistView() self.setSource(self.handleURL) def initlistView(self): self.listView.addColumn('group') self.listView.setRootIsDecorated(True)
def setupUi(self): """setup UI elements""" self.viewLeft = ScoreViewLeft(self) self.viewRight = ScoreViewRight(self) self.viewRight.setHorizontalScrollBar(HorizontalScrollBar(self)) self.viewRight.setHorizontalScrollMode(QAbstractItemView.ScrollPerItem) self.viewRight.setFocusPolicy(Qt.NoFocus) self.viewRight.header().setSectionsClickable(False) self.viewRight.header().setSectionsMovable(False) self.viewRight.setSelectionMode(QAbstractItemView.NoSelection) windowLayout = QVBoxLayout(self) self.splitter = QSplitter(Qt.Vertical) self.splitter.setObjectName('ScoreTableSplitter') windowLayout.addWidget(self.splitter) scoreWidget = QWidget() self.scoreLayout = QHBoxLayout(scoreWidget) leftLayout = QVBoxLayout() leftLayout.addWidget(self.viewLeft) self.leftLayout = leftLayout self.scoreLayout.addLayout(leftLayout) self.scoreLayout.addWidget(self.viewRight) self.splitter.addWidget(scoreWidget) self.ruleTree = RuleTreeView(i18nc('kajongg', 'Used Rules')) self.splitter.addWidget(self.ruleTree) # this shows just one line for the ruleTree - so we just see the # name of the ruleset: self.splitter.setSizes(list([1000, 1]))
def __init__(self, parent, table, fields, idcol, groupfields, mainview, name='PaellaRecordSelector'): #PaellaManagerWidget.__init__(self, parent, mainview, name=name) QSplitter.__init__(self, parent, name) BasePaellaWidget.initPaellaCommon(self) self.current = currentobject() self.table = table self.fields = fields self.idcol = idcol self.groupfields = groupfields self.listView = KListView(self) self.vsplit = QSplitter(self) self.vsplit.setOrientation(self.Vertical) self.mainView = mainview(self.vsplit) self.recordForm = EditableRecordFrame(self, fields) self.connect(self.listView, SIGNAL('selectionChanged()'), self.groupChanged) self.connect(self.recordForm.insButton, SIGNAL('clicked()'), self.insertRecord) self.connect(self.recordForm.updButton, SIGNAL('clicked()'), self.updateRecord) self.initlistView() self.setSource(self.handleURL)
def make(): demo = QSplitter(QSplitter.Horizontal) plot1 = Plot(demo, 30) plot1.setFloorStyle(FLOORISO) plot1.setCoordinateStyle(BOX) saddle = Saddle(plot1) saddle.create() plot1.setTitle("Autoswitching axes") plot1.setBackgroundColor(RGBA(1.0, 1.0, 0.6)) plot1.makeCurrent() plot1.updateData() plot1.updateGL() plot2 = Plot(demo ,80) plot2.setZoom(0.8) hat = Hat(plot2) hat.create() plot2.setPlotStyle(HIDDENLINE) plot2.setFloorStyle(FLOORDATA) plot2.setCoordinateStyle(FRAME) plot2.setBackgroundColor(RGBA(1.0, 1.0, 0.6)) plot2.makeCurrent() plot2.updateData() plot2.updateGL() demo.resize(800, 400) demo.show() return demo
def __init__(self, app, parent, view, name): QSplitter.__init__(self, parent, name) self.app = app self.listView = KListView(self) self.view = view(self.app, self) self.initlistView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) self.show()
def __init__(self, parent, mainview, listview=None, name='BaseManagerWidget'): QSplitter.__init__(self, parent, name) if listview is None: self.listView = KListView(self) else: self.listView = listView(self) self.mainView = mainview(self) self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged)
def __init__(self, parent, suite, name='TemplateEditor'): QSplitter.__init__(self, parent, name) self.app = get_application_pointer() self.trait = None self.listView = TraitListView(self, 'template') self.mainEdit = SimpleEdit(self) self.set_suite(suite) self.refreshListView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged)
def __init__(self, parent, name='ProfileManagerWidget'): QSplitter.__init__(self, parent, name) self.app = get_application_pointer() #self.listView = KListView(self) self.cfgView = DosboxConfigTabWidget(self) self.dbox = self.app.make_new_dosbox_object() #self.initlistView() cfg = self.dbox.get_default_config() self.cfgView.set_config(cfg)
def __init__(self, app, parent, suite, name='TemplateEditor'): QSplitter.__init__(self, parent, name) dbwidget(self, app) self.trait = None self.listView = TraitList(self.app, self, 'template') self.mainEdit = SimpleEdit(self.app, self) self.set_suite(suite) self.refreshListView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged)
def setupUi(self): """setup UI elements""" self.viewLeft = ScoreViewLeft(self) self.viewRight = ScoreViewRight(self) self.viewRight.setHorizontalScrollBar(HorizontalScrollBar(self)) self.viewRight.setHorizontalScrollMode(QAbstractItemView.ScrollPerItem) self.viewRight.setFocusPolicy(Qt.NoFocus) if usingQt5: self.viewRight.header().setSectionsClickable(False) self.viewRight.header().setSectionsMovable(False) else: self.viewRight.header().setClickable(False) self.viewRight.header().setMovable(False) self.viewRight.setSelectionMode(QAbstractItemView.NoSelection) windowLayout = QVBoxLayout(self) self.splitter = QSplitter(Qt.Vertical) self.splitter.setObjectName("ScoreTableSplitter") windowLayout.addWidget(self.splitter) scoreWidget = QWidget() self.scoreLayout = QHBoxLayout(scoreWidget) leftLayout = QVBoxLayout() leftLayout.addWidget(self.viewLeft) self.leftLayout = leftLayout self.scoreLayout.addLayout(leftLayout) self.scoreLayout.addWidget(self.viewRight) self.splitter.addWidget(scoreWidget) self.ruleTree = RuleTreeView(m18nc("kajongg", "Used Rules")) self.splitter.addWidget(self.ruleTree) # this shows just one line for the ruleTree - so we just see the # name of the ruleset: self.splitter.setSizes(list([1000, 1]))
def __init__(self, parent, name='MainEntityWindow'): BaseToolboxWindow.__init__(self, parent, name=name) self.splitView = QSplitter(self, 'splitView') self.listView = KListView(self.splitView, 'entities_view') self.textView = RtorrentInfoPart(self.splitView) self.initActions() self.initMenus() self.initToolbar() self.app.rtserver = Server(url="http://roujin/RPC2") self.app.rtorrent = Rtorrent(self.app.rtserver) #self._sortby = 'name' self.initlistView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) self.connect(self.textView, PYSIGNAL('EntityInfoUpdated'), self.refreshDisplay) self.setCentralWidget(self.splitView) # dialogs self._new_entity_dlg = None # resize window self.resize(400, 500) self.splitView.setSizes([75, 325]) self.setAcceptDrops(True)
def __init__(self, parent): KMainWindow.__init__(self, parent, 'Uncover Truth Frontend') self.app = get_application_pointer() self.splitView = QSplitter(self, 'splitView') self.listView = KListView(self.splitView, 'guests_view') self.textView = InfoPart(self.splitView) self.initlistView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) self.connect(self.textView, PYSIGNAL('GuestInfoUpdated'), self.refreshDisplay) self.setCentralWidget(self.splitView) collection = self.actionCollection() self.quitAction = KStdAction.quit(self.close, collection) self.newGuestAction = KStdAction.openNew(self.slotNewGuest, collection) self.selectAllAction = KStdAction.selectAll(self.slotSelectAll, collection) mainmenu = KPopupMenu(self) self.newGuestAction.plug(mainmenu) self.selectAllAction.plug(mainmenu) self.quitAction.plug(mainmenu) menubar = self.menuBar() menubar.insertItem('&Main', mainmenu) toolbar = self.toolBar() self.newGuestAction.plug(toolbar) self.quitAction.plug(toolbar) self.new_guest_dialog = None # resize window self.resize(400, 500) self.splitView.setSizes([75, 325])
def __init__(self, parent, db, table, fields, idcol, groupfields, view, name='RecordSelector'): QSplitter.__init__(self, parent, name) self.current = currentobject() self.db = db self.table = table self.fields = fields self.idcol = idcol self.groupfields = groupfields self.listView = KListView(self) self.vsplit = QSplitter(self) self.vsplit.setOrientation(Qt.Vertical) self.recView = view(db, self.vsplit) frame = QFrame(self.vsplit) self.recForm = EditableRecord(frame, fields) self.connect(self.listView, SIGNAL('selectionChanged()'), self.groupChanged) self.connect(self.recForm.insButton, SIGNAL('clicked()'), self.insertRecord) self.connect(self.recForm.updButton, SIGNAL('clicked()'), self.updateRecord) self.initlistView() self.setSource(self.handleURL)
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 __init__(self, parent): KMainWindow.__init__(self, parent, 'PyKDE Dosbox Frontend') # setup app pointer self.app = get_application_pointer() self._init_common() self.setAcceptDrops(True) # place a splitter in the window self.splitView = QSplitter(self, 'splitView') # place a listview in the splitter (on the left) self.listView = KListView(self.splitView, 'games_view') # fill listview self.initlistView() # try to resize splitter # this is a kind of ugly hack, but seems to work ok x, y = self.myconfig.get_xy('mainwindow', 'mainwindow_size') self.splitView.setSizes([int(.1*x), int(.9*x)]) # setup signals self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) # place text browser in splitter #self.textView = InfoBrowser(self.splitView) # i may eventually use the KHTMLPart instead # of the KTextBrowser if self.app.myconfig.getboolean('mainwindow', 'use_khtml_part'): self.textView = InfoPart(self.splitView) else: self.textView = InfoBrowser(self.splitView) self.connect(self.textView, PYSIGNAL('GameInfoSet'), self.selectGame) self.statusbar = KStatusBar(self) self._set_current_profile(self.app.dosbox.current_profile) # set main widget self.setCentralWidget(self.splitView) # setup dialog pointers # it would be nice if I knew a better way to get # information from dialogs self.new_game_dir_dialog = None self.add_new_game_dlg = None self.set_profile_dlg = None # here we add some methods to the dcop object self.app.dcop.addMethod('void selectGame (QString)', self.selectGame) self.app.dcop.addMethod('void launchSelectedGame()', self.slotLaunchDosbox)
class RecordSelector(QSplitter): def __init__(self, parent, db, table, fields, idcol, groupfields, view, name='RecordSelector'): QSplitter.__init__(self, parent, name) self.current = currentobject() self.db = db self.table = table self.fields = fields self.idcol = idcol self.groupfields = groupfields self.listView = KListView(self) self.vsplit = QSplitter(self) self.vsplit.setOrientation(Qt.Vertical) self.recView = view(db, self.vsplit) frame = QFrame(self.vsplit) self.recForm = EditableRecord(frame, fields) self.connect(self.listView, SIGNAL('selectionChanged()'), self.groupChanged) self.connect(self.recForm.insButton, SIGNAL('clicked()'), self.insertRecord) self.connect(self.recForm.updButton, SIGNAL('clicked()'), self.updateRecord) self.initlistView() self.setSource(self.handleURL) def initlistView(self): self.listView.addColumn('group') self.listView.setRootIsDecorated(True) all = KListViewItem(self.listView, 'all') groups = [KListViewItem(self.listView, g) for g in self.groupfields] for g, parent in zip(self.groupfields, groups): fields = ['distinct %s' % g] rows = self.db.mcursor.select(fields=fields, table=self.table, order=g) for row in rows: item = KListViewItem(parent, row[g]) item.groupfield = g def groupChanged(self): item = self.listView.currentItem() self.current.group = item.text(0) if hasattr(item, 'groupfield'): clause = Eq(item.groupfield, self.current.group) self.recView.set_clause(clause) elif self.current.group == 'all': self.recView.set_clause(None) else: self.recView.set_clause('NULL') def handleURL(self, url): action, obj, ident = str(url).split('.') row = self.db.mcursor.select_row(fields=self.fields, table=self.table, clause=Eq(self.idcol, ident)) entries = self.recForm.entries for field in entries: entries[field].setText(row[field]) self.current.id = ident def setSource(self, handler): self.recView.setSource = handler def insertRecord(self): data = self.recForm.get_data() self.db.insertData(self.idcol, self.table, data) self.groupChanged() def updateRecord(self): if self.current.id is not None: data = self.recForm.get_data() clause = Eq(self.idcol, self.current.id) row = self.db.mcursor.select_row(table=self.table, clause=clause) updict = {} for k, v in data.items(): if str(row[k]) != str(v) and str(v): print v updict[k] = v print updict if updict: self.db.mcursor.update(table=self.table, data=updict, clause=clause) self.groupChanged()
def __init__(self): super(MainWidget, self).__init__() self.my_pop = None # Any child popup windows. Only bravais_table ATM self.storage_path = sys_arg.directory refresh_gui = False # Load the previous state of DUI, if present dui_files_path = os.path.join(self.storage_path, "dui_files") if os.path.isfile(os.path.join(dui_files_path, "bkp.pickle")): try: self.idials_runner = load_previous_state(dui_files_path) except Exception as e: # Something went wrong - tell the user then close msg = traceback.format_exc() logger.error("ERROR LOADING PREVIOUS DATA:\n%s", msg) raise_from(DUIDataLoadingError(msg), e) refresh_gui = True else: # No dui_files path - start with a fresh state if not os.path.isdir(dui_files_path): os.mkdir(dui_files_path) self.idials_runner = Runner() self.gui2_log = {"pairs_list": []} self.cli_tree_output = TreeShow() self.cli_tree_output(self.idials_runner) self.cur_html = None self.cur_pick = None self.cur_json = None self.cur_log = None self.cur_cmd_name = "None" main_box = QVBoxLayout() self.centre_par_widget = ControlWidget() self.centre_par_widget.pass_sys_arg_object_to_import(sys_arg) self.stop_run_retry = StopRunRetry() self.tree_out = TreeNavWidget() left_control_box = QHBoxLayout() left_top_control_box = QVBoxLayout() left_top_control_box.addWidget(self.centre_par_widget) left_top_control_box.addStretch() left_control_box.addLayout(left_top_control_box) centre_control_box = QVBoxLayout() v_control_splitter = QSplitter() v_control_splitter.setOrientation(Qt.Vertical) v_control_splitter.addWidget(self.tree_out) v_control_splitter.addWidget(self.centre_par_widget.step_param_widg) centre_control_box.addWidget(v_control_splitter) centre_control_box.addWidget(self.stop_run_retry) left_control_box.addLayout(centre_control_box) dummy_left_widget = QWidget() dummy_h_layout = QHBoxLayout() dummy_h_layout.addLayout(left_control_box) dummy_left_widget.setLayout(dummy_h_layout) dummy_left_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) h_main_splitter = QSplitter() h_main_splitter.setOrientation(Qt.Horizontal) h_main_splitter.addWidget(dummy_left_widget) self.cli_out = CliOutView() self.web_view = WebTab() self.img_view = MyImgWin() self.ext_view = OuterCaller() self.info_widget = InfoWidget() self.output_info_tabs = QTabWidget() self.output_info_tabs.addTab(self.img_view, "Image") self.output_info_tabs.addTab(self.cli_out, "Log") self.output_info_tabs.addTab(self.web_view, "Report") self.output_info_tabs.addTab(self.ext_view, "Tools") self.output_info_tabs.addTab(self.info_widget, "Experiment") self.view_tab_num = 0 self.output_info_tabs.currentChanged.connect(self.tab_changed) self.img_view.mask_applied.connect(self.pop_mask_list) self.img_view.predic_changed.connect(self.tab_changed) self.img_view.bc_applied.connect(self.pop_b_centr_coord) self.img_view.new_pars_applied.connect(self.pass_parmams) # self.ext_view.pass_parmam_lst.connect(self.pass_parmams) self.centre_par_widget.finished_masking.connect(self.img_view.unchec_my_mask) self.centre_par_widget.click_mask.connect(self.img_view.chec_my_mask) self.centre_par_widget.finished_b_centr.connect(self.img_view.unchec_b_centr) self.centre_par_widget.click_b_centr.connect(self.img_view.chec_b_centr) v_info_splitter = QSplitter() v_info_splitter.setOrientation(Qt.Vertical) v_info_splitter.addWidget(self.output_info_tabs) h_main_splitter.addWidget(v_info_splitter) main_box.addWidget(h_main_splitter) self.txt_bar = Text_w_Bar() main_box.addWidget(self.txt_bar) self.connect_all() self.custom_thread = CommandThread() self.custom_thread.finished.connect(self.update_after_finished) self.custom_thread.str_fail_signal.connect(self.after_failed) self.custom_thread.str_print_signal.connect(self.cli_out.add_txt) self.custom_thread.str_print_signal.connect(self.txt_bar.setText) self.custom_thread.busy_box_on.connect(self.pop_busy_box) self.custom_thread.busy_box_off.connect(self.close_busy_box) self.main_widget = QWidget() self.main_widget.setLayout(main_box) self.setCentralWidget(self.main_widget) self.setWindowTitle("CCP4 DUI - {}: {}".format(__version__, dui_files_path)) self.setWindowIcon(QIcon(self.stop_run_retry.dials_logo_path)) self.just_reindexed = False self.user_stoped = False self.reconnect_when_ready() self.my_pop = None if refresh_gui: self.refresh_my_gui()
class MainWindow(MainWindowCommon, KMainWindow): def __init__(self, parent): KMainWindow.__init__(self, parent, 'PyKDE Dosbox Frontend') # setup app pointer self.app = get_application_pointer() self._init_common() self.setAcceptDrops(True) # place a splitter in the window self.splitView = QSplitter(self, 'splitView') # place a listview in the splitter (on the left) self.listView = KListView(self.splitView, 'games_view') # fill listview self.initlistView() # try to resize splitter # this is a kind of ugly hack, but seems to work ok x, y = self.myconfig.get_xy('mainwindow', 'mainwindow_size') self.splitView.setSizes([int(.1*x), int(.9*x)]) # setup signals self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) # place text browser in splitter #self.textView = InfoBrowser(self.splitView) # i may eventually use the KHTMLPart instead # of the KTextBrowser if self.app.myconfig.getboolean('mainwindow', 'use_khtml_part'): self.textView = InfoPart(self.splitView) else: self.textView = InfoBrowser(self.splitView) self.connect(self.textView, PYSIGNAL('GameInfoSet'), self.selectGame) self.statusbar = KStatusBar(self) self._set_current_profile(self.app.dosbox.current_profile) # set main widget self.setCentralWidget(self.splitView) # setup dialog pointers # it would be nice if I knew a better way to get # information from dialogs self.new_game_dir_dialog = None self.add_new_game_dlg = None self.set_profile_dlg = None # here we add some methods to the dcop object self.app.dcop.addMethod('void selectGame (QString)', self.selectGame) self.app.dcop.addMethod('void launchSelectedGame()', self.slotLaunchDosbox) # Should probably start putting these actions into a dict def initActions(self): collection = self.actionCollection() self.quitAction = KStdAction.quit(self.close, collection) self.newGameAction = NewGame(self.slotNewGame, collection) self.importZipFileAction = ImportZipFile(self.slotImportZipFile, collection) self.launchDosboxAction = \ LaunchDosbox(self.slotLaunchDosbox, collection) self.launchDosboxPromptAction = \ LaunchDosboxPrompt(self.slotLaunchDosboxPrompt, collection) self.launchMainDosboxPromptAction = \ LaunchMainDosboxPrompt(self.slotLaunchMainDosboxPrompt, collection) self.flatViewAction = FlatView(self.slotFlatView, collection) self.treeViewAction = TreeView(self.slotTreeView, collection) self.nameViewAction = NameView(self.slotNameView, collection) self.titleViewAction = TitleView(self.slotTitleView, collection) self.prepareAllGamesAction = \ PrepareAllGames(self.slotPrepareAllGames, collection) self.cleanAllGamesAction = \ CleanAllGames(self.slotCleanAllGames, collection) self.archiveAllGamesAction = \ ArchiveAllGames(self.slotArchiveAllGames, collection) self.filterAllGamesAction = \ FilterAllGames(self.slotFilterAllGames, collection) self.filterAvailableGamesAction = \ FilterAvailableGames(self.slotFilterAvailableGames, collection) self.filterUnavailableGamesAction = \ FilterUnavailableGames(self.slotFilterUnavailableGames, collection) self.manageDosboxProfilesAction = \ ManageDosboxProfiles(self.slotManageDosboxProfiles, collection) self.setCurrentProfileAction = \ SetCurrentProfile(self.slotSetCurrentProfile, collection) self.configureDosboxPyKDEAction = \ ConfigureDosboxPyKDE(self.slotConfigureDosboxPyKDE, collection) def initMenus(self): # make a new menu mainmenu = KPopupMenu(self) # plug import new game actions into the menu self.newGameAction.plug(mainmenu) self.importZipFileAction.plug(mainmenu) # insert a little line separating menu items mainmenu.insertSeparator() # plug launch dosbox actions into the menu self.launchDosboxAction.plug(mainmenu) self.launchDosboxPromptAction.plug(mainmenu) self.launchMainDosboxPromptAction.plug(mainmenu) # insert a little line separating menu items mainmenu.insertSeparator() # plug the rest of the main menu actions self.prepareAllGamesAction.plug(mainmenu) self.cleanAllGamesAction.plug(mainmenu) self.archiveAllGamesAction.plug(mainmenu) self.quitAction.plug(mainmenu) # make a profiles menu profilemenu = KPopupMenu(self) self.manageDosboxProfilesAction.plug(profilemenu) self.setCurrentProfileAction.plug(profilemenu) # make another menu for options viewmenu = KPopupMenu(self) self.flatViewAction.plug(viewmenu) self.treeViewAction.plug(viewmenu) self.nameViewAction.plug(viewmenu) self.titleViewAction.plug(viewmenu) viewmenu.insertSeparator() self.filterAllGamesAction.plug(viewmenu) self.filterAvailableGamesAction.plug(viewmenu) self.filterUnavailableGamesAction.plug(viewmenu) # make a settings menu settingsmenu = KPopupMenu(self) self.configureDosboxPyKDEAction.plug(settingsmenu) # get a pointer to the menubar in the main window # this method will create a menubar if one is not already # available menubar = self.menuBar() # place the menus on the menu bar (in order) menubar.insertItem('&Main', mainmenu) menubar.insertItem('&Profiles', profilemenu) menubar.insertItem('&View', viewmenu) menubar.insertItem('&Settings', settingsmenu) menubar.insertItem('&Help', self.helpMenu('')) def initToolbar(self): # get a pointer to the main toolbar in the main window # this method will create a toolbar if one is not already there. toolbar = self.toolBar() # add some actions to the toolbar self.newGameAction.plug(toolbar) self.importZipFileAction.plug(toolbar) self.launchMainDosboxPromptAction.plug(toolbar) self.launchDosboxAction.plug(toolbar) self.launchDosboxPromptAction.plug(toolbar) self.manageDosboxProfilesAction.plug(toolbar) self.quitAction.plug(toolbar) def refreshListView(self): self.refreshListView_common(KListViewItem) def _appendListItem(self, parent, name): self._appendListItem_common(parent, name, KListViewItem) # if this method is called externally, i.e. through dcop # we need to select the KListViewItem that matches also # if this method is not called externally, it means that the # listitem has already been selected def selectGame(self, name, called_externally=True): if called_externally: # if this method is called from dcop, name will be # a QString, so we make it python string name = str(name) if name not in self.game_names: KMessageBox.error(self, '%s is not a valid game name.' % name) else: if self.name_title_view is 'name': # this is the easy part # the 0 in the second arg means column item = self.listView.findItem(name, 0) else: # we're using titles, so we have to get it title = self.game_titles[name] item = self.listView.findItem(title, 0) # here True means select, False means unselect self.listView.setSelected(item, True) # calling setSelected will emit the selection changed signal # which will result in this method being called again, although # internally this time. self._make_listitem_visible(item) else: # we only change the textView for internal calls self.textView.set_game_info(name) # here we make the selected item visible on the list # if it's not currently visible def _make_listitem_visible(self, item): item_pos = item.itemPos() # contentsY is the position in the contents that # is at the top of the visible area contentsY = self.listView.contentsY() # contentsHeight is the height of the full list contentsHeight = self.listView.contentsHeight() # visibleHeight is the height of the visible part of the list visibleHeight = self.listView.visibleHeight() # visible_range is the interval defining the contents positions # that are visible visible_range = range(contentsY, contentsY + visibleHeight) # here we test whether the item position is in the range of # visible positions, and if not, we scroll the listview to make it so. if item_pos not in visible_range: self.listView.setContentsPos(0, 0) self.listView.scrollBy(0, item_pos) def slotNewGame(self): if self.new_game_dir_dialog is None: main_dosbox_path = self.myconfig.get('dosbox', 'main_dosbox_path') dlg = KDirSelectDialog(main_dosbox_path, 0, self) dlg.connect(dlg, SIGNAL('okClicked()'), self.new_game_path_selected) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_new_game_dir_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_new_game_dir_dlg) dlg.show() self.new_game_dir_dialog = dlg else: KMessageBox.error(self, opendlg_errormsg) def slotLaunchDosbox(self, game=None): self._launchdosbox_common(game, launch_game=True) def slotLaunchDosboxPrompt(self, game=None): self._launchdosbox_common(game, launch_game=False) def slotLaunchMainDosboxPrompt(self): KMessageBox.information(self, 'Not implemented') def slotManageDosboxProfiles(self): #from dosboxcfg.profile import ProfileDialogWindow #win = ProfileDialogWindow(self) win = ManageDosboxProfilesWindow(self) win.show() def slotSetCurrentProfile(self): dlg = ProfileSelectorDialog(self) self.connect(dlg, SIGNAL('okClicked()'), self._current_profile_selected) self.set_profile_dlg = dlg dlg.show() def slotImportZipFile(self): #KMessageBox.information(self, 'Import a new game, not yet implemented.') #dlg = ImportGameUrlDialog(self) #dlg.show() win = ImportsMainWindow(self) win.show() def slotConfigureDosboxPyKDE(self): #KMessageBox.information(self, 'ConfigureDosboxPyKDE') dlg = SettingsWidgetDialog(self) dlg.show() def _launchdosbox_common(self, game, launch_game=True): if game is None: game = self.listView.currentItem().game if self.app.game_fileshandler.get_game_status(game): if launch_game: self.app.dosbox.run_game(game) else: self.app.dosbox.launch_dosbox_prompt(game) else: title = self.game_titles[game] KMessageBox.error(self, '%s is unavailable' % title) def _current_profile_selected(self): dlg = self.set_profile_dlg if dlg is not None: profile = dlg.get_selected_profile() self._set_current_profile(profile) self.set_profile_dlg = None def _set_current_profile(self, profile): dosbox = self.app.dosbox dosbox.set_current_profile(profile) msg = 'Current Profile: %s' % dosbox.current_profile self.statusbar.message(msg) def new_game_path_selected(self): # url is a KURL url = self.new_game_dir_dialog.url() # since the url should be file://path/to/game # we only want the /path/to/game fullpath = str(url.path()) # here we set the name of the game to the base # directory of the path. This is probably not a good # idea in the long run, and I'll change this behaviour one day. name = os.path.basename(fullpath) if name not in self.game_names: print name, fullpath, self.game_names if self.add_new_game_dlg is None: dlg = AddNewGameDialog(self, fullpath) dlg.connect(dlg, SIGNAL('okClicked()'), self.add_new_game) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_add_new_game_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_add_new_game_dlg) dlg.show() self.add_new_game_dlg = dlg else: KMessageBox.error(self, '%s already exists.' % name) self.new_game_dir_dialog = None def _report_add_to_installed_archive(self, filename, count, total): dlg = self._add_to_installed_archive_progress progress = dlg.progressBar() if dlg.total is None: dlg.total = total progress.setTotalSteps(total) dlg.setLabel('Adding %s to archive.' % filename) progress.setProgress(count) self.app.processEvents() def _report_extract_from_installed_archive(self, filename, count, total): dlg = self.extract_from_installed_archive_progress progress = dlg.progressBar() if dlg.total is None: dlg.total = total progress.setTotalSteps(total) dlg.setLabel('Extracting %s from archive.' % filename) progress.setProgress(count) self.app.processEvents() def add_new_game(self): dlg = self.add_new_game_dlg gamedata = dlg.get_gamedata_from_entries() name = gamedata['name'] fullpath = dlg.fullpath dlg.close() ### ugly section -- testing now -- cleanup later self.app.processEvents() filehandler = self.app.game_fileshandler filehandler._report_add_to_installed_archive = self._report_add_to_installed_archive self._add_to_installed_archive_progress = BaseProgressDialog(self) dlg = self._add_to_installed_archive_progress dlg.resize(400, 200) dlg.total = None dlg.show() ##### end of ugly section try: self.add_new_game_common(gamedata, fullpath) except ExistsError, inst: print 'here we are', inst KMessageBox.error(self, '%s already exists' % inst.args) dlg.close()
def __init__(self, parent=None): QSplitter.__init__(self, parent, 'hsplit') self.setOrientation(QSplitter.Horizontal) self.listbox = QListView(self) #self.insertWidget(self.listbox) self.notebook = QTabBar(self)
class ScoreTable(QWidget): """show scores of current or last game, even if the last game is finished. To achieve this we keep our own reference to game.""" def __init__(self, scene): super(ScoreTable, self).__init__(None) self.setObjectName('ScoreTable') self.scene = scene self.scoreModel = None self.scoreModelTest = None decorateWindow(self, i18nc('kajongg', 'Scores')) self.setAttribute(Qt.WA_AlwaysShowToolTips) self.setMouseTracking(True) self.__tableFields = [ 'prevailing', 'won', 'wind', 'points', 'payments', 'balance', 'hand', 'manualrules' ] self.setupUi() self.refresh() StateSaver(self, self.splitter) @property def game(self): """a proxy""" return self.scene.game def setColWidth(self): """we want to accommodate for 5 digits plus minus sign and all column widths should be the same, making horizontal scrolling per item more pleasant""" self.viewRight.setColWidth() def setupUi(self): """setup UI elements""" self.viewLeft = ScoreViewLeft(self) self.viewRight = ScoreViewRight(self) self.viewRight.setHorizontalScrollBar(HorizontalScrollBar(self)) self.viewRight.setHorizontalScrollMode(QAbstractItemView.ScrollPerItem) self.viewRight.setFocusPolicy(Qt.NoFocus) self.viewRight.header().setSectionsClickable(False) self.viewRight.header().setSectionsMovable(False) self.viewRight.setSelectionMode(QAbstractItemView.NoSelection) windowLayout = QVBoxLayout(self) self.splitter = QSplitter(Qt.Vertical) self.splitter.setObjectName('ScoreTableSplitter') windowLayout.addWidget(self.splitter) scoreWidget = QWidget() self.scoreLayout = QHBoxLayout(scoreWidget) leftLayout = QVBoxLayout() leftLayout.addWidget(self.viewLeft) self.leftLayout = leftLayout self.scoreLayout.addLayout(leftLayout) self.scoreLayout.addWidget(self.viewRight) self.splitter.addWidget(scoreWidget) self.ruleTree = RuleTreeView(i18nc('kajongg', 'Used Rules')) self.splitter.addWidget(self.ruleTree) # this shows just one line for the ruleTree - so we just see the # name of the ruleset: self.splitter.setSizes(list([1000, 1])) def sizeHint(self): """give the scoring table window a sensible default size""" result = QWidget.sizeHint(self) result.setWidth(result.height() * 3 / 2) # the default is too small. Use at least 2/5 of screen height and 1/4 # of screen width: available = Internal.app.desktop().availableGeometry() height = max(result.height(), available.height() * 2 / 5) width = max(result.width(), available.width() / 4) result.setHeight(height) result.setWidth(width) return result def refresh(self): """load this game and this player. Keep parameter list identical with ExplainView""" if not self.game: # keep scores of previous game on display return if self.scoreModel: expandGroups = [ self.viewLeft.isExpanded( self.scoreModel.index(x, 0, QModelIndex())) for x in range(4) ] else: expandGroups = [True, False, True, True] gameid = str(self.game.seed or self.game.gameid) if self.game.finished(): title = i18n('Final scores for game <numid>%1</numid>', gameid) else: title = i18n('Scores for game <numid>%1</numid>', gameid) decorateWindow(self, title) self.ruleTree.rulesets = list([self.game.ruleset]) self.scoreModel = ScoreModel(self) if Debug.modelTest: self.scoreModelTest = ModelTest(self.scoreModel, self) for view in [self.viewLeft, self.viewRight]: view.setModel(self.scoreModel) header = view.header() header.setStretchLastSection(False) view.setAlternatingRowColors(True) self.viewRight.header().setSectionResizeMode(QHeaderView.Fixed) for col in range(self.viewLeft.header().count()): self.viewLeft.header().setSectionHidden(col, col > 0) self.viewRight.header().setSectionHidden(col, col == 0) self.scoreLayout.setStretch(1, 100) self.scoreLayout.setSpacing(0) self.viewLeft.setFrameStyle(QFrame.NoFrame) self.viewRight.setFrameStyle(QFrame.NoFrame) self.viewLeft.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) for master, slave in ((self.viewRight, self.viewLeft), (self.viewLeft, self.viewRight)): master.expanded.connect(slave.expand) master.collapsed.connect(slave.collapse) master.verticalScrollBar().valueChanged.connect( slave.verticalScrollBar().setValue) for row, expand in enumerate(expandGroups): self.viewLeft.setExpanded( self.scoreModel.index(row, 0, QModelIndex()), expand) self.viewLeft.resizeColumnToContents(0) self.viewRight.setColWidth() # we need a timer since the scrollbar is not yet visible QTimer.singleShot(0, self.scrollRight) def scrollRight(self): """make sure the latest hand is visible""" scrollBar = self.viewRight.horizontalScrollBar() scrollBar.setValue(scrollBar.maximum()) def showEvent(self, dummyEvent): """Only now the views and scrollbars have useful sizes, so we can compute the spacer for the left view""" self.adaptLeftViewHeight() def adaptLeftViewHeight(self): """if the right view has a horizontal scrollbar, make sure both view have the same vertical scroll area. Otherwise scrolling to bottom results in unsyncronized views.""" if self.viewRight.horizontalScrollBar().isVisible(): height = self.viewRight.horizontalScrollBar().height() else: height = 0 if self.leftLayout.count() > 1: # remove previous spacer self.leftLayout.takeAt(1) if height: self.leftLayout.addSpacing(height)
class MainEntityWindow(BaseToolboxWindow): def __init__(self, parent, name='MainEntityWindow'): BaseToolboxWindow.__init__(self, parent, name=name) self.splitView = QSplitter(self, 'splitView') self.listView = KListView(self.splitView, 'entities_view') self.textView = InfoPart(self.splitView) self.initActions() self.initMenus() self.initToolbar() #self._sortby = 'name' self.initlistView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) self.connect(self.textView, PYSIGNAL('EntityInfoUpdated'), self.refreshDisplay) self.setCentralWidget(self.splitView) # dialogs self._new_entity_dlg = None # resize window self.resize(400, 500) self.splitView.setSizes([75, 325]) def initActions(self): collection = self.actionCollection() self.quitAction = KStdAction.quit(self.close, collection) self.newEntityAction = KStdAction.openNew(self.slotNewEntity, collection) self.newTagAction = NewTagAction(self.slotNewTag, collection) self.manageEntityTypesAction = KStdAction.addBookmark(self.slotManageEntityTypes, collection) def initMenus(self): mainmenu = KPopupMenu(self) self.newEntityAction.plug(mainmenu) self.newTagAction.plug(mainmenu) self.manageEntityTypesAction.plug(mainmenu) self.quitAction.plug(mainmenu) menubar = self.menuBar() menubar.insertItem('&Main', mainmenu) def initToolbar(self): toolbar = self.toolBar() self.newEntityAction.plug(toolbar) self.newTagAction.plug(toolbar) self.manageEntityTypesAction.plug(toolbar) self.quitAction.plug(toolbar) def initlistView(self): self.listView.addColumn('entity', -1) #self.listView.setSorting(-1) self.refreshListView() def refreshListView(self): self.listView.clear() #cursor = self.app.conn.stmtcursor() #rows = self.app.db.get_entities() #for row in rows: # item = KListViewItem(self.listView, row['name']) # item.entityid = row['entityid'] entities = self.app.db.get_entities() for entity in entities: item = KListViewItem(self.listView, entity.name) # we don't need the id anymore item.entityid = entity.entityid # since we can hold the whole object # which will talk to the db as needed item.entity = entity def slotNewEntity(self): from dialogs import SelectEntityTypeDialog win = SelectEntityTypeDialog(self) #win = MainEntityDialog(self, dtype='insert') #self._new_entity_dlg = win win.show() def slotNewTag(self): dlg = NewTagDialog(self) dlg.show() def slotManageEntityTypes(self): win = EntityTypeWindow(self) win.show() def _new_entity_added(self): dlg = self._new_entity_dlg if dlg is not None: data = dlg.get_data() self.app.db.create_entity(data) self.refreshListView() self._new_entity_dlg = None def selectionChanged(self): item = self.listView.currentItem() entityid = item.entityid self.textView.set_info(item.entity) def refreshDisplay(self): #KMessageBox.error(self, 'ack refreshDisplay called') #self.refreshListView() self.selectionChanged()
class BaseRtorrentWindow(BaseToolboxWindow, MainDropCatcher): def __init__(self, parent, name='MainEntityWindow'): BaseToolboxWindow.__init__(self, parent, name=name) self.splitView = QSplitter(self, 'splitView') self.listView = KListView(self.splitView, 'entities_view') self.textView = RtorrentInfoPart(self.splitView) self.initActions() self.initMenus() self.initToolbar() self.app.rtserver = Server(url="http://roujin/RPC2") self.app.rtorrent = Rtorrent(self.app.rtserver) #self._sortby = 'name' self.initlistView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) self.connect(self.textView, PYSIGNAL('EntityInfoUpdated'), self.refreshDisplay) self.setCentralWidget(self.splitView) # dialogs self._new_entity_dlg = None # resize window self.resize(400, 500) self.splitView.setSizes([75, 325]) self.setAcceptDrops(True) def initActions(self): collection = self.actionCollection() self.quitAction = KStdAction.quit(self.close, collection) self.newEntityAction = KStdAction.openNew(self.slotNewEntity, collection) self.newTagAction = NewTagAction(self.slotNewTag, collection) self.manageEntityTypesAction = KStdAction.addBookmark(self.slotManageEntityTypes, collection) def initMenus(self): mainmenu = KPopupMenu(self) self.newEntityAction.plug(mainmenu) self.newTagAction.plug(mainmenu) self.manageEntityTypesAction.plug(mainmenu) self.quitAction.plug(mainmenu) menubar = self.menuBar() menubar.insertItem('&Main', mainmenu) def initToolbar(self): toolbar = self.toolBar() self.newEntityAction.plug(toolbar) self.newTagAction.plug(toolbar) self.manageEntityTypesAction.plug(toolbar) self.quitAction.plug(toolbar) def initlistView(self): self.listView.addColumn('entity', -1) #self.listView.setSorting(-1) self.refreshListView() def refreshListView(self): self.listView.clear() torrents = self.app.rtorrent.torrents for k, v in self.app.rtorrent.torrents.items(): item = KListViewItem(self.listView, v.name) item.infohash = k def slotNewEntity(self): from dialogs import SelectEntityTypeDialog win = SelectEntityTypeDialog(self) #win = MainEntityDialog(self, dtype='insert') #self._new_entity_dlg = win win.show() def slotNewTag(self): dlg = NewTagDialog(self) dlg.show() def slotManageEntityTypes(self): win = EntityTypeWindow(self) win.show() def _new_entity_added(self): dlg = self._new_entity_dlg if dlg is not None: data = dlg.get_data() self.app.db.create_entity(data) self.refreshListView() self._new_entity_dlg = None def selectionChanged(self): item = self.listView.currentItem() infohash = item.infohash tv = self.textView self.textView.set_info(infohash) def refreshDisplay(self): #KMessageBox.error(self, 'ack refreshDisplay called') #self.refreshListView() self.selectionChanged()
class ScoreTable(QWidget): """show scores of current or last game, even if the last game is finished. To achieve this we keep our own reference to game.""" def __init__(self, scene): super(ScoreTable, self).__init__(None) self.setObjectName("ScoreTable") self.scene = scene self.scoreModel = None self.scoreModelTest = None decorateWindow(self, m18nc("kajongg", "Scores")) self.setAttribute(Qt.WA_AlwaysShowToolTips) self.setMouseTracking(True) self.__tableFields = ["prevailing", "won", "wind", "points", "payments", "balance", "hand", "manualrules"] self.setupUi() self.refresh() StateSaver(self, self.splitter) @property def game(self): """a proxy""" return self.scene.game def setColWidth(self): """we want to accommodate for 5 digits plus minus sign and all column widths should be the same, making horizontal scrolling per item more pleasant""" self.viewRight.setColWidth() def setupUi(self): """setup UI elements""" self.viewLeft = ScoreViewLeft(self) self.viewRight = ScoreViewRight(self) self.viewRight.setHorizontalScrollBar(HorizontalScrollBar(self)) self.viewRight.setHorizontalScrollMode(QAbstractItemView.ScrollPerItem) self.viewRight.setFocusPolicy(Qt.NoFocus) if usingQt5: self.viewRight.header().setSectionsClickable(False) self.viewRight.header().setSectionsMovable(False) else: self.viewRight.header().setClickable(False) self.viewRight.header().setMovable(False) self.viewRight.setSelectionMode(QAbstractItemView.NoSelection) windowLayout = QVBoxLayout(self) self.splitter = QSplitter(Qt.Vertical) self.splitter.setObjectName("ScoreTableSplitter") windowLayout.addWidget(self.splitter) scoreWidget = QWidget() self.scoreLayout = QHBoxLayout(scoreWidget) leftLayout = QVBoxLayout() leftLayout.addWidget(self.viewLeft) self.leftLayout = leftLayout self.scoreLayout.addLayout(leftLayout) self.scoreLayout.addWidget(self.viewRight) self.splitter.addWidget(scoreWidget) self.ruleTree = RuleTreeView(m18nc("kajongg", "Used Rules")) self.splitter.addWidget(self.ruleTree) # this shows just one line for the ruleTree - so we just see the # name of the ruleset: self.splitter.setSizes(list([1000, 1])) def sizeHint(self): """give the scoring table window a sensible default size""" result = QWidget.sizeHint(self) result.setWidth(result.height() * 3 / 2) # the default is too small. Use at least 2/5 of screen height and 1/4 # of screen width: available = KApplication.kApplication().desktop().availableGeometry() height = max(result.height(), available.height() * 2 / 5) width = max(result.width(), available.width() / 4) result.setHeight(height) result.setWidth(width) return result def refresh(self): """load this game and this player. Keep parameter list identical with ExplainView""" if not self.game: # keep scores of previous game on display return if self.scoreModel: expandGroups = [self.viewLeft.isExpanded(self.scoreModel.index(x, 0, QModelIndex())) for x in range(4)] else: expandGroups = [True, False, True, True] gameid = str(self.game.seed or self.game.gameid) if self.game.finished(): title = m18n("Final scores for game <numid>%1</numid>", gameid) else: title = m18n("Scores for game <numid>%1</numid>", gameid) decorateWindow(self, title) self.ruleTree.rulesets = list([self.game.ruleset]) self.scoreModel = ScoreModel(self) if Debug.modelTest: self.scoreModelTest = ModelTest(self.scoreModel, self) for view in [self.viewLeft, self.viewRight]: view.setModel(self.scoreModel) header = view.header() header.setStretchLastSection(False) view.setAlternatingRowColors(True) if usingQt5: self.viewRight.header().setSectionResizeMode(QHeaderView.Fixed) else: self.viewRight.header().setResizeMode(QHeaderView.Fixed) for col in range(self.viewLeft.header().count()): self.viewLeft.header().setSectionHidden(col, col > 0) self.viewRight.header().setSectionHidden(col, col == 0) self.scoreLayout.setStretch(1, 100) self.scoreLayout.setSpacing(0) self.viewLeft.setFrameStyle(QFrame.NoFrame) self.viewRight.setFrameStyle(QFrame.NoFrame) self.viewLeft.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) for master, slave in ((self.viewRight, self.viewLeft), (self.viewLeft, self.viewRight)): master.expanded.connect(slave.expand) master.collapsed.connect(slave.collapse) master.verticalScrollBar().valueChanged.connect(slave.verticalScrollBar().setValue) for row, expand in enumerate(expandGroups): self.viewLeft.setExpanded(self.scoreModel.index(row, 0, QModelIndex()), expand) self.viewLeft.resizeColumnToContents(0) self.viewRight.setColWidth() # we need a timer since the scrollbar is not yet visible QTimer.singleShot(0, self.scrollRight) def scrollRight(self): """make sure the latest hand is visible""" scrollBar = self.viewRight.horizontalScrollBar() scrollBar.setValue(scrollBar.maximum()) def showEvent(self, dummyEvent): """Only now the views and scrollbars have useful sizes, so we can compute the spacer for the left view""" self.adaptLeftViewHeight() def adaptLeftViewHeight(self): """if the right view has a horizontal scrollbar, make sure both view have the same vertical scroll area. Otherwise scrolling to bottom results in unsyncronized views.""" if self.viewRight.horizontalScrollBar().isVisible(): height = self.viewRight.horizontalScrollBar().height() else: height = 0 if self.leftLayout.count() > 1: # remove previous spacer self.leftLayout.takeAt(1) if height: self.leftLayout.addSpacing(height)
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)
class MainWindow(KMainWindow): def __init__(self, parent): KMainWindow.__init__(self, parent, 'Uncover Truth Frontend') self.app = get_application_pointer() self.splitView = QSplitter(self, 'splitView') self.listView = KListView(self.splitView, 'guests_view') self.textView = InfoPart(self.splitView) self.initlistView() self.connect(self.listView, SIGNAL('selectionChanged()'), self.selectionChanged) self.connect(self.textView, PYSIGNAL('GuestInfoUpdated'), self.refreshDisplay) self.setCentralWidget(self.splitView) collection = self.actionCollection() self.quitAction = KStdAction.quit(self.close, collection) self.newGuestAction = KStdAction.openNew(self.slotNewGuest, collection) self.selectAllAction = KStdAction.selectAll(self.slotSelectAll, collection) mainmenu = KPopupMenu(self) self.newGuestAction.plug(mainmenu) self.selectAllAction.plug(mainmenu) self.quitAction.plug(mainmenu) menubar = self.menuBar() menubar.insertItem('&Main', mainmenu) toolbar = self.toolBar() self.newGuestAction.plug(toolbar) self.quitAction.plug(toolbar) self.new_guest_dialog = None # resize window self.resize(400, 500) self.splitView.setSizes([75, 325]) def initlistView(self): self.listView.addColumn('guests', -1) self.refreshListView() def refreshListView(self): self.listView.clear() cursor = self.app.conn.stmtcursor() rows = self.app.guests.get_guest_rows() for row in rows: name = '%s %s' % (row.firstname, row.lastname) item = KListViewItem(self.listView, name) item.guestid = row['guestid'] def slotNewGuest(self): win = BaseGuestDialog(self) self.connect(win, SIGNAL('okClicked()'), self._new_guest_added) self.new_guest_dialog = win win.show() def slotSelectAll(self): self.textView.view_all_guests() def _new_guest_added(self): dlg = self.new_guest_dialog if dlg is not None: data = dlg.get_guest_data() self.app.guests.insert_guest_data(data) self.refreshListView() self.new_guest_dialog = None def selectionChanged(self): item = self.listView.currentItem() guestid = item.guestid self.textView.set_guest_info(item.guestid) def refreshDisplay(self): #KMessageBox.error(self, 'ack refreshDisplay called') #self.refreshListView() self.selectionChanged()
def __init__(self, parent, name='MainSplitter'): QSplitter.__init__(self, parent, name) #self.browser = TestTextBrowser(self) self.kpart = TestTextPart(self)