def onCreate(tag, keys): """Handle the onCreate event in the chapterHoist plugin.""" c = keys.get('c') if c: sc = scriptingController(c) ch = chapterHoist(sc, c)
def onCreate (tag, keys): """Handle the onCreate event in the chapterHoist plugin.""" c = keys.get('c') if c: sc = scriptingController(c) ch = chapterHoist(sc,c)
def addButton(self, first): '''Add a button for an interact class.''' c = self.c sc = scriptingController(c) mb = InteractButton(c, class_=first) if mb.available(): sc.createIconButton( args=None, text=mb.interactor.buttonText(), command=mb.run, statusLine=mb.interactor.statusText(), kind='interact', )
def addButton(self,first): '''Add a button for an interact class.''' c = self.c sc = scriptingController(c) mb = InteractButton(c,class_=first) if mb.available(): sc.createIconButton( args=None, text = mb.interactor.buttonText(), command = mb.run, statusLine = mb.interactor.statusText(), kind='interact', )
def addButton(self, which, type_="move", v=None, parent=None): '''Add a button that creates a target for future moves.''' c = self.c p = c.p if v is None: v = p.v sc = scriptingController(c) mb = quickMoveButton(self, v, which, type_=type_) txt = self.txts[type_] if parent: # find parent button for i in self.buttons: if i[0].target.gnx == parent: parent = i[1] break else: g.es('Move to button parent not found, placing at top level') parent = None header = v.anyAtFileNodeName() or v.h # drop @auto etc. text = txt + ":" + header if txt else header # createButton truncates text. if parent and g.app.gui.guiName().startswith("qt"): pb = parent.button rc = QtWidgets.QAction(text, pb) rc.triggered.connect(mb.moveCurrentNodeToTarget) pb.insertAction(pb.actions()[0], rc) # insert at top b = None mb.has_parent = True # New code. t = c.config.getString('mod-scripting-subtext') or '' t2 = pb.text() if not t.endswith(t): pb.setText(t2 + t) else: b = sc.createIconButton( args=None, text=text, command=mb.moveCurrentNodeToTarget, statusLine='%s current node to %s child of %s' % (type_.title(), which, v.h), kind="quick-move") if g.app.gui.guiName() == "qt": def cb_goto_target(checked, c=c, v=v): p = c.vnode2position(v) c.selectPosition(p) c.redraw() def cb_set_parent(checked, c=c, v=v, first=which, type_=type_): c.quickMove.set_parent(v, first, type_) def cb_permanent(checked, c=c, v=v, type_=type_, first=which): c.quickMove.permanentButton(v=v, type_=type_, first=first) # def cb_clear(event=None, c=c, v=v): # c.quickMove.clearButton(v) for cb, txt in [ (cb_goto_target, 'Goto target'), (cb_permanent, 'Make permanent'), # (cb_clear, 'Clear permanent'), (cb_set_parent, 'Set parent'), ]: but = b.button rc = QtWidgets.QAction(txt, but) rc.triggered.connect(cb) but.insertAction(but.actions()[-1], rc) # insert rc before Remove Button self.buttons.append((mb, b))
def addButton (self, which, type_="move", v=None, parent=None): '''Add a button that creates a target for future moves.''' c = self.c p = c.p if v is None: v = p.v sc = scriptingController(c) mb = quickMoveButton(self,v,which,type_=type_) txt=self.txts[type_] if parent: # find parent button for i in self.buttons: if i[0].target.gnx == parent: parent = i[1] break else: g.es('Move to button parent not found, placing at top level') parent = None header = v.anyAtFileNodeName() or v.h # drop @auto etc. text = txt + ":" + header if txt else header # createButton truncates text. if parent and g.app.gui.guiName() == "qt": # see setCommandForButton pb = parent.button rc = QtGui.QAction(text, pb) rc.connect(rc, QtCore.SIGNAL("triggered()"), mb.moveCurrentNodeToTarget) pb.insertAction(pb.actions()[0], rc) # insert at top b = None mb.has_parent = True t = QtCore.QString(c.config.getString('mod_scripting_subtext') or '') if not unicode(pb.text()).endswith(unicode(t)): pb.setText(pb.text()+t) else: b = sc.createIconButton( text, command = mb.moveCurrentNodeToTarget, statusLine = '%s current node to %s child of %s' % ( type_.title(), which, v.h), kind = "quick-move" ) if g.app.gui.guiName() == "qt": def cb_goto_target(event=None, c=c, v=v): p = c.vnode2position(v) c.selectPosition(p) c.redraw() def cb_set_parent(event=None, c=c, v=v, first=which, type_=type_): c.quickMove.set_parent(v, first, type_) def cb_permanent(event=None, c=c, v=v, type_=type_, first=which): c.quickMove.permanentButton(v=v, type_=type_, first=first) # def cb_clear(event=None, c=c, v=v): # c.quickMove.clearButton(v) for cb, txt in [ (cb_goto_target, 'Goto target'), (cb_permanent, 'Make permanent'), # (cb_clear, 'Clear permanent'), (cb_set_parent, 'Set parent'), ]: but = b.button rc = QtGui.QAction(txt, but) rc.connect(rc, QtCore.SIGNAL("triggered()"), cb) but.insertAction(but.actions()[-1], rc) # insert rc before Remove Button self.buttons.append((mb,b))
def addButton(self, first, type_="move", v=None, parent=None): '''Add a button that creates a target for future moves.''' c = self.c p = c.p if v is None: v = p.v sc = scriptingController(c) mb = quickMoveButton(self, v, first, type_=type_) txt = self.txts[type_] if parent: # find parent button for i in self.buttons: if i[0].target.gnx == parent: parent = i[1] break else: g.es('Move to button parent not found, placing at top level') parent = None header = v.anyAtFileNodeName() or v.h # drop @auto etc. text = txt + ":" + header if txt else header # createButton truncates text. if parent and g.app.gui.guiName() == "qt": # see qtGui.py/class leoQtFrame/class qtIconBarClass/setCommandForButton pb = parent.button rc = QtGui.QAction(text, pb) rc.connect(rc, QtCore.SIGNAL("triggered()"), mb.moveCurrentNodeToTarget) pb.insertAction(pb.actions()[0], rc) # insert at top b = None mb.has_parent = True t = QtCore.QString( c.config.getString('mod_scripting_subtext') or '') if not unicode(pb.text()).endswith(unicode(t)): pb.setText(pb.text() + t) else: b = sc.createIconButton( text, command=mb.moveCurrentNodeToTarget, statusLine='Move current node to %s child of %s' % (g.choose(first, 'first', 'last'), v.h), kind="quick-move") if g.app.gui.guiName() == "qt": def cb_goto_target(event=None, c=c, v=v): p = c.vnode2position(v) c.selectPosition(p) c.redraw() def cb_set_parent(event=None, c=c, v=v, first=first, type_=type_): c.quickMove.set_parent(v, first, type_) def cb_permanent(event=None, c=c, v=v, type_=type_, first=first): c.quickMove.permanentButton(v=v, type_=type_, first=first) # def cb_clear(event=None, c=c, v=v): # c.quickMove.clearButton(v) for cb, txt in [ (cb_goto_target, 'Goto target'), (cb_permanent, 'Make permanent'), # (cb_clear, 'Clear permanent'), (cb_set_parent, 'Set parent'), ]: but = b.button rc = QtGui.QAction(txt, but) rc.connect(rc, QtCore.SIGNAL("triggered()"), cb) but.insertAction(but.actions()[-1], rc) # insert rc before Remove Button self.buttons.append((mb, b))