def searchMenu(self, txt, parent, mousemenu): # this menu needs to be rebuilt everytime a character changes # don't bother if the user just cleared the search if len(txt) == 0: return pos = self._parent.mapToGlobal(self._parent._event_pos + QtCore.QPoint(mousemenu.sizeHint().width(), 0)) # close any existing search menu and assign the new one self.removeSearchPopup() searchMenu = SearchMenu(pos, parent=parent) self.generateNodeSearchActions(str(txt), searchMenu, mousemenu) self._listwdg = searchMenu searchMenu.show()
def dropEvent(self, event): log.debug("dropped in test window") if event.mimeData().hasFormat('application/gpi-widget'): mime = event.mimeData() itemData = mime.data('application/gpi-widget') dataStream = QtCore.QDataStream(itemData, QtCore.QIODevice.ReadOnly) text = QtCore.QByteArray() offset = QtCore.QPoint() dataStream >> text >> offset if self.addWidgetByID(self._graph.getAllNodes(), int(text)): # event.acceptProposedAction() event.accept() else: event.ignore()
def _createNewNode(self): # copy node template to this library, and open it up fullpath = self._new_node_path new_node_created = False if os.path.exists(fullpath): log.warn("Didn't create new node at path: " + fullpath + " (file already exists)") else: try: shutil.copyfile(Config.GPI_NEW_NODE_TEMPLATE_FILE, fullpath) except OSError as e: print(e) log.warn("Didn't create new node at path: " + fullpath) else: log.dialog("New node created at path: " + fullpath) new_node_created = True self.rescan() self._list_win.hide() if new_node_created: # instantiate our new node on the canvas canvas = self._parent pos = QtCore.QPoint(0, 0) node = self.findNode_byPath(fullpath) sig = {'sig': 'load', 'subsig': node, 'pos': pos} canvas.addNodeRun(sig) # now open the file for editing (stolen from node.py) if Specs.inOSX(): # OSX users set their launchctl associated file prefs command = "open \"" + fullpath + "\"" subprocess.Popen(command, shell=True) # Linux users set their editor choice # TODO: this should be moved to config elif Specs.inLinux(): editor = 'gedit' if os.environ.has_key("EDITOR"): editor = os.environ["EDITOR"] command = editor + " \"" + fullpath + "\"" subprocess.Popen(command, shell=True) else: log.warn("Quick-Edit unavailable for this OS, aborting...")
def searchMenu(self, txt, parent, mousemenu): # this menu needs to be rebuilt everytime a character changes # don't bother if the user just cleared the search if len(txt) == 0: return pos = self._parent.mapToGlobal(self._parent._event_pos + QtCore.QPoint(mousemenu.sizeHint().width(), 0)) # generate the menu menu = QtGui.QMenu(self._parent) self.generateNodeSearchActions(str(txt), menu, mousemenu) # render the menu without executing it menupixmap = QtGui.QPixmap().grabWidget(menu) # display the menu image (as a dummy menu as its being built) # TODO: this could probably be moved to the FauxMenu self._listwdg = FauxMenu(menu, pos) self._listwdg.setWindowFlags(QtCore.Qt.Tool | QtCore.Qt.FramelessWindowHint) self._listwdg.move(pos) self._listwdg.setPixmap(menupixmap) self._listwdg.show() self._listwdg.raise_()