Ejemplo n.º 1
0
 def action(self, arg):
     filename = arg
     modname = os.path.splitext(os.path.basename(filename))[0]
     with open(filename, 'rb') as f:
         c = imp.load_module(modname, f, filename,
                             ('.py', 'rb', imp.PY_SOURCE))
     qmk.CommandManager().registerCommands(c.commands())
     qmk.CommandInput().updateCompletions()
Ejemplo n.º 2
0
 def action(self, arg):
     # For now, ignore help requests for specific commands.
     # if arg is not None: pass
     f = file(self.__filename, 'wb')
     f.write('<html><head><title>QMK Help</title></head><body>')
     f.write('<h1>QMK Command Help</h1>')
     cm = qmk.CommandManager()
     f.write('<table border="1"><tr><th>Name</th><th>Help</th></tr>')
     for name in cm.commandNames():
         cmd = cm.command(name)
         ht = cmd.help
         f.write('<tr><td><pre>%s</pre></td><td><pre>%s</pre></td></tr>' %
                 (name, ht.encode('ascii', 'xmlcharrefreplace')))
     f.write('</table></body></html>\n')
     f.close()
     webbrowser.open_new_tab('file:%s' % urllib.pathname2url(f.name))
Ejemplo n.º 3
0
def register_commands(cmds):
    for t in cmds:
        basedir = t[0]
        if not basedir:
            basedir = os.path.join(qmk.base_dir(), 'commands')

        if not t[1]:
            files = glob.glob(os.path.join(basedir, '*.py'))
        else:
            files = [os.path.join(basedir, x) for x in t[1]]

        for fn in files:
            with open(fn, 'rb') as f:
                qmk.CommandManager().registerCommands(
                    imp.load_module(
                        os.path.splitext(os.path.basename(fn))[0], f, fn,
                        modloadtuple).commands())
Ejemplo n.º 4
0
def _quit():
    qmk.CommandManager().shutdownCommands()
    qmk.QtGui.qApp.quit()
Ejemplo n.º 5
0
    border-color: #00ff00;
}
QListView {
    background-color: #004b00;
    color: #00ff00;
    border-width: 2px;
    border-style: solid;
    border-color: #00ff00;
    border-radius: 5px;
    font-size: 18px;
    font-family: "Ubuntu Mono";
}
''')
# }}}

qmk.CommandManager().registerCommands([QuitCommand(), RestartCommand()])
qmk.CommandInput().updateCompletions()

qmk.InputFilter().setQMKKeyboardCallback(qmk.Engine.QMKCallback)
qmk.InputFilter().enableQMKKeyboardCallback()
qmk.InputFilter().setKeyboardCallback(qmk.Engine.hideMessageCallback)
qmk.InputFilter().setMouseCallback(qmk.Engine.hideMessageCallback)
qmk.InputFilter().setKeyboardWindowId(int(qmk.CommandInput().winId()))

os.chdir(qmk.base_dir())

qmk.Message()('QMK has started...')
# Instantiate ErrorMessage in case it's eventually called from another thread
# to avoid parental confusion.
qmk.ErrorMessage()