def __init__(self): QObject.__init__(self) self.invalidate = QAction("invalidate_deleted", self) self.invalidate.setText("Grey out deleted songs") self.invalidate.connect("activated()", self.grey_out_activated) self.delete = QAction("remove_deleted", self) self.delete.setText("Remove deleted songs") self.delete.connect("activated()", self.delete_activated) clementine.ui.AddAction('playlist_menu', self.invalidate) clementine.ui.AddAction('playlist_menu', self.delete)
def __init__(self): QObject.__init__(self) # Generate colors self.colors = [] for hue in xrange(0, 255, 30): self.colors.append(QColor.fromHsv(hue, 255, 255, 96)) self.action = QAction("rainbowize_playlist", self) self.action.setText("Rainbowize!") self.action.setCheckable(True) self.action.connect("changed()", self.rainbowize) clementine.ui.AddAction('playlist_menu', self.action)
def connect_wrap(signal, response): """Helper function to connect a Qt or Mari signal to a Python callable. If the signal connection fails, make sure the signal and response are of the correct types and take compatible parameters. @param signal: A signal (event) to connect with a function call. @param response: A Python callable object, such as a function, to call when the signal is triggered. @raise TypeError: Raised if one of the parameters is of the wrong type. @return: True or False to indicate whether the connection succeeded. """ if not callable(response): raise TypeError(str(response) + " is not callable.") Result = False # PySide version if hasattr(signal, "connect"): Result = signal.connect(response) # Old PySide version if hasattr(signal, "__self__"): Result = QObject.connect(signal.__self__, signal.__name__, response) if Result == False: mari.app.log("Failed to connect {0}.{1} to {2}".format( signal.__self__, signal.__name__, response)) return Result
def connect_wrap(signal, response): """Helper function to connect a Qt or Mari signal to a Python callable. If the signal connection fails, make sure the signal and response are of the correct types and take compatible parameters. @param signal: A signal (event) to connect with a function call. @param response: A Python callable object, such as a function, to call when the signal is triggered. @raise TypeError: Raised if one of the parameters is of the wrong type. @return: True or False to indicate whether the connection succeeded. """ if not callable(response): raise TypeError(str(response) + " is not callable.") Result = False # PySide version if hasattr(signal, "connect"): Result = signal.connect(response) # Old PySide version if hasattr(signal, "__self__"): Result = QObject.connect(signal.__self__, signal.__name__, response) if Result==False: mari.app.log("Failed to connect {0}.{1} to {2}".format(signal.__self__, signal.__name__, response)) return Result