summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2008-12-27 11:21:20 +0100
committerAnton Khirnov <wyskas@gmail.com>2008-12-27 11:21:20 +0100
commit808ae74e6760803cafcc6c93792b1d1981a1464f (patch)
treec971433ad9cfd93c93e42ba61d8af249c36eeee1
parentab88d703ef13151912248825cf3b71df3543ae98 (diff)
Cleanup.
-rw-r--r--plugins/Lyrics.py14
-rw-r--r--plugins/MPD.py3
-rw-r--r--plugins/Notify.py18
-rw-r--r--plugins/PlayControl.py51
-rw-r--r--plugins/SongStatus.py6
-rw-r--r--plugins/Systray.py2
-rw-r--r--plugins/Tabs.py14
7 files changed, 48 insertions, 60 deletions
diff --git a/plugins/Lyrics.py b/plugins/Lyrics.py
index 518940d..c4534d2 100644
--- a/plugins/Lyrics.py
+++ b/plugins/Lyrics.py
@@ -56,7 +56,6 @@ class wgLyrics(QtGui.QWidget):
editMode=False
lyFormat=None
p=None # plugin
- monty = None
def __init__(self, p, parent=None):
QtGui.QWidget.__init__(self, parent)
self.p=p
@@ -65,7 +64,6 @@ class wgLyrics(QtGui.QWidget):
self.btnRefetch=Button("Refetch", self.onBtnRefetchClick)
self.btnSave=Button("Save lyrics", self.onBtnSaveClick)
self.btnSearch=Button("Search www", self.onBtnSearch)
- self.monty = p.monty
self.txtView=QtGui.QTextEdit(parent)
self.txtView.setReadOnly(True)
@@ -92,7 +90,7 @@ class wgLyrics(QtGui.QWidget):
def onBtnSearch(self):
SE=self.p.getSetting('engine')
f=format.compile(SE)
- SE_url=toAscii(f(format.params(monty.getCurrentSong())))
+ SE_url=toAscii(f(format.params(self.p.monty.getCurrentSong())))
webbrowser.open(urllib.quote(SE_url, ":/+?="))
def onBtnEditClick(self):
@@ -102,16 +100,16 @@ class wgLyrics(QtGui.QWidget):
def onBtnSaveClick(self):
self.setMode(False)
self.curLyrics=self.txtView.toPlainText()
- file=open(self.getLyricsFilePath(monty.getCurrentSong()), 'w')
+ file=open(self.getLyricsFilePath(self.p.monty.getCurrentSong()), 'w')
file.write(self.curLyrics)
file.close()
# just to test if everything's still fine
- self.fetchLyrics(monty.getCurrentSong())
+ self.fetchLyrics(self.p.monty.getCurrentSong())
def onBtnRefetchClick(self):
# force refetch
- lyFName=self.getLyricsFilePath(monty.getCurrentSong())
+ lyFName=self.getLyricsFilePath(self.p.monty.getCurrentSong())
try:
os.remove(lyFName)
except:
@@ -124,7 +122,7 @@ class wgLyrics(QtGui.QWidget):
self.setMode(False)
self.lyFormat=format.compile(self.p.getSetting('downloadto'))
- song=monty.getCurrentSong()
+ song = self.p.monty.getCurrentSong()
try:
song._data['file']
except:
@@ -238,7 +236,7 @@ class wgLyrics(QtGui.QWidget):
max=t.verticalScrollBar().maximum()
if max<=0:
return
- t.verticalScrollBar().setValue((max+t.height()/t.currentFont().pointSize())*time/monty.getCurrentSong()._data['time'])
+ t.verticalScrollBar().setValue((max+t.height()/t.currentFont().pointSize())*time/self.p.monty.getCurrentSong()._data['time'])
diff --git a/plugins/MPD.py b/plugins/MPD.py
index 1f6f6d5..59ac394 100644
--- a/plugins/MPD.py
+++ b/plugins/MPD.py
@@ -13,8 +13,7 @@ class pluginMPD(Plugin):
self.monty = winMain.monty
def getInfo(self):
return "Provides an interface to the MPD settings."
-
-
+
def _getSettings(self):
return [
['host', 'Host', 'Host where mpd resides.', QtGui.QLineEdit(self.getSetting('host'))],
diff --git a/plugins/Notify.py b/plugins/Notify.py
index 04ad045..8d25912 100644
--- a/plugins/Notify.py
+++ b/plugins/Notify.py
@@ -15,7 +15,6 @@ class winNotify(QtGui.QWidget):
resizeWindow=True
winMain=None
p=None
- monty = None
# data used for showing off
timer=None
@@ -27,16 +26,15 @@ class winNotify(QtGui.QWidget):
QtGui.QWidget.__init__(self, parent)
self.p=p
self.winMain=winMain
- self.monty = winMain.monty
-
+
self.setWindowFlags(QtCore.Qt.ToolTip)
self.setWindowOpacity(0.7)
-
+
font=QtGui.QFont()
font.setPixelSize(30)
font.setFamily('Comic Sans Ms')
self.setFont(font)
-
+
def mousePressEvent(self, event):
self.hide()
@@ -56,14 +54,14 @@ class winNotify(QtGui.QWidget):
self.timer=3
self.raise_()
self.timerEvent(None)
-
+
def hide(self):
if self._timerID:
self.killTimer(self._timerID)
self._timerID=None
self.setHidden(True)
-
+
def centerH(self):
screen = QtGui.QDesktopWidget().screenGeometry()
size = self.geometry()
@@ -109,14 +107,12 @@ class winNotify(QtGui.QWidget):
rect=p.boundingRect(width+margin+spacing,margin,
rect.width(),self.height(), QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter, txt)
p.drawText(rect, QtCore.Qt.AlignHCenter, txt)
-
+
def timerEvent(self, event):
self.timer-=1
if self.timer<=0:
self.hide()
self.update()
-
-
class pluginNotify(Plugin):
o=None
@@ -142,7 +138,7 @@ class pluginNotify(Plugin):
, time=self.getSetting('timer'))
def onReady(self, params):
- self.o.show('self.montypc loaded!', monty.getCurrentSong(), time=self.getSetting('timer'))
+ self.o.show('montypc loaded!', self.monty.getCurrentSong(), time=self.getSetting('timer'))
def onDisconnect(self, params):
self.o.show('Disconnected!', time=self.getSetting('timer'))
diff --git a/plugins/PlayControl.py b/plugins/PlayControl.py
index b31046a..aee4a86 100644
--- a/plugins/PlayControl.py
+++ b/plugins/PlayControl.py
@@ -48,11 +48,10 @@ class wgPlayControl(QtGui.QWidget):
cmbRepeat=None
cmbShuffle=None
p=None
- monty = None
-
+
" contains the songs of the album the current song is playing. None, if the album is not set"
curAlbumSongs=None
-
+
" queued songs: int*"
queuedSongs=[]
# what mode where we in before the queue started?
@@ -61,7 +60,7 @@ class wgPlayControl(QtGui.QWidget):
def __init__(self, p, parent=None):
QtGui.QWidget.__init__(self, parent)
self.p=p
- self.monty = p.monty
+ self.p.monty = p.monty
class wgSvgSwitcher(QtSvg.QSvgWidget):
"""Widget showing an svg-image, which, when clicked, will (un)hide an element."""
@@ -141,7 +140,7 @@ class wgPlayControl(QtGui.QWidget):
self.connect(self.cmbRepeat, QtCore.SIGNAL('currentIndexChanged(int)'),self.onCmbRepeatChanged)
self.connect(self.cmbShuffle, QtCore.SIGNAL('currentIndexChanged(int)'),self.onCmbShuffleChanged)
-
+
def addSongsToQueue(self, songs):
self.queuedSongs.extend(songs)
self._onQueueUpdate()
@@ -153,9 +152,9 @@ class wgPlayControl(QtGui.QWidget):
self.cmbShuffle.setItemText(PC_RANDOM_QUEUE, "Queue (%i)"%(len(self.queuedSongs)))
def onBtnJmpCurrentClick(self):
- plugins.getPlugin("Playlist").getPlaylist().ensureVisible(self.monty.getCurrentSong().getID())
+ plugins.getPlugin("Playlist").getPlaylist().ensureVisible(self.p.monty.getCurrentSong().getID())
def onStateChange(self, params):
- newState=self.monty.getStatus()['state']
+ newState=self.p.monty.getStatus()['state']
map(lambda o: o.setEnabled(newState!='stop'), self.objects)
@@ -174,7 +173,7 @@ class wgPlayControl(QtGui.QWidget):
self.slrTime.setValue(params['newTime'])
def onSongChange(self, params):
try:
- self.slrTime.setMaximum(self.monty.getStatus()['length'])
+ self.slrTime.setMaximum(self.p.monty.getStatus()['length'])
self.slrTime.setEnabled(True)
except:
pass
@@ -184,7 +183,7 @@ class wgPlayControl(QtGui.QWidget):
def beforeSongChange(self, params):
nextID=None
- song=self.monty.getCurrentSong()
+ song=self.p.monty.getCurrentSong()
# decide here what next song to play!
repeat=self.cmbRepeat.currentIndex()
random=self.cmbShuffle.currentIndex()
@@ -239,7 +238,7 @@ class wgPlayControl(QtGui.QWidget):
# album.
if eofAlbum and (repeat==PC_REPEAT_PLAYLIST or repeat==PC_REPEAT_NO):
# all first songs of an album
- albums=filter(lambda s: s.getAlbum() and s.getTrack()==1, self.monty.listPlaylist())
+ albums=filter(lambda s: s.getAlbum() and s.getTrack()==1, self.p.monty.listPlaylist())
nextID=albums[randint(0,len(albums)-1)].getID()
else:
# we're not at end of album, so we fetch the next id
@@ -255,45 +254,45 @@ class wgPlayControl(QtGui.QWidget):
self.cmbShuffle.setCurrentIndex(int(self.p.getSetting('oldshuffle')))
if nextID!=None:
- self.monty.play(nextID)
+ self.p.monty.play(nextID)
def getCurAlbumSongs(self):
return self.curAlbumSongs
def findAlbumSongs(self):
"""This method looks for the songs in the album of current playing song."""
- song=self.monty.getCurrentSong()
+ song=self.p.monty.getCurrentSong()
if self.curAlbumSongs and clSong.isSameAlbum(song, self.curAlbumSongs[0]):
return
self.curAlbumSongs=None
if not song or not song.getAlbum():
return
- self.curAlbumSongs=filter(lambda s: clSong.isSameAlbum(s, song), self.monty.listPlaylist())
+ self.curAlbumSongs=filter(lambda s: clSong.isSameAlbum(s, song), self.p.monty.listPlaylist())
self.curAlbumSongs=sorted(self.curAlbumSongs, lambda l,r: numeric_compare(l.getTrack(), r.getTrack()))
def onBtnPlayPauseClick(self):
- status=self.monty.getStatus()
+ status=self.p.monty.getStatus()
if status['state']=='play':
- self.monty.pause()
+ self.p.monty.pause()
self.p.extended("Toggling playback")
elif status['state']=='stop':
- self.monty.play(None)
+ self.p.monty.play(None)
self.p.extended("Pausing playback")
else:
- self.monty.resume()
+ self.p.monty.resume()
def onBtnStopClick(self):
- self.monty.stop()
+ self.p.monty.stop()
self.p.extended("Stopping playback")
def onBtnPreviousClick(self):
- self.monty.previous()
+ self.p.monty.previous()
self.p.extended("Playing previous")
def onBtnNextClick(self):
- self.monty.next()
+ self.p.monty.next()
self.p.extended("Playing next")
def onTimeSliderChange(self):
- self.monty.seek(self.slrTime.value())
+ self.p.monty.seek(self.slrTime.value())
def onVolumeSliderChange(self):
v=self.slrVolume.value()
- self.monty.setVolume(v)
+ self.p.monty.setVolume(v)
if v<=1:
mode='mute'
else:
@@ -303,9 +302,9 @@ class wgPlayControl(QtGui.QWidget):
def onCmbRepeatChanged(self, newval):
self.p.setSetting('repeat', newval)
if newval==PC_REPEAT_PLAYLIST:
- self.monty.repeat(1)
+ self.p.monty.repeat(1)
else:
- self.monty.repeat(0)
+ self.p.monty.repeat(0)
def onCmbShuffleChanged(self, newval):
if newval==PC_RANDOM_QUEUE:
# must do some extra's if moving to queued-mode
@@ -321,9 +320,9 @@ class wgPlayControl(QtGui.QWidget):
self.p.setSetting('shuffle', newval)
if newval==PC_RANDOM_SONG:
- self.monty.random(1)
+ self.p.monty.random(1)
else:
- self.monty.random(0)
+ self.p.monty.random(0)
# save and load the queue
def saveQueue(self):
diff --git a/plugins/SongStatus.py b/plugins/SongStatus.py
index f5e5ab9..f0095e5 100644
--- a/plugins/SongStatus.py
+++ b/plugins/SongStatus.py
@@ -16,15 +16,13 @@ class wgSongStatus(QtGui.QWidget):
lblInfo=None
format=None
p=None
- monty = None
def __init__(self, p, parent=None):
QtGui.QWidget.__init__(self, parent)
self.p=p
- self.monty = p.monty
self.lblInfo=QtGui.QLabel()
self.setMinimumWidth(400)
-
+
layout=QtGui.QHBoxLayout()
self.setLayout(layout)
@@ -46,7 +44,7 @@ class wgSongStatus(QtGui.QWidget):
if song:
self.lblInfo.setText(self.format(format.params(song, values)))
-
+
def updateFormat(self):
try:
self.format=format.compile(self.p.getSetting('format'))
diff --git a/plugins/Systray.py b/plugins/Systray.py
index ea4ef6d..309835b 100644
--- a/plugins/Systray.py
+++ b/plugins/Systray.py
@@ -54,7 +54,7 @@ class pluginSystray(Plugin):
self.o=None
self.winMain._wheelEvent=None
def getInfo(self):
- return "Display the self.montypc icon in the systray."
+ return "Display the montypc icon in the systray."
def update(self, params):
status=self.monty.getStatus()
diff --git a/plugins/Tabs.py b/plugins/Tabs.py
index 4862f12..17c4c92 100644
--- a/plugins/Tabs.py
+++ b/plugins/Tabs.py
@@ -28,21 +28,19 @@ class wgTabs(QtGui.QWidget):
" contains the tabs"
txt=None
p=None # plugin
- monty = None
def __init__(self, p, parent=None):
QtGui.QWidget.__init__(self, parent)
self.p=p
self.txt=QtGui.QTextEdit(parent)
self.txt.setReadOnly(True)
-
+
layout=QtGui.QVBoxLayout()
layout.addWidget(self.txt)
self.setLayout(layout)
- self.monty = p.monty
-
+
def refresh(self):
- song=self.monty.getCurrentSong()
+ song=self.p.monty.getCurrentSong()
try:
song._data['file']
except:
@@ -51,7 +49,7 @@ class wgTabs(QtGui.QWidget):
self.resetTxt(song)
start_new_thread(self.fetchTabs, (song,))
-
+
def customEvent(self, event):
if isinstance(event,ResetEvent):
self.resetTxt(event.song)
@@ -147,10 +145,10 @@ class pluginTabs(Plugin):
self.o=None
def getInfo(self):
return "Show (and fetch) the tabs of the currently playing song."
-
+
def _getDockWidget(self):
return self._createDock(self.o)
-
+
def refresh(self, params):
self.o.refresh()
def onDisconnect(self, params):