def saveHotKeys(self): """ Сохранить все горячие клавиши в конфиг """ for actionInfo in self._actionsInfo.values(): option = HotKeyOption(self._config, self.configSection, actionInfo.action.stringId, None) option.value = actionInfo.hotkey
def saveHotKeys (self): """ Сохранить все горячие клавиши в конфиг """ for actionInfo in self._actionsInfo.values(): option = HotKeyOption (self._config, self.configSection, actionInfo.action.strid, None) option.value = actionInfo.hotkey
def testHotKeyWrite2(self): config = Config(self.path) section = "TestHotKey" paramName = "MyHotKey" option = HotKeyOption(config, section, paramName, None) option.value = None with open(self.path) as fp: resultFile = fp.read() self.assertTrue("[TestHotKey]" in resultFile) self.assertTrue("myhotkey =" in resultFile)
def testHotKeyWrite1(self): config = Config(self.path) hotkey = HotKey("F11", ctrl=True) section = "TestHotKey" paramName = "MyHotKey" option = HotKeyOption(config, section, paramName, None) option.value = hotkey with open(self.path) as fp: resultFile = fp.read() self.assertTrue("[TestHotKey]" in resultFile) self.assertTrue("myhotkey = Ctrl+F11" in resultFile)
def _getHotKeyForAction(self, action, defaultHotKey): """ Получить горячую клавишу. Горячая клавиша берется из конфига, или defaultHotKey """ return HotKeyOption(self._config, self.configSection, action.stringId, defaultHotKey).value
def testHotKeyOptionEmptyConfig(self): config = Config(self.path) hotKeyDefault = HotKey("F11", ctrl=True) section = "TestHotKey" paramName = "MyHotKey" option = HotKeyOption(config, section, paramName, hotKeyDefault) self.assertEqual(option.value, hotKeyDefault)
def testReadOption3(self): with open(self.path, "w") as fp: fp.write("""[TestHotKey] MyHotKey=Ctrl+""") config = Config(self.path) section = "TestHotKey" paramName = "MyHotKey" option = HotKeyOption(config, section, paramName, None) result = option.value self.assertEqual(result, None)
def testReadOption4(self): with open(self.path, "w") as fp: fp.write("""[TestHotKey] MyHotKey=Ctrl+DEL""") config = Config(self.path) section = "TestHotKey" paramName = "MyHotKey2" hotKeyDefault = HotKey("F11", ctrl=True) option = HotKeyOption(config, section, paramName, hotKeyDefault) result = option.value self.assertEqual(result, hotKeyDefault)
def testHotKeyLoadConfig(self): action = TestAction() hotKeyFromConfig = HotKey("F11") HotKeyOption(Application.config, self.actionController.configSection, action.stringId, None).value = hotKeyFromConfig self.actionController.register(action, HotKey("F12", ctrl=True)) self.assertEqual( self.actionController.getHotKey(action.stringId).key, "F11") self.assertFalse(self.actionController.getHotKey(action.stringId).ctrl) self.assertFalse( self.actionController.getHotKey(action.stringId).shift) self.assertFalse(self.actionController.getHotKey(action.stringId).alt)
def testReadOption1(self): with open(self.path, "w") as fp: fp.write("""[TestHotKey] MyHotKey=Ctrl+T""") config = Config(self.path) section = "TestHotKey" paramName = "MyHotKey" option = HotKeyOption(config, section, paramName, None) result = option.value self.assertNotEqual(result, None) self.assertEqual(result.key, "T") self.assertTrue(result.ctrl) self.assertFalse(result.alt) self.assertFalse(result.shift)