예제 #1
0
 def saveHotKeys(self):
     """
     Сохранить все горячие клавиши в конфиг
     """
     for actionInfo in self._actionsInfo.values():
         option = HotKeyOption(self._config, self.configSection,
                               actionInfo.action.stringId, None)
         option.value = actionInfo.hotkey
예제 #2
0
 def saveHotKeys (self):
     """
     Сохранить все горячие клавиши в конфиг
     """
     for actionInfo in self._actionsInfo.values():
         option = HotKeyOption (self._config,
             self.configSection,
             actionInfo.action.strid,
             None)
         option.value = actionInfo.hotkey
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
 def _getHotKeyForAction(self, action, defaultHotKey):
     """
     Получить горячую клавишу.
     Горячая клавиша берется из конфига, или defaultHotKey
     """
     return HotKeyOption(self._config, self.configSection, action.stringId,
                         defaultHotKey).value
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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)
예제 #10
0
    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)