diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-08-21 13:40:16 +0200 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-08-21 14:54:50 +0200 |
commit | 0e23f7776fd104d8713cb705438c21559addc1d9 (patch) | |
tree | fb3303d6f6a0c86ac92febca1dd827c2218c60c7 | |
parent | 4636982682d69c0fc5fea724344f02c94c6cb741 (diff) |
switch to new-style PyQt4 signals.
-rw-r--r-- | nephilim/common.py | 7 | ||||
-rw-r--r-- | nephilim/mpclient.py | 37 | ||||
-rw-r--r-- | nephilim/nephilim_app.py | 4 | ||||
-rw-r--r-- | nephilim/plugin.py | 4 | ||||
-rw-r--r-- | nephilim/plugins/AlbumCover.py | 32 | ||||
-rw-r--r-- | nephilim/plugins/Filebrowser.py | 6 | ||||
-rw-r--r-- | nephilim/plugins/Library.py | 14 | ||||
-rw-r--r-- | nephilim/plugins/Lyrics.py | 13 | ||||
-rw-r--r-- | nephilim/plugins/Notify.py | 43 | ||||
-rw-r--r-- | nephilim/plugins/PlayControl.py | 24 | ||||
-rw-r--r-- | nephilim/plugins/Playlist.py | 7 | ||||
-rw-r--r-- | nephilim/plugins/Songinfo.py | 2 | ||||
-rw-r--r-- | nephilim/plugins/Systray.py | 9 | ||||
-rw-r--r-- | nephilim/settings_wg.py | 8 | ||||
-rw-r--r-- | nephilim/winMain.py | 12 |
15 files changed, 113 insertions, 109 deletions
diff --git a/nephilim/common.py b/nephilim/common.py index d4d7b47..906310f 100644 --- a/nephilim/common.py +++ b/nephilim/common.py @@ -41,7 +41,7 @@ class Button(QtGui.QPushButton): QtGui.QPushButton.__init__(self, parent) if onClick: - self.connect(self, QtCore.SIGNAL('clicked(bool)'), onClick) + self.clicked.connect(onClick) if iconPath: self.changeIcon(iconPath) @@ -98,6 +98,9 @@ class MetadataFetcher(QtCore.QObject): mrep = None # metadata page NetworkReply song = None # current song + # SIGNALS + finished = QtCore.pyqtSignal(['song', 'metadata']) + #### private #### def __init__(self, plugin): QtCore.QObject.__init__(self, plugin) @@ -126,7 +129,7 @@ class MetadataFetcher(QtCore.QObject): Feel free to reimplement/not use it.""" self.srep = None self.mrep = None - self.emit(QtCore.SIGNAL('finished'), self.song, metadata) + self.finished.emit(self.song, metadata) self.song = None #### public #### diff --git a/nephilim/mpclient.py b/nephilim/mpclient.py index ef8a4d0..ba3fd49 100644 --- a/nephilim/mpclient.py +++ b/nephilim/mpclient.py @@ -44,6 +44,19 @@ class MPClient(QtCore.QObject): logger = None + # SIGNALS + connect_changed = QtCore.pyqtSignal(bool) + db_updated = QtCore.pyqtSignal() + song_changed = QtCore.pyqtSignal(str) + time_changed = QtCore.pyqtSignal(int) + state_changed = QtCore.pyqtSignal(str) + volume_changed = QtCore.pyqtSignal(int) + repeat_changed = QtCore.pyqtSignal(bool) + random_changed = QtCore.pyqtSignal(bool) + single_changed = QtCore.pyqtSignal(bool) + consume_changed = QtCore.pyqtSignal(bool) + playlist_changed = QtCore.pyqtSignal() + def __init__(self): QtCore.QObject.__init__(self) self._cur_lib = [] @@ -84,7 +97,7 @@ class MPClient(QtCore.QObject): self._db_update = self.stats()['db_update'] self.emit(QtCore.SIGNAL('connected')) #should be removed - self.emit(QtCore.SIGNAL('connect_changed'), True) + self.connect_changed.emit(True) self.logger.info('Successfully connected to MPD.') self._timer_id = self.startTimer(500) self._db_timer_id = self.startTimer(10000) @@ -114,7 +127,7 @@ class MPClient(QtCore.QObject): self._cur_playlist = [] self._commands = [] self.emit(QtCore.SIGNAL('disconnected')) #should be removed - self.emit(QtCore.SIGNAL('connect_changed'), False) + self.connect_changed.emit(False) self.logger.info('Disconnected from MPD.') def password(self, password): """Use the password to authenticate with MPD.""" @@ -408,7 +421,7 @@ class MPClient(QtCore.QObject): self.logger.info('Database updated.') self._db_update = db_update self._update_lib() - self.emit(QtCore.SIGNAL('db_updated')) + self.db_updated.emit() return @@ -421,29 +434,29 @@ class MPClient(QtCore.QObject): self._update_current_song() if self._status['songid'] != old_status['songid']: - self.emit(QtCore.SIGNAL('song_changed'), self._status['songid']) + self.song_changed.emit(self._status['songid']) if self._status['time'] != old_status['time']: - self.emit(QtCore.SIGNAL('time_changed'), self._status['time']) + self.time_changed.emit(self._status['time']) if self._status['state'] != old_status['state']: - self.emit(QtCore.SIGNAL('state_changed'), self._status['state']) + self.state_changed.emit(self._status['state']) if self._status['volume'] != old_status['volume']: - self.emit(QtCore.SIGNAL('volume_changed'), int(self._status['volume'])) + self.volume_changed.emit( int(self._status['volume'])) if self._status['repeat'] != old_status['repeat']: - self.emit(QtCore.SIGNAL('repeat_changed'), bool(self._status['repeat'])) + self.repeat_changed.emit(bool(self._status['repeat'])) if self._status['random'] != old_status['random']: - self.emit(QtCore.SIGNAL('random_changed'), bool(self._status['random'])) + self.random_changed.emit(bool(self._status['random'])) if self._status['single'] != old_status['single']: - self.emit(QtCore.SIGNAL('single_changed'), bool(self._status['single'])) + self.single_changed.emit(bool(self._status['single'])) if self._status['consume'] != old_status['consume']: - self.emit(QtCore.SIGNAL('consume_changed'), bool(self._status['consume'])) + self.consume_changed.emit(bool(self._status['consume'])) if self._status['playlist'] != old_status['playlist']: self._update_playlist() - self.emit(QtCore.SIGNAL('playlist_changed')) + self.playlist_changed.emit() diff --git a/nephilim/nephilim_app.py b/nephilim/nephilim_app.py index ad340da..3e9b197 100644 --- a/nephilim/nephilim_app.py +++ b/nephilim/nephilim_app.py @@ -70,7 +70,7 @@ class NephilimApp(QtGui.QApplication): if self.settings.value(plugin.name + '/load', QtCore.QVariant(True)).toBool(): self.plugins.load(plugin.name) - self.connect(self, QtCore.SIGNAL('aboutToQuit()'), self.__cleanup) + self.aboutToQuit.connect(self.__cleanup) if show_settings: @@ -92,7 +92,7 @@ class NephilimApp(QtGui.QApplication): if not self.__settings_win: self.__settings_win = SettingsWidget(self.mpclient, self.plugins) - self.connect(self.__settings_win, QtCore.SIGNAL('destroyed()'), self.__del_settings_win) + self.__settings_win.destroyed.connect(self.__del_settings_win) self.__settings_win.show() self.__settings_win.raise_() def show_connect_win(self): diff --git a/nephilim/plugin.py b/nephilim/plugin.py index fd521f0..d4bad03 100644 --- a/nephilim/plugin.py +++ b/nephilim/plugin.py @@ -69,7 +69,7 @@ class Plugin(QtCore.QObject): opts = QtGui.QDockWidget.DockWidgetClosable|QtGui.QDockWidget.DockWidgetMovable QtGui.QApplication.instance().main_win.add_dock(self.get_dock_widget(opts)) QtGui.QApplication.instance().main_win.restore_layout() - self.connect(self.mpclient, QtCore.SIGNAL('connect_changed'), self.set_enabled) + self.mpclient.connect_changed.connect(self.set_enabled) self.loaded = True def unload(self): if not self.loaded: @@ -81,7 +81,7 @@ class Plugin(QtCore.QObject): QtGui.QApplication.instance().main_win.remove_dock(dock_widget) self._dock_widget = None self.settingsWidget = None - self.disconnect(self.mpclient, QtCore.SIGNAL('connect_changed'), self.set_enabled) + self.mpclient.connect_changed.disconnect(self.set_enabled) self.loaded = False def set_enabled(self, val): if self.o: diff --git a/nephilim/plugins/AlbumCover.py b/nephilim/plugins/AlbumCover.py index f54b101..5250e1e 100644 --- a/nephilim/plugins/AlbumCover.py +++ b/nephilim/plugins/AlbumCover.py @@ -60,7 +60,7 @@ class AlbumCoverWidget(QtGui.QLabel): self.cover = None self.cover_loaded = False self.setPixmap(QtGui.QPixmap('gfx/no-cd-cover.png')) - self.plugin.emit(QtCore.SIGNAL('cover_changed'), None) + self.plugin.cover_changed.emit(QtGui.QPixmap()) return if song != self.plugin.mpclient.current_song(): @@ -69,7 +69,7 @@ class AlbumCoverWidget(QtGui.QLabel): self.cover = cover self.cover_loaded = True self.setPixmap(self.cover.scaled(self.size(), QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)) - self.plugin.emit(QtCore.SIGNAL('cover_changed'), self.cover) + self.plugin.cover_changed.emit(self.cover) self.logger.info('Cover set.') def __view_cover(self): @@ -112,6 +112,9 @@ class AlbumCover(Plugin): __cover_dir = None __cover_path = None + # SIGNALS + cover_changed = QtCore.pyqtSignal(QtGui.QPixmap) + #### private #### def __init__(self, parent, mpclient, name): Plugin.__init__(self, parent, mpclient, name) @@ -212,7 +215,7 @@ class AlbumCover(Plugin): ('artist', song.artist()), ('album', song.album())]) self.fetch2(song, url) - self.connect(self.srep, QtCore.SIGNAL('finished()'), self.__handle_search_res) + self.srep.finished.connect(self.__handle_search_res) def __handle_search_res(self): url = None @@ -233,7 +236,7 @@ class AlbumCover(Plugin): self.logger.info('Found %s song URL: %s.'%(self.name, url)) self.mrep = self.nam.get(QtNetwork.QNetworkRequest(url)) - self.connect(self.mrep, QtCore.SIGNAL('finished()'), self.__handle_cover) + self.mrep.finished.connect(self.__handle_cover) def __handle_cover(self): data = self.mrep.readAll() @@ -245,10 +248,14 @@ class AlbumCover(Plugin): class FetcherLocal(QtCore.QObject): """This fetcher tries to find cover files in the same directory as current song.""" + #public, read-only name = 'local' logger = None settings = None + # SIGNALS + finished = QtCore.pyqtSignal('song', 'metadata') + def __init__(self, plugin): QtCore.QObject.__init__(self, plugin) self.logger = plugin.logger @@ -272,7 +279,7 @@ class AlbumCover(Plugin): os.path.dirname(song.filepath()))) if not dir: self.logger.error('Error opening directory' + self.__cover_dir) - return self.emit(QtCore.SIGNAL('finished'), song, None) + return self.finished.emit(song, None) dir.setNameFilters(filter) files = dir.entryList() @@ -280,7 +287,7 @@ class AlbumCover(Plugin): cover = QtGui.QPixmap(dir.filePath(files[0])) if not cover.isNull(): self.logger.info('Found a cover: %s'%dir.filePath(files[0])) - return self.emit(QtCore.SIGNAL('finished'), song, cover) + return self.finished.emit(song, cover) # if this failed, try any supported image dir.setNameFilters(exts) @@ -289,21 +296,18 @@ class AlbumCover(Plugin): cover = QtGui.QPixmap(dir.filePath(files[0])) if not cover.isNull(): self.logger.info('Found a cover: %s'%dir.filePath(files[0])) - return self.emit(QtCore.SIGNAL('finished'), song, cover) + return self.finished.emit(song, cover) self.logger.info('No matching cover found') - self.emit(QtCore.SIGNAL('finished'), song, None) + self.finished.emit(song, None) #### public #### def _load(self): self.o = AlbumCoverWidget(self) - self.connect(self.mpclient, QtCore.SIGNAL('song_changed'), self.refresh) - self.connect(self.mpclient, QtCore.SIGNAL('disconnected'), self.refresh) + self.mpclient.song_changed.connect(self.refresh) self.refresh_fetchers() def _unload(self): self.o = None - self.disconnect(self.mpclient, QtCore.SIGNAL('song_changed'), self.refresh) - self.disconnect(self.mpclient, QtCore.SIGNAL('disconnected'), self.refresh) - self.disconnect(self.mpclient, QtCore.SIGNAL('state_changed'),self.refresh) + self.mpclient.song_changed.disconnect(self.refresh) def info(self): return "Display the album cover of the currently playing album." @@ -340,7 +344,7 @@ class AlbumCover(Plugin): for site in self.available_fetchers: if site.name == name: self.__fetchers.append(site(self)) - self.connect(self.__fetchers[-1], QtCore.SIGNAL('finished'), self.__new_cover_fetched) + self.__fetchers[-1].finished.connect(self.__new_cover_fetched) def save_cover_file(self, cover, path = None): """Save cover to a file specified in path. diff --git a/nephilim/plugins/Filebrowser.py b/nephilim/plugins/Filebrowser.py index a566489..925468a 100644 --- a/nephilim/plugins/Filebrowser.py +++ b/nephilim/plugins/Filebrowser.py @@ -63,7 +63,7 @@ class wgFilebrowser(QtGui.QWidget): self.menu.addAction('***EXPERIMENTAL DON\'T USE*** &Copy to collection.', self.selection_copy_to_collection) self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - self.connect(self, QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), self.show_context_menu) + self.customContextMenuRequested.connect(self.show_context_menu) def show_context_menu(self, pos): if not self.indexAt(pos).isValid(): @@ -112,10 +112,10 @@ class wgFilebrowser(QtGui.QWidget): self.model.setSorting(QtCore.QDir.DirsFirst) self.view = self.FileView(self.model, self.plugin) - self.connect(self.view, QtCore.SIGNAL('activated(const QModelIndex&)'), self.item_activated) + self.view.activated.connect(self.item_activated) self.path = QtGui.QLineEdit(self.model.filePath(self.view.rootIndex())) - self.connect(self.path, QtCore.SIGNAL('returnPressed()'), self.path_changed) + self.path.returnPressed.connect(self.path_changed) self.setLayout(QtGui.QVBoxLayout()) self.layout().setSpacing(0) diff --git a/nephilim/plugins/Library.py b/nephilim/plugins/Library.py index 35c6015..b2a4ed7 100644 --- a/nephilim/plugins/Library.py +++ b/nephilim/plugins/Library.py @@ -134,12 +134,11 @@ class LibraryWidget(QtGui.QWidget): self.modes = QtGui.QComboBox() self.refresh_modes() - self.connect(self.modes, QtCore.SIGNAL('activated(int)'), self.modes_activated) + self.modes.activated.connect(self.modes_activated) self.search_txt = QtGui.QLineEdit() - self.connect(self.search_txt, QtCore.SIGNAL('textChanged(const QString&)'), - self.filter_changed) - self.connect(self.search_txt, QtCore.SIGNAL('returnPressed()'), self.add_filtered) + self.search_txt.textChanged.connect(self.filter_changed) + self.search_txt.returnPressed.connect(self.add_filtered) #construct the library self.library_model = self.LibraryModel() @@ -147,7 +146,7 @@ class LibraryWidget(QtGui.QWidget): self.library_view = self.LibraryView() self.library_view.setModel(self.library_model) - self.connect(self.library_view, QtCore.SIGNAL('activated(const QModelIndex &)'), self.add_selection) + self.library_view.activated.connect(self.add_selection) self.setLayout(QtGui.QVBoxLayout()) self.layout().setSpacing(2) @@ -156,9 +155,8 @@ class LibraryWidget(QtGui.QWidget): self.layout().addWidget(self.search_txt) self.layout().addWidget(self.library_view) - self.connect(self.plugin.mpclient, QtCore.SIGNAL('connected'), self.fill_library) - self.connect(self.plugin.mpclient, QtCore.SIGNAL('disconnected'), self.fill_library) - self.connect(self.plugin.mpclient, QtCore.SIGNAL('db_updated'), self.fill_library) + self.plugin.mpclient.connect_changed.connect(self.fill_library) + self.plugin.mpclient.connect_changed.connect(self.fill_library) def refresh_modes(self): self.modes.clear() diff --git a/nephilim/plugins/Lyrics.py b/nephilim/plugins/Lyrics.py index 15160d8..1a88dd1 100644 --- a/nephilim/plugins/Lyrics.py +++ b/nephilim/plugins/Lyrics.py @@ -59,7 +59,7 @@ class LyricsWidget(QtGui.QWidget): self.__toolbar.addAction(QtGui.QIcon('gfx/refresh.png'), 'Refresh lyrics', self.plugin.refresh) edit = self.__toolbar.addAction(QtGui.QIcon('gfx/edit.png'), 'Edit lyrics') edit.setCheckable(True) - edit.connect(edit, QtCore.SIGNAL('toggled(bool)'), self.__toggle_editable) + edit.toggled.connect(self.__toggle_editable) self.__toolbar.addAction(QtGui.QIcon('gfx/save.png'), 'Save lyrics', self.__save_lyrics) self.__toolbar.addAction(QtGui.QIcon('gfx/delete.png'), 'Delete stored file', self.plugin.del_lyrics_file) @@ -100,7 +100,6 @@ class LyricsWidget(QtGui.QWidget): self.logger.info('Lyrics not found.') self.__text_view.insertPlainText('Lyrics not found.') - class Lyrics(Plugin): # public, read-only o = None @@ -196,7 +195,7 @@ class Lyrics(Plugin): url = QtCore.QUrl('http://www.animelyrics.com/search.php') url.setQueryItems([('t', 'performer'), ('q', song.artist())]) self.fetch2(song, url) - self.connect(self.srep, QtCore.SIGNAL('finished()'), self.__handle_search_res) + self.srep.finished.connect(self.__handle_search_res) def __handle_search_res(self): # TODO use Qt xml functions @@ -217,7 +216,7 @@ class Lyrics(Plugin): self.logger.info('Found Animelyrics song URL: %s.'%url) self.mrep = self.nam.get(QtNetwork.QNetworkRequest(url)) - self.connect(self.mrep, QtCore.SIGNAL('finished()'), self.__handle_lyrics) + self.mrep.finished.connect(self.__handle_lyrics) def __handle_lyrics(self): lyrics = '' @@ -310,11 +309,11 @@ class Lyrics(Plugin): def _load(self): self.refresh_fetchers() self.o = LyricsWidget(self) - self.connect(self.mpclient, QtCore.SIGNAL('song_changed'), self.refresh) + self.mpclient.song_changed.connect(self.refresh) def _unload(self): self.o = None self.__fetchers = None - self.disconnect(self.mpclient, QtCore.SIGNAL('song_changed'), self.refresh) + self.mpclient.song_changed.disconnect(self.refresh) def info(self): return "Show (and fetch) the lyrics of the currently playing song." @@ -389,5 +388,5 @@ class Lyrics(Plugin): for fetcher in self.available_fetchers: if fetcher.name == name: self.__fetchers.append(fetcher(self)) - self.connect(self.__fetchers[-1], QtCore.SIGNAL('finished'), self.__new_lyrics_fetched) + self.__fetchers[-1].finished.connect(self.__new_lyrics_fetched) diff --git a/nephilim/plugins/Notify.py b/nephilim/plugins/Notify.py index d8b26b9..30c6d9b 100644 --- a/nephilim/plugins/Notify.py +++ b/nephilim/plugins/Notify.py @@ -18,17 +18,15 @@ from PyQt4 import QtGui, QtCore from PyQt4.QtCore import QVariant -from traceback import print_exc -from ..common import sec2min, APPNAME, expand_tags +from ..common import sec2min, APPNAME, expand_tags from ..plugin import Plugin -from .. import plugins +from .. import plugins NOTIFY_PRIORITY_SONG = 1 NOTIFY_PRIORITY_VOLUME = 2 class winNotify(QtGui.QWidget): - _timerID = None parent = None p = None @@ -45,7 +43,7 @@ class winNotify(QtGui.QWidget): self.timer = QtCore.QTimer(self) self.timer.setSingleShot(True) - self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.hide) + self.timer.timeout.connect(self._hide) layout = QtGui.QHBoxLayout() self.cover_label = QtGui.QLabel() @@ -65,14 +63,15 @@ class winNotify(QtGui.QWidget): ac = QtGui.QApplication.instance().plugins.plugin('AlbumCover') if ac: - self.connect(ac, QtCore.SIGNAL('cover_changed'), self.on_cover_changed) + ac.cover_changed.connect(self.on_cover_changed) def on_cover_changed(self, cover): - if not cover: + if cover.isNull(): self.cover_label.clear() return self.cover_label.setPixmap(cover.scaledToHeight(self.fontInfo().pixelSize()*4)) + self.resize(self.layout().sizeHint()) def mousePressEvent(self, event): self.hide() @@ -88,10 +87,7 @@ class winNotify(QtGui.QWidget): self.setVisible(True) self.timer.start(time) - def hide(self): - if self._timerID: - self.killTimer(self._timerID) - self._timerID=None + def _hide(self): self.setHidden(True) self._current_priority = -1 @@ -107,18 +103,16 @@ class Notify(Plugin): def _load(self): self.o = winNotify(self) - self.connect(self.mpclient, QtCore.SIGNAL('song_changed'), self.onSongChange) - self.connect(self.mpclient, QtCore.SIGNAL('connected'), self.onConnected) - self.connect(self.mpclient, QtCore.SIGNAL('disconnected'), self.onDisconnect) - self.connect(self.mpclient, QtCore.SIGNAL('state_changed'), self.onStateChange) - self.connect(self.mpclient, QtCore.SIGNAL('volume_changed'),self.onVolumeChange) + self.mpclient.song_changed.connect(self.onSongChange) + self.mpclient.connect_changed.connect(self.on_connect_changed) + self.mpclient.state_changed.connect(self.onStateChange) + self.mpclient.volume_changed.connect (self.onVolumeChange) def _unload(self): self.o=None - self.disconnect(self.mpclient, QtCore.SIGNAL('song_changed'), self.onSongChange) - self.disconnect(self.mpclient, QtCore.SIGNAL('connected'), self.onConnected) - self.disconnect(self.mpclient, QtCore.SIGNAL('disconnected'), self.onDisconnect) - self.disconnect(self.mpclient, QtCore.SIGNAL('state_changed'), self.onStateChange) - self.disconnect(self.mpclient, QtCore.SIGNAL('volume_changed'),self.onVolumeChange) + self.mpclient.song_changed.disconnect(self.onSongChange) + self.mpclient.connect_changed.disconnect(self.on_connect_changed) + self.mpclient.state_changed.disconnect(self.onStateChange) + self.mpclient.volume_changed.disconnect(self.onVolumeChange) def getInfo(self): return "Show interesting events in a popup window." @@ -131,11 +125,8 @@ class Notify(Plugin): NOTIFY_PRIORITY_SONG) self.settings.endGroup() - def onConnected(self): - self.o.show('%s loaded'%APPNAME, self.settings.value(self.name + '/timer').toInt()[0]) - - def onDisconnect(self): - self.o.show('Disconnected!', self.settings.value(self.name + '/timer').toInt()[0]) + def on_connect_changed(self, val): + self.o.show('%s.'%('Connected' if val else 'Disconnected'), self.settings.value(self.name + '/timer').toInt()[0]) def onStateChange(self, new_state): self.o.show(new_state, self.settings.value(self.name + '/timer').toInt()[0]) diff --git a/nephilim/plugins/PlayControl.py b/nephilim/plugins/PlayControl.py index 0784bab..b93dbdc 100644 --- a/nephilim/plugins/PlayControl.py +++ b/nephilim/plugins/PlayControl.py @@ -76,34 +76,34 @@ class wgPlayControl(QtGui.QToolBar): self.addSeparator() self.vol_slider = self.VolumeSlider(self) - self.connect(self.vol_slider, QtCore.SIGNAL('valueChanged(int)'),self.onVolumeSliderChange) + self.vol_slider.valueChanged.connect(self.onVolumeSliderChange) self.addWidget(self.vol_slider) self.addSeparator() self.random = self.addAction(QtGui.QIcon('gfx/media-playlist-shuffle.svgz'), 'random') self.random.setCheckable(True) - self.connect(self.random, QtCore.SIGNAL('toggled(bool)'), self.p.mpclient.random) - self.connect(self.p.mpclient, QtCore.SIGNAL('random_changed'), self.random.setChecked) + self.random.toggled.connect(self.p.mpclient.random) + self.p.mpclient.random_changed.connect(self.random.setChecked) self.repeat = self.addAction(QtGui.QIcon('gfx/media-playlist-repeat.svg'), 'repeat') self.repeat.setCheckable(True) - self.connect(self.p.mpclient, QtCore.SIGNAL('repeat_changed'), self.repeat.setChecked) - self.connect(self.repeat, QtCore.SIGNAL('toggled(bool)'), self.p.mpclient.repeat) + self.p.mpclient.repeat_changed.connect(self.repeat.setChecked) + self.repeat.toggled.connect(self.p.mpclient.repeat) self.single = self.addAction(QtGui.QIcon('gfx/single.png'), 'single mode') self.single.setCheckable(True) - self.connect(self.p.mpclient, QtCore.SIGNAL('single_changed'), self.single.setChecked) - self.connect(self.single, QtCore.SIGNAL('toggled(bool)'), self.p.mpclient.single) + self.p.mpclient.single_changed.connect(self.single.setChecked) + self.single.toggled.connect(self.p.mpclient.single) self.consume = self.addAction(QtGui.QIcon('gfx/consume.png'), 'consume mode') self.consume.setCheckable(True) - self.connect(self.p.mpclient, QtCore.SIGNAL('consume_changed'), self.consume.setChecked) - self.connect(self.consume, QtCore.SIGNAL('toggled(bool)'), self.p.mpclient.consume) + self.p.mpclient.consume_changed.connect(self.consume.setChecked) + self.consume.toggled.connect(self.p.mpclient.consume) - self.connect(self, QtCore.SIGNAL('orientationChanged(Qt::Orientation)'), self.vol_slider.setOrientation) + self.orientationChanged.connect(self.vol_slider.setOrientation) - self.connect(self.p.mpclient, QtCore.SIGNAL('state_changed'), self.onStateChange) - self.connect(self.p.mpclient, QtCore.SIGNAL('volume_changed'), self.onVolumeChange) + self.p.mpclient.state_changed.connect(self.onStateChange) + self.p.mpclient.volume_changed.connect(self.onVolumeChange) def onStateChange(self, new_state): status = self.p.mpclient.status() diff --git a/nephilim/plugins/Playlist.py b/nephilim/plugins/Playlist.py index 085fa84..1f70021 100644 --- a/nephilim/plugins/Playlist.py +++ b/nephilim/plugins/Playlist.py @@ -67,11 +67,10 @@ class PlaylistWidget(QtGui.QWidget): self.setColumnCount(len(columns)) self.setHeaderLabels(columns) self.header().restoreState(self.plugin.settings.value(self.plugin.name + '/header_state').toByteArray()) - self.connect(self, QtCore.SIGNAL('itemActivated(QTreeWidgetItem*, int)'), self._song_activated) - self.connect(self.header(), QtCore.SIGNAL('geometriesChanged()'), self._save_state) + self.itemActivated.connect(self._song_activated) + self.header().geometriesChanged.connect(self._save_state) - self.connect(self.plugin.mpclient, QtCore.SIGNAL('playlist_changed'), self.fill) - self.connect(self.plugin.mpclient, QtCore.SIGNAL('disconnected'), self.fill) + self.plugin.mpclient.playlist_changed.connect(self.fill) def _save_state(self): self.plugin.settings.setValue(self.plugin.name + '/header_state', QVariant(self.header().saveState())) diff --git a/nephilim/plugins/Songinfo.py b/nephilim/plugins/Songinfo.py index 86739e9..6334d67 100644 --- a/nephilim/plugins/Songinfo.py +++ b/nephilim/plugins/Songinfo.py @@ -48,7 +48,7 @@ class SonginfoWidget(QtGui.QWidget): self.labels[item].setWordWrap(True) self.layout().addWidget(self.labels[item]) - self.connect(self.plugin.mpclient, QtCore.SIGNAL('song_changed'), self.on_song_change) + self.plugin.mpclient.song_changed.connect(self.on_song_change) def on_song_change(self): song = self.plugin.mpclient.current_song() diff --git a/nephilim/plugins/Systray.py b/nephilim/plugins/Systray.py index e093c9f..b786d45 100644 --- a/nephilim/plugins/Systray.py +++ b/nephilim/plugins/Systray.py @@ -45,15 +45,12 @@ class Systray(Plugin): self.eventObj=SystrayWheelEventObject() self.eventObj.plugin = self self.o.installEventFilter(self.eventObj) - self.parent().connect(self.o, QtCore.SIGNAL('activated (QSystemTrayIcon::ActivationReason)') - , self.onSysTrayClick) + self.o.activated.connect(self.onSysTrayClick) - self.connect(self.mpclient, QtCore.SIGNAL('song_changed'), self.update) + self.mpclient.song_changed.connect(self.update) self.o.show() def _unload(self): - self.disconnect(self.mpclient, QtCore.SIGNAL('song_changed'), self.update) - self.disconnect(self.mpclient, QtCore.SIGNAL('disconnected'), self.update) - self.disconnect(self.mpclient, QtCore.SIGNAL('time_changed'), self.update) + self.mpclient.song_changed.disconnect(self.update) self.o.hide() self.o.setIcon(QtGui.QIcon(None)) self.o = None diff --git a/nephilim/settings_wg.py b/nephilim/settings_wg.py index 1175936..a75d3b2 100644 --- a/nephilim/settings_wg.py +++ b/nephilim/settings_wg.py @@ -57,7 +57,7 @@ class SettingsWidget(QtGui.QWidget): self.settings.endGroup() self.update = QtGui.QPushButton('Update MPD database') - self.connect(self.update, QtCore.SIGNAL('clicked()'), self.update_db) + self.update.clicked.connect(self.update_db) self.outputs = QtGui.QGroupBox('Audio outputs') self.outputs.setLayout(QtGui.QVBoxLayout()) @@ -68,7 +68,7 @@ class SettingsWidget(QtGui.QWidget): QtGui.QCheckBox.__init__(self, text) self.mpclient = mpclient self.id = id - self.connect(self, QtCore.SIGNAL('stateChanged(int)'), self.change_state) + self.stateChanged.connect(self.change_state) def change_state(self, state): self.mpclient.set_output(self.id, state) @@ -83,7 +83,7 @@ class SettingsWidget(QtGui.QWidget): self.xfade = QtGui.QSpinBox() self.xfade.setValue(int(self.mpclient.status()['xfade'])) - self.connect(self.xfade, QtCore.SIGNAL('valueChanged(int)'), self.mpclient.crossfade) + self.xfade.valueChanged.connect(self.mpclient.crossfade) self.setLayout(QtGui.QVBoxLayout()) self._add_widget(self.host_txt, 'Host', 'Host or socket to connect to') @@ -147,7 +147,7 @@ class SettingsWidget(QtGui.QWidget): self.layout().addWidget(self.save_btn, 1, 0) self.layout().addWidget(self.close_btn, 1, 1) - self.connect(self.pluginlist, QtCore.SIGNAL('itemChanged(QListWidgetItem*)'), self.plugin_checked) + self.pluginlist.itemChanged.connect(self.plugin_checked) self.setWindowTitle('Settings') self.setAttribute(QtCore.Qt.WA_DeleteOnClose) diff --git a/nephilim/winMain.py b/nephilim/winMain.py index 2912303..31ab17f 100644 --- a/nephilim/winMain.py +++ b/nephilim/winMain.py @@ -51,7 +51,7 @@ class winMain(QtGui.QMainWindow): self.__statuslabel = QtGui.QLabel() self.__time_slider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.__time_slider.setMaximumWidth(self.width()/4) - self.connect(self.__time_slider, QtCore.SIGNAL('sliderReleased()'), self.__on___time_slider_change) + self.__time_slider.sliderReleased.connect( self.__on___time_slider_change) self.__time_label = QtGui.QLabel() self.__time_label.duration = '0:00' @@ -94,10 +94,10 @@ class winMain(QtGui.QMainWindow): self.restoreGeometry(self.settings.value('geometry').toByteArray()) " add event handlers" - self.connect(self.mpclient, QtCore.SIGNAL('connect_changed'), self.__on_connect_changed) - self.connect(self.mpclient, QtCore.SIGNAL('song_changed'), self.__on_song_change) - self.connect(self.mpclient, QtCore.SIGNAL('state_changed'), self.__update_state_messages) - self.connect(self.mpclient, QtCore.SIGNAL('time_changed'), self.__on_time_change) + self.mpclient.connect_changed.connect(self.__on_connect_changed) + self.mpclient.song_changed.connect(self.__on_song_change) + self.mpclient.state_changed.connect(self.__update_state_messages) + self.mpclient.time_changed.connect(self.__on_time_change) self.__update_state_messages() self.show() @@ -115,7 +115,7 @@ class winMain(QtGui.QMainWindow): a.setCheckable(True) a.setChecked(self.settings.value('show_titlebars', QVariant(True)).toBool()) self.__toggle_titlebars(a.isChecked()) - self.connect(a, QtCore.SIGNAL('toggled(bool)'), self.__toggle_titlebars) + a.toggled.connect(self.__toggle_titlebars) self.__layout_menu.addAction(a) self.__layout_menu.addSeparator() |