PluginSelectionEncloser.py

changeset 7
e6addbe23b18
parent 3
b26df0282953
child 11
7c821731282a
equal deleted inserted replaced
6:5e92a5654d3a 7:e6addbe23b18
22 # Start-Of-Header 22 # Start-Of-Header
23 name = "Selection Encloser Plug-in" 23 name = "Selection Encloser Plug-in"
24 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 24 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
25 autoactivate = True 25 autoactivate = True
26 deactivateable = True 26 deactivateable = True
27 version = "0.1.0" 27 version = "0.2.0"
28 className = "SelectionEncloserPlugin" 28 className = "SelectionEncloserPlugin"
29 packageName = "SelectionEncloser" 29 packageName = "SelectionEncloser"
30 shortDescription = "Enclose the selection with a string." 30 shortDescription = "Enclose the selection with a string."
31 longDescription = \ 31 longDescription = \
32 """This plug-in implements a tool to enclose the selection of""" \ 32 """This plug-in implements a tool to enclose the selection of""" \
110 ]], 110 ]],
111 [self.tr("HTML"), [ 111 [self.tr("HTML"), [
112 ['<h1>', '<h1>{0}</h1>'], 112 ['<h1>', '<h1>{0}</h1>'],
113 ['<h2>', '<h2>{0}</h2>'], 113 ['<h2>', '<h2>{0}</h2>'],
114 ['<h3>', '<h3>{0}</h3>'], 114 ['<h3>', '<h3>{0}</h3>'],
115 ['--Separator--', ''],
115 ['<p>', '<p>{0}</p>'], 116 ['<p>', '<p>{0}</p>'],
116 ['<div>', '<div>{0}</div>'], 117 ['<div>', '<div>{0}</div>'],
117 ['<span>', '<span>{0}</span>'], 118 ['<span>', '<span>{0}</span>'],
118 ]] 119 ]]
119 ] 120 ]
294 Private slot to build the menu hierarchy. 295 Private slot to build the menu hierarchy.
295 """ 296 """
296 self.__menu.clear() 297 self.__menu.clear()
297 hierarchy = self.getPreferences("MenuHierarchy") 298 hierarchy = self.getPreferences("MenuHierarchy")
298 for menuTitle, entries in hierarchy: 299 for menuTitle, entries in hierarchy:
299 submenu = QMenu(menuTitle, self.__menu) 300 if menuTitle == '--Separator--':
300 for title, encString in entries: 301 self.__menu.addSeparator()
301 act = submenu.addAction(title, self.__encloseSelection) 302 else:
302 act.setData(encString) 303 submenu = QMenu(menuTitle, self.__menu)
303 self.__menu.addMenu(submenu) 304 for title, encString in entries:
305 if title == '--Separator--':
306 submenu.addSeparator()
307 else:
308 act = submenu.addAction(title, self.__encloseSelection)
309 act.setData(encString)
310 self.__menu.addMenu(submenu)
304 311
305 def __encloseSelection(self): 312 def __encloseSelection(self):
306 """ 313 """
307 Private slot to enclose the selection with the selected string. 314 Private slot to enclose the selection with the selected string.
308 """ 315 """

eric ide

mercurial