def __on_button_click(self, source, event): # Detect a single right-click if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: treepath = self.get_path_at_pos(int(event.x), int(event.y)) if treepath: path, tree_column, x, y = treepath iter = self._model.get_iter(path) view = self._model.get_value(iter, 1) parent = self._model.iter_parent(iter) if parent: parentview = self._model.get_value(parent, 1) else: parentview = None if isinstance(view, ContactView) or isinstance(view, GroupView): # TODO: pass the parentview to the menu in some way, # the menu could be custom self.grab_focus() self.set_cursor(path, tree_column, 0) menu = gtk.Menu() common.create_menu_items_from_view(menu, view.on_right_click_popup_menu.items) menu.popup(None, None, None, event.button, event.time) return True # Detect a single left-click, but it is called even when a double-click occours, # so should we detect them or is there a simpler way? #elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: # return False else: return False
def contextMenuEvent(self, event): objtype = None view = None l = self.ui.cList.selectedIndexes() if len( l ) == 0: #no item in cList was selected, make context work as if a group was selected objtype = "group" for item in self._model.findItems("*", QtCore.Qt.MatchWildcard): index = item.index() model = item.model() qvarv = model.data(model.index(index.row(), 3, index.parent())) gitem = qvarv.toPyObject() if str(gitem.uid) == "0": view = gitem else: index = l[0] model = index.model() qvart = model.data(model.index(index.row(), 2, index.parent())) qvarv = model.data(model.index(index.row(), 3, index.parent())) objtype = qvart.toString() view = qvarv.toPyObject() if objtype == "contact": menu = QtGui.QMenu("Contact Popup", self) elif objtype == "group": menu = QtGui.QMenu("Group Popup", self) menuview = view.on_right_click_popup_menu common.create_menu_items_from_view(menu, menuview.items) menu.popup(event.globalPos())
def contextMenuEvent(self, event): objtype = None view = None l = self.ui.cList.selectedIndexes() if len(l) == 0: #no item in cList was selected, make context work as if a group was selected objtype = "group" for item in self._model.findItems("*", QtCore.Qt.MatchWildcard): index = item.index() model = item.model() qvarv = model.data(model.index(index.row(), 3, index.parent())) gitem = qvarv.toPyObject() if str(gitem.uid) == "0": view = gitem else: index = l[0] model = index.model() qvart = model.data(model.index(index.row(), 2, index.parent())) qvarv = model.data(model.index(index.row(), 3, index.parent())) objtype = qvart.toString() view = qvarv.toPyObject() if objtype == "contact": menu = QtGui.QMenu("Contact Popup", self) elif objtype == "group": menu = QtGui.QMenu("Group Popup", self) menuview = view.on_right_click_popup_menu common.create_menu_items_from_view(menu, menuview.items) menu.popup(event.globalPos())
def set_menu(self, menu): """ This will allow the core to change the current window's main menu @type menu: MenuView """ chldn = self.main_menu.get_children() if len(chldn) is not 0: for chl in chldn: self.main_menu.remove(chl) common.create_menu_items_from_view(self.main_menu, menu.items) self.main_menu.show()
def contextMenuEvent(self, event): l = self.ui.cList.selectedIndexes() index = l[0] model = index.model() qvart = model.data(model.index(index.row(), 2, index.parent())) qvarv = model.data(model.index(index.row(), 3, index.parent())) type = qvart.toString() view = qvarv.toPyObject() #is the double-clicked item a contact? if type == "contact": menuview = view.on_right_click_popup_menu menu = QMenu("Contact Popup", self) common.create_menu_items_from_view(menu, menuview.items) menu.popup(event.globalPos())
def __on_button_click(self, source, event): # Detect a single right-click if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: treepath = self.get_path_at_pos(int(event.x), int(event.y)) if treepath: path, tree_column, x, y = treepath iter = self._model.get_iter(path) view = self._model.get_value(iter, 1) parent = self._model.iter_parent(iter) if parent: parentview = self._model.get_value(parent, 1) else: parentview = None if isinstance(view, ContactView) or isinstance( view, GroupView): # TODO: pass the parentview to the menu in some way, # the menu could be custom self.grab_focus() self.set_cursor(path, tree_column, 0) menu = gtk.Menu() common.create_menu_items_from_view( menu, view.on_right_click_popup_menu.items) menu.popup(None, None, None, event.button, event.time) return True # Detect a single left-click, but it is called even when a double-click occours, # so should we detect them or is there a simpler way? #elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: # return False else: return False
def set_menu(self, menu): mb = QMenuBar() common.create_menu_items_from_view(mb, menu.items) self.setMenuBar(mb)
def set_menu(self, menu): mb = QtGui.QMenuBar() common.create_menu_items_from_view(mb, menu.items) self.setMenuBar(mb)