diff options
author | Anton Khirnov <wyskas@gmail.com> | 2008-12-17 20:48:52 +0100 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2008-12-17 20:48:52 +0100 |
commit | 4942e2f39fc9dc61745c952f0ddef6804351398f (patch) | |
tree | 20b28f22ca8b9290d690aad2c1653a25d51a75ad /plugins/Shortcuts.py | |
parent | 6ff27d9b54cb75d041bd18589a1c6b5f606d51c3 (diff) |
get rid of tabs
Diffstat (limited to 'plugins/Shortcuts.py')
-rw-r--r-- | plugins/Shortcuts.py | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/plugins/Shortcuts.py b/plugins/Shortcuts.py index baa462f..e76078f 100644 --- a/plugins/Shortcuts.py +++ b/plugins/Shortcuts.py @@ -6,81 +6,81 @@ from misc import * import format class pluginShortcuts(Plugin): - keys=None - col=None - actionPrefix=None - def __init__(self, winMain): - Plugin.__init__(self, winMain, 'Shortcuts') + keys=None + col=None + actionPrefix=None + def __init__(self, winMain): + Plugin.__init__(self, winMain, 'Shortcuts') - def _load(self): - winMain=self.getWinMain() - # Note people wanting to implement global shortcuts in KDE4 (and sniffing through - # this code): one needs to have a KApplication running, else shortcuts will fail - self.col=kdeui.KActionCollection(None) - self.col.addAssociatedWidget(winMain) - self.keys=[ - ['toggleplay', QtCore.Qt.META+QtCore.Qt.Key_Home, self.togglePlay], - ['volumeup', QtCore.Qt.META+QtCore.Qt.Key_PageDown, lambda b: monty.setVolume(monty.getVolume()-5)], - ['volumedown', QtCore.Qt.META+QtCore.Qt.Key_PageUp, lambda b: monty.setVolume(monty.getVolume()+5)], - ['playnext', QtCore.Qt.META+QtCore.Qt.Key_Right, monty.next], - ['playprevious', QtCore.Qt.META+QtCore.Qt.Key_Left, monty.previous], - ['showosd', QtCore.Qt.META+QtCore.Qt.Key_O, self.showOSD], - ['togglewin', QtCore.Qt.META+QtCore.Qt.Key_P, self.toggleWinMain], - ] - # Note: don't use any non-alphanumerics in the prefix, as else it won't work - self.actionPrefix="shortcuts" - - for entry in self.keys: - name=entry[0] - key=entry[1] - callback=entry[2] - - self.debug("%s - %s"%(name, QtGui.QKeySequence(key).toString())) - - action=kdeui.KAction(winMain) # winMain needed - action.setText(name) - action.setObjectName(name) - action.setGlobalShortcut(kdeui.KShortcut(key)) - QtCore.QObject.connect(action, QtCore.SIGNAL('triggered(bool)'), callback) - self.col.addAction("%s%s"%(self.actionPrefix, action.objectName()), action) - def _unload(self): - actions=self.col.actions() - for action in actions: - try: - if action.objectName()[0:len(self.actionPrefix)]==self.actionPrefix: - self.debug("removing %s"%(action.objectName())) - self.col.removeAction(action) - except Exception, e: - self.important(str(e)) - - def getInfo(self): - return "Shortcuts for mpd." + def _load(self): + winMain=self.getWinMain() + # Note people wanting to implement global shortcuts in KDE4 (and sniffing through + # this code): one needs to have a KApplication running, else shortcuts will fail + self.col=kdeui.KActionCollection(None) + self.col.addAssociatedWidget(winMain) + self.keys=[ + ['toggleplay', QtCore.Qt.META+QtCore.Qt.Key_Home, self.togglePlay], + ['volumeup', QtCore.Qt.META+QtCore.Qt.Key_PageDown, lambda b: monty.setVolume(monty.getVolume()-5)], + ['volumedown', QtCore.Qt.META+QtCore.Qt.Key_PageUp, lambda b: monty.setVolume(monty.getVolume()+5)], + ['playnext', QtCore.Qt.META+QtCore.Qt.Key_Right, monty.next], + ['playprevious', QtCore.Qt.META+QtCore.Qt.Key_Left, monty.previous], + ['showosd', QtCore.Qt.META+QtCore.Qt.Key_O, self.showOSD], + ['togglewin', QtCore.Qt.META+QtCore.Qt.Key_P, self.toggleWinMain], + ] + # Note: don't use any non-alphanumerics in the prefix, as else it won't work + self.actionPrefix="shortcuts" + + for entry in self.keys: + name=entry[0] + key=entry[1] + callback=entry[2] + + self.debug("%s - %s"%(name, QtGui.QKeySequence(key).toString())) + + action=kdeui.KAction(winMain) # winMain needed + action.setText(name) + action.setObjectName(name) + action.setGlobalShortcut(kdeui.KShortcut(key)) + QtCore.QObject.connect(action, QtCore.SIGNAL('triggered(bool)'), callback) + self.col.addAction("%s%s"%(self.actionPrefix, action.objectName()), action) + def _unload(self): + actions=self.col.actions() + for action in actions: + try: + if action.objectName()[0:len(self.actionPrefix)]==self.actionPrefix: + self.debug("removing %s"%(action.objectName())) + self.col.removeAction(action) + except Exception, e: + self.important(str(e)) + + def getInfo(self): + return "Shortcuts for mpd." - def showOSD(self, b): - plugins.getPlugin('notify').onSongChange(None) + def showOSD(self, b): + plugins.getPlugin('notify').onSongChange(None) - def togglePlay(self, btns=None, mods=None): - if monty.isPlaying(): - monty.pause() - else: - monty.resume() - - def toggleWinMain(self, b): - w=self.getWinMain() - if w.isVisible(): - w.setVisible(False) - else: - w.setVisible(True) - - def _getSettings(self): - txt=QtGui.QTextEdit() - txt.setReadOnly(True) - txt.insertPlainText("Keybindings (read-only)\n") - for entry in self.keys: - name=entry[0] - key=entry[1] - - txt.insertPlainText("%s\t%s\n"%(name, QtGui.QKeySequence(key).toString())) - return [ - ['', 'Keybindings', 'Current keybindings', txt], - ] + def togglePlay(self, btns=None, mods=None): + if monty.isPlaying(): + monty.pause() + else: + monty.resume() + + def toggleWinMain(self, b): + w=self.getWinMain() + if w.isVisible(): + w.setVisible(False) + else: + w.setVisible(True) + + def _getSettings(self): + txt=QtGui.QTextEdit() + txt.setReadOnly(True) + txt.insertPlainText("Keybindings (read-only)\n") + for entry in self.keys: + name=entry[0] + key=entry[1] + + txt.insertPlainText("%s\t%s\n"%(name, QtGui.QKeySequence(key).toString())) + return [ + ['', 'Keybindings', 'Current keybindings', txt], + ] |