Esempio n. 1
0
    def testToFromSetting(self):
        i1 = ItemId("Blah")
        setting = i1.toSetting()
        self.assertIsNotNone(setting)

        # [...]

        i2 = ItemId.fromSetting(setting)
        self.assertEqual(i1.name, i2.name, "'{}' and restored '{}' do not match".format(
            i1.name, i2.name))
Esempio n. 2
0
    def testCompareIdsById(self):
        a = ItemId("Foo")
        b = ItemId("Foo")
        print(a.uniqueIdentifier, b.uniqueIdentifier)
        self.assertTrue(a == b)
        self.assertFalse(a != b)

        setting = a.toSetting()
        c = ItemId.fromSetting(setting)

        self.assertTrue(a == c)
Esempio n. 3
0
    def registerAction(self, action, actionId: ItemId, context: IContext, scriptable: bool) -> Command:
        """Makes a shortcut known to the system under the specified id.
        Returns a command object that represents the shortcut in the application and is
        owned by the ActionManager. You can register several shortcuts with the
        same id as long as the context is different. In this case
        a trigger of the actual shortcut is forwarded to the registered QShortcut
        for the currently active context.
        A scriptable shortcut can be called from a script without the need for the user
        to interact with it."""

        a = self.__overridableAction(actionId)
        if a is not None:
            a.addOverrideAction(action, context, scriptable)
            self.instance.commandListChanged.emit()
            self.instance.commandAdded(actionId.toSetting())
        return a
Esempio n. 4
0
 def testToSetting(self):
     i = ItemId("Foo")
     self.assertEqual(i.toSetting(), "Foo")