def testEmpty (self): strid = "test_id" title = u"title" description = u"description" hotkey = HotKey ("F1") polyaction = PolyAction (Application, strid, title, description) self.actionController.register (polyaction, hotkey) self.assertEqual (self.actionController.getAction (strid).title, title) self.assertEqual (self.actionController.getAction (strid).description, description) polyaction.run (None)
def testEmpty(self): strid = "test_id" title = "title" description = "description" hotkey = HotKey("F1") polyaction = PolyAction(self.application, strid, title, description) self.actionController.register(polyaction, hotkey) self.assertEqual(self.actionController.getAction(strid).title, title) self.assertEqual( self.actionController.getAction(strid).description, description) polyaction.run(None)
def registerActions(application): """ Зарегистрировать действия """ # Действия, связанные с разными типами страниц from outwiker.pages.html.htmlpage import HtmlPageFactory HtmlPageFactory.registerActions(application) from outwiker.pages.wiki.wikipage import WikiPageFactory WikiPageFactory.registerActions(application) actionController = application.actionController from outwiker.gui.actionslist import actionsList, polyactionsList # Register the normal actions [ actionController.register(item[0](application), item[1]) for item in actionsList ] # Register the polyactions [ actionController.register( PolyAction(application, item[0], item[1], item[2]), item[3]) for item in polyactionsList ]
def _registerActions(self, application): """ Зарегистрировать действия """ # Действия, связанные с разными типами страниц from outwiker.pages.html.htmlpage import HtmlPageFactory HtmlPageFactory.registerActions(application) from outwiker.pages.wiki.wikipage import WikiPageFactory WikiPageFactory.registerActions(application) actionController = application.actionController from outwiker.gui.actionslist import actionsList, polyactionsList # Register the normal actions [actionController.register(item.action_type(application), item.hotkey, item.area, item.hidden) for item in actionsList] # Register the polyactions [actionController.register(PolyAction(application, item.stringId, item.title, item.description), item.hotkey) for item in polyactionsList]
def testPolymorphParam1(self): strid = "test_id" title = "title" description = "description" polyaction = PolyAction(self.application, strid, title, description) polyaction.run(None) self.assertEqual(self._actionVal, 0) polyaction.setFunc(self._addParams) polyaction.run(5) self.assertEqual(self._actionVal, 5)
def testPolymorphParam2(self): strid = "test_id" title = "title" description = "description" polyaction = PolyAction(self.application, strid, title, description) self.actionController.register(polyaction, None) self.actionController.getAction(strid).run(None) self.assertEqual(self._actionVal, 0) self.actionController.getAction(strid).setFunc(self._addParams) self.actionController.getAction(strid).run(5) self.assertEqual(self._actionVal, 5)
def testPolymorphParam1 (self): strid = "test_id" title = u"title" description = u"description" polyaction = PolyAction (Application, strid, title, description) polyaction.run(None) self.assertEqual (self._actionVal, 0) polyaction.setFunc (self._addParams) polyaction.run (5) self.assertEqual (self._actionVal, 5)
def testPolymorph(self): strid = "test_id" title = "title" description = "description" polyaction = PolyAction(self.application, strid, title, description) polyaction.run(None) self.assertEqual(self._actionVal, 0) polyaction.setFunc(self._addActionVal) polyaction.run(None) self.assertEqual(self._actionVal, 1) polyaction.run(None) self.assertEqual(self._actionVal, 2) self._actionVal = 0 polyaction.setFunc(self._addActionVal2) polyaction.run(0) self.assertEqual(self._actionVal, 2) polyaction.setFunc(None) polyaction.run(0) self.assertEqual(self._actionVal, 2)
def testPolymorph (self): strid = "test_id" title = u"title" description = u"description" polyaction = PolyAction (Application, strid, title, description) polyaction.run(None) self.assertEqual (self._actionVal, 0) polyaction.setFunc (self._addActionVal) polyaction.run(None) self.assertEqual (self._actionVal, 1) polyaction.run(None) self.assertEqual (self._actionVal, 2) self._actionVal = 0 polyaction.setFunc (self._addActionVal2) polyaction.run (0) self.assertEqual (self._actionVal, 2) polyaction.setFunc (None) polyaction.run (0) self.assertEqual (self._actionVal, 2)
def _registerPolyActions(application): # Шрифты application.actionController.register( PolyAction(application, BOLD_STR_ID, _(u"Bold"), _(u"Bold")), HotKey("B", ctrl=True)) application.actionController.register( PolyAction(application, ITALIC_STR_ID, _(u"Italic"), _(u"Italic")), HotKey("I", ctrl=True)) application.actionController.register( PolyAction(application, BOLD_ITALIC_STR_ID, _(u"Bold italic"), _(u"Bold italic")), HotKey("I", ctrl=True, shift=True)) application.actionController.register( PolyAction(application, UNDERLINE_STR_ID, _(u"Underline"), _(u"Underline")), HotKey("U", ctrl=True)) application.actionController.register( PolyAction(application, STRIKE_STR_ID, _(u"Strikethrough"), _(u"Strikethrough")), HotKey("K", ctrl=True)) application.actionController.register( PolyAction(application, SUBSCRIPT_STR_ID, _(u"Subscript"), _(u"Subscript")), HotKey("=", ctrl=True)) application.actionController.register( PolyAction(application, SUPERSCRIPT_STR_ID, _(u"Superscript"), _(u"Superscript")), HotKey("+", ctrl=True)) application.actionController.register( PolyAction(application, PREFORMAT_STR_ID, _(u"Preformatted text"), _(u"Preformatted text")), HotKey("F", ctrl=True, alt=True)) application.actionController.register( PolyAction(application, CODE_STR_ID, _(u"Insert code"), _(u"Insert code (monospaced font)")), HotKey("D", ctrl=True, alt=True)) # Выравнивания application.actionController.register( PolyAction(application, ALIGN_LEFT_STR_ID, _(u"Align text left"), _(u"Align text left")), HotKey("L", ctrl=True, alt=True)) application.actionController.register( PolyAction(application, ALIGN_CENTER_STR_ID, _(u"Center"), _(u"Center")), HotKey("C", ctrl=True, alt=True)) application.actionController.register( PolyAction(application, ALIGN_RIGHT_STR_ID, _(u"Align text right"), _(u"Align text right")), HotKey("R", ctrl=True, alt=True)) application.actionController.register( PolyAction(application, ALIGN_JUSTIFY_STR_ID, _(u"Justify"), _(u"Justify")), HotKey("J", ctrl=True, alt=True)) # Заголовки application.actionController.register( PolyAction(application, HEADING_1_STR_ID, _(u"First-level heading"), _(u"First-level heading")), HotKey("1", ctrl=True)) application.actionController.register( PolyAction(application, HEADING_2_STR_ID, _(u"Second-level heading"), _(u"Second-level heading")), HotKey("2", ctrl=True)) application.actionController.register( PolyAction(application, HEADING_3_STR_ID, _(u"Subtitle three"), _(u"Subtitle three")), HotKey("3", ctrl=True)) application.actionController.register( PolyAction(application, HEADING_4_STR_ID, _(u"Subtitle four"), _(u"Subtitle four")), HotKey("4", ctrl=True)) application.actionController.register( PolyAction(application, HEADING_5_STR_ID, _(u"Subtitle five"), _(u"Subtitle five")), HotKey("5", ctrl=True)) application.actionController.register( PolyAction(application, HEADING_6_STR_ID, _(u"Subtitle six"), _(u"Subtitle six")), HotKey("6", ctrl=True)) # Разное application.actionController.register( PolyAction(application, ANCHOR_STR_ID, _(u"Anchor"), _(u"Anchor")), HotKey("N", ctrl=True, alt=True)) application.actionController.register( PolyAction(application, HORLINE_STR_ID, _(u"Horizontal rule"), _(u"Horizontal rule")), HotKey("H", ctrl=True, shift=True)) application.actionController.register( PolyAction(application, LINK_STR_ID, _(u"Link"), _(u"Insert Link")), HotKey("L", ctrl=True)) application.actionController.register( PolyAction(application, QUOTE_STR_ID, _(u"Quote"), _(u"Insert a quote block")), HotKey("Q", ctrl=True, alt=True)) application.actionController.register( PolyAction(application, IMAGE_STR_ID, _(u"Image"), _(u"Insert image")), HotKey("M", ctrl=True)) application.actionController.register( PolyAction(application, MARK_STR_ID, _(u"Mark"), _(u"Mark text")), HotKey("M", ctrl=True, shift=True)) # Списки application.actionController.register( PolyAction(application, LIST_BULLETS_STR_ID, _(u"Bullets list"), _(u"Insert a bullets list")), HotKey("G", ctrl=True)) application.actionController.register( PolyAction(application, LIST_NUMBERS_STR_ID, _(u"Numbers list"), _(u"Insert a numbers list")), HotKey("J", ctrl=True)) application.actionController.register( PolyAction(application, LINE_BREAK_STR_ID, _(u"Line break"), _(u"Insert a line break")), HotKey("Return", ctrl=True)) application.actionController.register( PolyAction(application, HTML_ESCAPE_STR_ID, _(u"Convert HTML Symbols"), _(u"Convert HTML Symbols")), None) # Таблицы application.actionController.register( PolyAction(application, TABLE_STR_ID, _(u"Table"), _(u"Insert a table")), HotKey("Q", ctrl=True)) application.actionController.register( PolyAction(application, TABLE_ROW_STR_ID, _(u"Table rows"), _(u"Insert table rows")), HotKey("W", ctrl=True)) application.actionController.register( PolyAction(application, TABLE_CELL_STR_ID, _(u"Table cell"), _(u"Insert a table cell")), HotKey("Y", ctrl=True, shift=True)) application.actionController.register( PolyAction(application, CURRENT_DATE, _(u"Current date"), _(u"Insert the current date")), None) application.actionController.register( PolyAction(application, SPELL_ON_OFF_ID, _(u"Spell checking"), _(u"Enable / disable spell checking")), HotKey("F7"))