summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-10-13 13:49:22 +0200
committerAnton Khirnov <anton@khirnov.net>2020-10-13 13:49:22 +0200
commitded8496439c0a1bfa2d244470cbd99113b8e84be (patch)
treef691d38fffadf4c314b615bccff027de5f14d970
parent56b63e7929bc9a2b74535107e7a9bb5f317bacc1 (diff)
Port to PyQt5.
-rwxr-xr-xnephilim.py7
-rw-r--r--nephilim/common.py12
-rw-r--r--nephilim/connect_wg.py26
-rw-r--r--nephilim/data.py2
-rw-r--r--nephilim/icons.py2
-rw-r--r--nephilim/main_window.py35
-rw-r--r--nephilim/metadata_fetcher.py4
-rw-r--r--nephilim/mpclient.py11
-rw-r--r--nephilim/mpdsocket.py4
-rw-r--r--nephilim/nephilim_app.py8
-rw-r--r--nephilim/plugin.py23
-rw-r--r--nephilim/plugins/AlbumCover.py52
-rw-r--r--nephilim/plugins/Filebrowser.py22
-rw-r--r--nephilim/plugins/Library.py30
-rw-r--r--nephilim/plugins/Lyrics.py55
-rw-r--r--nephilim/plugins/Notify.py24
-rw-r--r--nephilim/plugins/PlayControl.py18
-rw-r--r--nephilim/plugins/Playlist.py32
-rw-r--r--nephilim/plugins/Songinfo.py30
-rw-r--r--nephilim/plugins/Systray.py10
-rw-r--r--nephilim/settings_wg.py28
-rw-r--r--nephilim/song.py2
22 files changed, 225 insertions, 212 deletions
diff --git a/nephilim.py b/nephilim.py
index 32c868f..7091eb7 100755
--- a/nephilim.py
+++ b/nephilim.py
@@ -25,12 +25,9 @@ import logging
from traceback import print_exc
from optparse import OptionParser
try:
- import sip
- sip.setapi('QString', 2)
- sip.setapi('QVariant', 2)
- from PyQt4 import QtGui
+ from PyQt5 import QtGui
except ImportError:
- sys.exit('PyQt4 not found. Ensure that it is installed.')
+ sys.exit('PyQt5 not found. Ensure that it is installed.')
from nephilim.nephilim_app import NephilimApp
diff --git a/nephilim/common.py b/nephilim/common.py
index ddbb96b..5690b3d 100644
--- a/nephilim/common.py
+++ b/nephilim/common.py
@@ -16,7 +16,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtCore, QtGui
+from PyQt5 import QtCore, QtWidgets, QtGui
import socket
import logging
import os
@@ -39,11 +39,11 @@ def sec2min(secs):
if sec<10:sec='0'+str(sec)
return str(min)+':'+str(sec)
-class Button(QtGui.QPushButton):
+class Button(QtWidgets.QPushButton):
iconSize=32
"""A simple Button class which calls $onClick when clicked."""
def __init__(self, caption, onClick=None, iconPath=None, iconOnly=False, parent=None):
- QtGui.QPushButton.__init__(self, parent)
+ QtWidgets.QPushButton.__init__(self, parent)
if onClick:
self.clicked.connect(onClick)
@@ -51,7 +51,7 @@ class Button(QtGui.QPushButton):
self.changeIcon(iconPath)
if not(iconPath and iconOnly):
- QtGui.QPushButton.setText(self, caption)
+ QtWidgets.QPushButton.setText(self, caption)
self.setToolTip(caption)
@@ -82,8 +82,8 @@ def generate_metadata_path(song, dir_tag, file_tag):
dirname = ''
filepath = ''
else:
- dirname = expand_tags(dir_tag, (QtGui.QApplication.instance(), song))
- filepath = '%s/%s'%(dirname, expand_tags(file_tag, (QtGui.QApplication.instance(), song)).replace('/', '_'))
+ dirname = expand_tags(dir_tag, (QtWidgets.QApplication.instance(), song))
+ filepath = '%s/%s'%(dirname, expand_tags(file_tag, (QtWidgets.QApplication.instance(), song)).replace('/', '_'))
return dirname, filepath
diff --git a/nephilim/connect_wg.py b/nephilim/connect_wg.py
index e237527..6c5cad9 100644
--- a/nephilim/connect_wg.py
+++ b/nephilim/connect_wg.py
@@ -16,10 +16,10 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
import time
-class ConnectWidget(QtGui.QWidget):
+class ConnectWidget(QtWidgets.QWidget):
host_txt = None
port_txt = None
pass_txt = None
@@ -28,26 +28,26 @@ class ConnectWidget(QtGui.QWidget):
settings = None
def __init__(self):
- QtGui.QWidget.__init__(self)
- self.mpclient = QtGui.QApplication.instance().mpclient
+ QtWidgets.QWidget.__init__(self)
+ self.mpclient = QtWidgets.QApplication.instance().mpclient
self.settings = QtCore.QSettings()
- self.host_txt = QtGui.QLineEdit(self.settings.value('MPD/host', 'localhost'))
+ self.host_txt = QtWidgets.QLineEdit(self.settings.value('MPD/host', 'localhost'))
self.host_txt.setToolTip('Host')
- self.port_txt = QtGui.QLineEdit(self.settings.value('MPD/port', '6600'))
+ self.port_txt = QtWidgets.QLineEdit(self.settings.value('MPD/port', '6600'))
self.port_txt.setValidator(QtGui.QIntValidator(1, 65535, self.port_txt))
self.port_txt.setToolTip('Port')
- self.pass_txt = QtGui.QLineEdit(self.settings.value('MPD/password'))
- self.pass_txt.setEchoMode(QtGui.QLineEdit.Password)
+ self.pass_txt = QtWidgets.QLineEdit(self.settings.value('MPD/password'))
+ self.pass_txt.setEchoMode(QtWidgets.QLineEdit.Password)
self.pass_txt.setToolTip('Password')
- self.connect_btn = QtGui.QPushButton('Connect')
- self.connect(self.connect_btn, QtCore.SIGNAL('clicked()'), self.connect_mpd)
+ self.connect_btn = QtWidgets.QPushButton('Connect')
+ self.connect_btn.clicked.connect(self.connect_mpd)
- self.setLayout(QtGui.QGridLayout())
- self.layout().addWidget(QtGui.QLabel('host:port:password'), 0, 0, 1, 3, QtCore.Qt.AlignHCenter)
+ self.setLayout(QtWidgets.QGridLayout())
+ self.layout().addWidget(QtWidgets.QLabel('host:port:password'), 0, 0, 1, 3, QtCore.Qt.AlignHCenter)
self.layout().addWidget(self.host_txt, 1, 0)
self.layout().addWidget(self.port_txt, 1, 1)
self.layout().addWidget(self.pass_txt, 1, 2)
@@ -59,7 +59,7 @@ class ConnectWidget(QtGui.QWidget):
self.mpclient.connect_changed.connect(self.on_connected)
def center(self):
- screen = QtGui.QDesktopWidget().screenGeometry()
+ screen = QtWidgets.QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2+100)
diff --git a/nephilim/data.py b/nephilim/data.py
index 746877b..a3876dd 100644
--- a/nephilim/data.py
+++ b/nephilim/data.py
@@ -7,7 +7,7 @@
#
# WARNING! All changes made in this file will be lost!
-from PyQt4 import QtCore
+from PyQt5 import QtCore
qt_resource_data = "\
\x00\x00\x01\xe7\
diff --git a/nephilim/icons.py b/nephilim/icons.py
index 511f3ab..48cd32b 100644
--- a/nephilim/icons.py
+++ b/nephilim/icons.py
@@ -7,7 +7,7 @@
#
# WARNING! All changes made in this file will be lost!
-from PyQt4 import QtCore
+from PyQt5 import QtCore
qt_resource_data = "\
\x00\x00\x09\xe2\
diff --git a/nephilim/main_window.py b/nephilim/main_window.py
index 8f3377b..441d65f 100644
--- a/nephilim/main_window.py
+++ b/nephilim/main_window.py
@@ -16,15 +16,15 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
-from PyQt4.QtCore import pyqtSlot as Slot
+from PyQt5 import QtGui, QtWidgets, QtCore
+from PyQt5.QtCore import pyqtSlot as Slot
import logging
from common import APPNAME, sec2min, appIcon
import icons
import data
-class MainWindow(QtGui.QMainWindow):
+class MainWindow(QtWidgets.QMainWindow):
"""
Application's main window class.
"""
@@ -43,15 +43,16 @@ class MainWindow(QtGui.QMainWindow):
__docks = []
def __init__(self, mpclient):
- QtGui.QMainWindow.__init__(self)
+ QtWidgets.QMainWindow.__init__(self)
+
self.settings = QtCore.QSettings()
self.mpclient = mpclient
# statusbar
self.statusBar()
- self.__statuslabel = QtGui.QLabel()
- self.__time_slider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
+ self.__statuslabel = QtWidgets.QLabel()
+ self.__time_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
self.__time_slider.setMaximumWidth(self.width()/4)
self.__time_slider.sliderReleased.connect( self.__on___time_slider_change)
self.__time_label = TimeLabel(self, mpclient)
@@ -61,11 +62,11 @@ class MainWindow(QtGui.QMainWindow):
self.statusBar().addPermanentWidget(self.__time_label)
self.statusBar().addPermanentWidget(self.__time_slider)
- mBar = QtGui.QMenuBar() # create a menubar
+ mBar = QtWidgets.QMenuBar() # create a menubar
# Server menu
m = mBar.addMenu('&Server')
# connect
- self.mConnect=m.addAction('&Connect.', QtGui.QApplication.instance().show_connect_win)
+ self.mConnect=m.addAction('&Connect.', QtWidgets.QApplication.instance().show_connect_win)
self.mConnect.setIcon(QtGui.QIcon(appIcon))
# disconnect
self.mDisconnect=m.addAction('&Disconnect', self.mpclient.disconnect_mpd)
@@ -77,25 +78,23 @@ class MainWindow(QtGui.QMainWindow):
m.addAction('&Rescan', self.mpclient.rescan_database)
m.addSeparator()
# quit
- m.addAction("&Quit", QtGui.QApplication.instance().quit).setIcon(QtGui.QIcon(':icons/gtk-quit.svg'))
+ m.addAction("&Quit", QtWidgets.QApplication.instance().quit).setIcon(QtGui.QIcon(':icons/gtk-quit.svg'))
# menu options
m=mBar.addMenu("Options")
# settings
- m.addAction("Settings", QtGui.QApplication.instance().show_settings_win).setIcon(QtGui.QIcon(':icons/gtk-preferences.svg'))
+ m.addAction("Settings", QtWidgets.QApplication.instance().show_settings_win).setIcon(QtGui.QIcon(':icons/gtk-preferences.svg'))
# menu layout
self.__layout_menu=mBar.addMenu("Layout")
# create a toolbar for the main menu
- menu_toolbar = QtGui.QToolBar('Main menu', self)
+ menu_toolbar = QtWidgets.QToolBar('Main menu', self)
menu_toolbar.addWidget(mBar)
self.addToolBar(QtCore.Qt.TopToolBarArea, menu_toolbar)
self.__update_layout_menu()
- self.setDockOptions(QtGui.QMainWindow.AllowNestedDocks \
- |QtGui.QMainWindow.AllowTabbedDocks \
- |QtGui.QMainWindow.VerticalTabs)
+ self.setDockOptions(self.AllowNestedDocks | self .AllowTabbedDocks | self.VerticalTabs)
self.setDockNestingEnabled(True)
self.restoreGeometry(self.settings.value('geometry', QtCore.QByteArray()))
@@ -116,7 +115,7 @@ class MainWindow(QtGui.QMainWindow):
self.__layout_menu.addAction('Restore layout', self.restore_layout)
self.__layout_menu.addSeparator()
# create checkable menu
- a = QtGui.QAction('Show titlebars', self)
+ a = QtWidgets.QAction('Show titlebars', self)
a.setCheckable(True)
a.setChecked(int(self.settings.value('show_titlebars', 1)))
self.__toggle_titlebars(a.isChecked())
@@ -138,7 +137,7 @@ class MainWindow(QtGui.QMainWindow):
if val:
dock.setTitleBarWidget(None)
else:
- dock.setTitleBarWidget(QtGui.QWidget())
+ dock.setTitleBarWidget(QtWidgets.QWidget())
def add_dock(self, dock):
if dock:
self.__docks.append(dock)
@@ -195,12 +194,12 @@ class MainWindow(QtGui.QMainWindow):
if not self.__time_slider.isSliderDown():
self.__time_slider.setValue(new_time)
-class TimeLabel(QtGui.QLabel):
+class TimeLabel(QtWidgets.QLabel):
_mpclient = None
def __init__(self, parent, mpclient):
- QtGui.QLabel.__init__(self, parent)
+ QtWidgets.QLabel.__init__(self, parent)
self._mpclient = mpclient
diff --git a/nephilim/metadata_fetcher.py b/nephilim/metadata_fetcher.py
index efce65a..72d7fae 100644
--- a/nephilim/metadata_fetcher.py
+++ b/nephilim/metadata_fetcher.py
@@ -15,8 +15,8 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtCore, QtNetwork
-from PyQt4.QtCore import pyqtSignal as Signal
+from PyQt5 import QtCore, QtNetwork
+from PyQt5.QtCore import pyqtSignal as Signal
from song import Song
diff --git a/nephilim/mpclient.py b/nephilim/mpclient.py
index f3fc24a..12934d1 100644
--- a/nephilim/mpclient.py
+++ b/nephilim/mpclient.py
@@ -15,8 +15,8 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtCore, QtNetwork
-from PyQt4.QtCore import pyqtSignal as Signal, pyqtSlot as Slot
+from PyQt5 import QtCore, QtNetwork
+from PyQt5.QtCore import pyqtSignal as Signal, pyqtSlot as Slot
import logging
import os.path
@@ -122,6 +122,10 @@ class MPClient(QtCore.QObject):
Changes when db_updated() signal is emitted.
"""
db = None
+ """
+ A list of Song objects representing current playlist
+ """
+ #playlist = None
# SIGNALS
connect_changed = Signal(bool)
@@ -165,6 +169,7 @@ class MPClient(QtCore.QObject):
self.status = MPDStatus()
self.cur_song = Song()
self.db = {}
+ #self.playlist = []
self.outputs = []
self.urlhandlers = []
@@ -536,8 +541,6 @@ class MPClient(QtCore.QObject):
self.consume_changed.emit(self.status['consume'])
if status['xfade'] != self.status['xfade']:
self.crossfade_changed.emit(self.status['xfade'])
- if status['playlist'] != self.status['playlist']:
- self.playlist_changed.emit()
if status['songid'] != self.status['songid']:
self._command('currentsong', callback = self._update_cur_song)
diff --git a/nephilim/mpdsocket.py b/nephilim/mpdsocket.py
index 7a8f03d..5cc9a60 100644
--- a/nephilim/mpdsocket.py
+++ b/nephilim/mpdsocket.py
@@ -17,8 +17,8 @@
#
import logging
-from PyQt4 import QtCore, QtNetwork
-from PyQt4.QtCore import pyqtSignal as Signal
+from PyQt5 import QtCore, QtNetwork
+from PyQt5.QtCore import pyqtSignal as Signal
class MPDSocket(QtCore.QObject):
"""
diff --git a/nephilim/nephilim_app.py b/nephilim/nephilim_app.py
index b03245d..1f160dc 100644
--- a/nephilim/nephilim_app.py
+++ b/nephilim/nephilim_app.py
@@ -15,7 +15,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
from string import Template
from main_window import MainWindow
@@ -26,7 +26,7 @@ from connect_wg import ConnectWidget
import plugins
import icons
-class NephilimApp(QtGui.QApplication):
+class NephilimApp(QtWidgets.QApplication):
#### PUBLIC ####
# those don't change while the program is running
"""main window object"""
@@ -46,7 +46,7 @@ class NephilimApp(QtGui.QApplication):
#### PUBLIC ####
def __init__(self, argv):
- QtGui.QApplication.__init__(self, argv)
+ QtWidgets.QApplication.__init__(self, argv)
self.setApplicationName(APPNAME)
self.setOrganizationName(ORGNAME)
@@ -85,7 +85,7 @@ class NephilimApp(QtGui.QApplication):
self.main_win.restore_layout()
self._connect_win.monitor()
- QtGui.QApplication.exec_()
+ QtWidgets.QApplication.exec_()
def show_settings_win(self):
diff --git a/nephilim/plugin.py b/nephilim/plugin.py
index c993bd7..6760868 100644
--- a/nephilim/plugin.py
+++ b/nephilim/plugin.py
@@ -16,7 +16,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtWidgets, QtCore
import logging
import plugins
@@ -61,12 +61,12 @@ class Plugin(QtCore.QObject):
def load(self):
self.logger.info('loading')
self._load()
- opts = QtGui.QDockWidget.DockWidgetClosable|QtGui.QDockWidget.DockWidgetMovable
+ opts = QtWidgets.QDockWidget.DockWidgetClosable|QtWidgets.QDockWidget.DockWidgetMovable
self.dock_widget = self._get_dock_widget()
if self.dock_widget:
self.dock_widget.setFeatures(opts)
- QtGui.QApplication.instance().main_win.add_dock(self.dock_widget)
- QtGui.QApplication.instance().main_win.restore_layout()
+ QtWidgets.QApplication.instance().main_win.add_dock(self.dock_widget)
+ QtWidgets.QApplication.instance().main_win.restore_layout()
self.mpclient.connect_changed.connect(self.set_enabled)
self.loaded = True
def unload(self):
@@ -75,7 +75,7 @@ class Plugin(QtCore.QObject):
self.logger.info("unloading")
self._unload()
if self.dock_widget:
- QtGui.QApplication.instance().main_win.remove_dock(self.dock_widget)
+ QtWidgets.QApplication.instance().main_win.remove_dock(self.dock_widget)
self.dock_widget = None
self.settingsWidget = None
self.mpclient.connect_changed.disconnect(self.set_enabled)
@@ -84,13 +84,14 @@ class Plugin(QtCore.QObject):
if self.o:
self.o.setEnabled(val)
- class SettingsWidget(QtGui.QWidget):
+ class SettingsWidget(QtWidgets.QWidget):
""" plugins should subclass this"""
plugin = None
settings = None
def __init__(self, plugin):
- QtGui.QWidget.__init__(self)
+ QtWidgets.QWidget.__init__(self)
+
self.plugin = plugin
self.settings = QtCore.QSettings()
@@ -104,10 +105,10 @@ class Plugin(QtCore.QObject):
def _add_widget(self, widget, label = '', tooltip = ''):
"""adds a widget with label"""
if not self.layout():
- self.plugin.logger.error('Attempted to call add_widget with no layout set.')
+ self.logger.error('Attempted to call add_widget with no layout set.')
widget.setToolTip(tooltip)
- layout = QtGui.QHBoxLayout()
- layout.addWidget(QtGui.QLabel(label))
+ layout = QtWidgets.QHBoxLayout()
+ layout.addWidget(QtWidgets.QLabel(label))
layout.addWidget(widget)
self.layout().addLayout(layout)
@@ -120,7 +121,7 @@ class Plugin(QtCore.QObject):
return None
def _create_dock(self, widget):
"""Creates a QDockWidget with _parent $_parent containing widget $widget."""
- dock=QtGui.QDockWidget(self.name, QtGui.QApplication.instance().main_win)
+ dock=QtWidgets.QDockWidget(self.name, QtWidgets.QApplication.instance().main_win)
dock.setObjectName(self.name)
dock.setWidget(widget)
dock.setAllowedAreas(QtCore.Qt.AllDockWidgetAreas)
diff --git a/nephilim/plugins/AlbumCover.py b/nephilim/plugins/AlbumCover.py
index b4302bc..c576c56 100644
--- a/nephilim/plugins/AlbumCover.py
+++ b/nephilim/plugins/AlbumCover.py
@@ -15,8 +15,8 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore, QtNetwork
-from PyQt4.QtCore import pyqtSignal as Signal
+from PyQt5 import QtGui, QtWidgets, QtCore, QtNetwork
+from PyQt5.QtCore import pyqtSignal as Signal
import os
@@ -24,7 +24,7 @@ from ..plugin import Plugin
from .. import common, metadata_fetcher, song
from .. import icons
-class AlbumCoverWidget(QtGui.QLabel):
+class AlbumCoverWidget(QtWidgets.QLabel):
"cover - QPixmap or None"
cover = None
"is there a (non-default) cover loaded?"
@@ -37,13 +37,13 @@ class AlbumCoverWidget(QtGui.QLabel):
_menu = None # popup menu
def __init__(self, plugin):
- QtGui.QLabel.__init__(self)
+ QtWidgets.QLabel.__init__(self)
self.plugin = plugin
self.logger = plugin.logger
self.setAlignment(QtCore.Qt.AlignCenter)
# popup menu
- self._menu = QtGui.QMenu('album')
+ self._menu = QtWidgets.QMenu('album')
self._menu.addAction('&Select cover file...', self.plugin.select_cover)
self._menu.addAction('&Refresh cover.', self.plugin.refresh)
self._menu.addAction('&View in a separate window.', self.__view_cover)
@@ -76,7 +76,7 @@ class AlbumCoverWidget(QtGui.QLabel):
def __view_cover(self):
if not self.cover_loaded:
return
- win = QtGui.QLabel(self, QtCore.Qt.Window)
+ win = QtWidgets.QLabel(self, QtCore.Qt.Window)
win.setScaledContents(True)
win.setPixmap(self.cover)
win.show()
@@ -85,7 +85,7 @@ class AlbumCoverWidget(QtGui.QLabel):
if not self.cover_loaded:
return
cover = self.cover
- file = QtGui.QFileDialog.getSaveFileName(None, '', QtCore.QDir.homePath())
+ file = QtWidgets.QFileDialog.getSaveFileName(None, '', QtCore.QDir.homePath())
if file:
self.plugin.save_cover_file(cover, file)
@@ -155,44 +155,44 @@ class AlbumCover(Plugin):
self.settings.beginGroup(self.plugin.name)
# store covers groupbox
- self.store = QtGui.QGroupBox('Store covers.')
+ self.store = QtWidgets.QGroupBox('Store covers.')
self.store.setToolTip('Should %s store its own copy of covers?'%common.APPNAME)
self.store.setCheckable(True)
self.store.setChecked(int(self.settings.value('store')))
- self.store.setLayout(QtGui.QGridLayout())
+ self.store.setLayout(QtWidgets.QGridLayout())
# paths to covers
- self.coverdir = QtGui.QLineEdit(self.settings.value('coverdir'))
+ self.coverdir = QtWidgets.QLineEdit(self.settings.value('coverdir'))
self.coverdir.setToolTip('Where should %s store covers.\n'
'${musicdir} will be expanded to path to MPD music library (as set by user)\n'
'${songdir} will be expanded to path to the song (relative to ${musicdir}\n'
'other tags same as in covername'
%common.APPNAME)
- self.covername = QtGui.QLineEdit(self.settings.value('covername'))
+ self.covername = QtWidgets.QLineEdit(self.settings.value('covername'))
self.covername.setToolTip('Filename for %s cover files.\n'
'All tags supported by MPD will be expanded to their\n'
'values for current song, e.g. ${title}, ${track}, ${artist},\n'
'${album}, ${genre} etc.'%common.APPNAME)
- self.store.layout().addWidget(QtGui.QLabel('Cover directory'), 0, 0)
+ self.store.layout().addWidget(QtWidgets.QLabel('Cover directory'), 0, 0)
self.store.layout().addWidget(self.coverdir, 0, 1)
- self.store.layout().addWidget(QtGui.QLabel('Cover filename'), 1, 0)
+ self.store.layout().addWidget(QtWidgets.QLabel('Cover filename'), 1, 0)
self.store.layout().addWidget(self.covername, 1, 1)
# sites list
fetchers = self.settings.value('fetchers')
- self.fetcherlist = QtGui.QListWidget(self)
+ self.fetcherlist = QtWidgets.QListWidget(self)
self.fetcherlist.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
for site in fetchers:
- it = QtGui.QListWidgetItem(site)
+ it = QtWidgets.QListWidgetItem(site)
it.setCheckState(QtCore.Qt.Checked)
self.fetcherlist.addItem(it)
for site in self.plugin.available_fetchers:
if not site.name in fetchers:
- it = QtGui.QListWidgetItem(site.name)
+ it = QtWidgets.QListWidgetItem(site.name)
it.setCheckState(QtCore.Qt.Unchecked)
self.fetcherlist.addItem(it)
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self.layout().addWidget(self.store)
self._add_widget(self.fetcherlist, label = 'Fetchers', tooltip = 'A list of sources used for fetching covers.\n'
'Use drag and drop to change their priority.')
@@ -290,7 +290,7 @@ class AlbumCover(Plugin):
return
self.__abort_fetch()
- file = QtGui.QFileDialog.getOpenFileName(None,
+ file = QtWidgets.QFileDialog.getOpenFileName(None,
'Select album cover for %s - %s'%(song['?artist'], song['?album']),
self.__cover_dir, '')
if not file:
@@ -323,12 +323,16 @@ class FetcherLastfm(metadata_fetcher.MetadataFetcher):
self.song = song
if not 'artist' in song or not 'album' in song:
return self.finish()
+
+ query = QtCore.QUrlQuery()
+ query.setQueryItems([('api_key', 'beedb2a8a0178b8059cd6c7e57fbe428'),
+ ('method', 'album.getInfo'),
+ ('artist', song['artist']),
+ ('album', song['album']),
+ ('mbid', song['?MUSICBRAINZ_ALBUMID'])])
url = QtCore.QUrl('http://ws.audioscrobbler.com/2.0/')
- url.setQueryItems([('api_key', 'beedb2a8a0178b8059cd6c7e57fbe428'),
- ('method', 'album.getInfo'),
- ('artist', song['artist']),
- ('album', song['album']),
- ('mbid', song['?MUSICBRAINZ_ALBUMID'])])
+ url.setQuery(query)
+
self.fetch2(song, url)
self.rep.finished.connect(self.__handle_search_res)
@@ -342,7 +346,7 @@ class FetcherLastfm(metadata_fetcher.MetadataFetcher):
if xml.name() == 'image' and xml.attributes().value('size') == 'extralarge':
url = QtCore.QUrl() # the url is already percent-encoded
try:
- url.setEncodedUrl(xml.readElementText())
+ url.setUrl(xml.readElementText())
except TypeError: #no text
url = None
if xml.hasError():
diff --git a/nephilim/plugins/Filebrowser.py b/nephilim/plugins/Filebrowser.py
index cb0a6e7..f9b07f6 100644
--- a/nephilim/plugins/Filebrowser.py
+++ b/nephilim/plugins/Filebrowser.py
@@ -15,7 +15,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtWidgets, QtCore
import os
import shutil
@@ -36,29 +36,29 @@ class Filebrowser(Plugin):
def _get_dock_widget(self):
return self._create_dock(self.o)
-class wgFilebrowser(QtGui.QWidget):
+class wgFilebrowser(QtWidgets.QWidget):
view = None
model = None
path = None
plugin = None
logger = None
- class FileView(QtGui.QListView):
+ class FileView(QtWidgets.QListView):
"context menu"
menu = None
plugin = None
logger = None
def __init__(self, model, plugin):
- QtGui.QListView.__init__(self)
+ QtWidgets.QListView.__init__(self)
self.plugin = plugin
self.logger = plugin.logger
self.setModel(model)
self.setRootIndex(self.model().index(os.path.expanduser('~')))
- self.setSelectionMode(QtGui.QTreeWidget.ExtendedSelection)
+ self.setSelectionMode(QtWidgets.QTreeWidget.ExtendedSelection)
- self.menu = QtGui.QMenu('file')
+ self.menu = QtWidgets.QMenu('file')
self.menu.addAction('&Make file(s) readable for MPD.', self.selection_make_readable)
self.menu.addAction('***EXPERIMENTAL DON\'T USE*** &Copy to collection.', self.selection_copy_to_collection)
@@ -103,23 +103,23 @@ class wgFilebrowser(QtGui.QWidget):
def __init__(self, plugin):
- QtGui.QWidget.__init__(self)
+ QtWidgets.QWidget.__init__(self)
self.plugin = plugin
self.logger = plugin.logger
- self.model = QtGui.QDirModel()
+ self.model = QtWidgets.QDirModel()
self.model.setFilter(QtCore.QDir.AllDirs|QtCore.QDir.AllEntries)
self.model.setSorting(QtCore.QDir.DirsFirst)
self.view = self.FileView(self.model, self.plugin)
self.view.activated.connect(self.item_activated)
- self.path = QtGui.QLineEdit(self.model.filePath(self.view.rootIndex()))
+ self.path = QtWidgets.QLineEdit(self.model.filePath(self.view.rootIndex()))
self.path.returnPressed.connect(self.path_changed)
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self.layout().setSpacing(0)
- self.layout().setMargin(0)
+ self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().addWidget(self.path)
self.layout().addWidget(self.view)
diff --git a/nephilim/plugins/Library.py b/nephilim/plugins/Library.py
index 3aa49f9..6f2aad9 100644
--- a/nephilim/plugins/Library.py
+++ b/nephilim/plugins/Library.py
@@ -15,8 +15,8 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
-from PyQt4.QtCore import pyqtSlot as Slot
+from PyQt5 import QtGui, QtWidgets, QtCore
+from PyQt5.QtCore import pyqtSlot as Slot
from ..plugin import Plugin
from ..common import MIMETYPES, SongsMimeData
@@ -44,7 +44,7 @@ class Library(Plugin):
return
self.o.fill_library()
-class LibraryWidget(QtGui.QWidget):
+class LibraryWidget(QtWidgets.QWidget):
library_view = None
library_model = None
search_txt = None
@@ -57,7 +57,8 @@ class LibraryWidget(QtGui.QWidget):
def __init__(self, plugin):
- QtGui.QWidget.__init__(self)
+ QtWidgets.QWidget.__init__(self)
+
self.plugin = plugin
self.logger = plugin.logger
self.settings = QtCore.QSettings()
@@ -68,14 +69,14 @@ class LibraryWidget(QtGui.QWidget):
# folding widgets
self.foldings = LibraryFolding(self.plugin, self)
self.foldings.activated.connect(self.fill_library)
- del_folding = QtGui.QPushButton(QtGui.QIcon(':icons/delete.png'), '')
+ del_folding = QtWidgets.QPushButton(QtGui.QIcon(':icons/delete.png'), '')
del_folding.setToolTip('Delete current folding pattern.')
del_folding.clicked.connect(lambda :self.foldings.removeItem(self.foldings.currentIndex()))
- folding_layout = QtGui.QHBoxLayout()
+ folding_layout = QtWidgets.QHBoxLayout()
folding_layout.addWidget(self.foldings, stretch = 1)
folding_layout.addWidget(del_folding)
- self.search_txt = QtGui.QLineEdit()
+ self.search_txt = QtWidgets.QLineEdit()
self.search_txt.setToolTip('Filter library')
self.search_txt.textChanged.connect(self.filter_library)
self.search_txt.returnPressed.connect(self.add_filtered)
@@ -88,9 +89,9 @@ class LibraryWidget(QtGui.QWidget):
self.library_view.setModel(self.library_model)
self.library_view.activated.connect(lambda : self.add_indices(self.library_view.selectedIndexes()))
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self.layout().setSpacing(2)
- self.layout().setMargin(0)
+ self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().addLayout(folding_layout)
self.layout().addWidget(self.search_txt)
self.layout().addWidget(self.library_view)
@@ -216,17 +217,17 @@ class LibraryModel(QtGui.QStandardItemModel):
data.set_songs(songs)
return data
-class LibraryView(QtGui.QTreeView):
+class LibraryView(QtWidgets.QTreeView):
def __init__(self):
- QtGui.QTreeView.__init__(self)
+ QtWidgets.QTreeView.__init__(self)
self.setAlternatingRowColors(True)
- self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
+ self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.setUniformRowHeights(True)
self.setHeaderHidden(True)
self.setDragEnabled(True)
-class LibraryFolding(QtGui.QComboBox):
+class LibraryFolding(QtWidgets.QComboBox):
#### PRIVATE ####
_plugin = None
@@ -235,7 +236,8 @@ class LibraryFolding(QtGui.QComboBox):
#### PUBLIC ####
def __init__(self, plugin, parent):
- QtGui.QComboBox.__init__(self, parent)
+ QtWidgets.QComboBox.__init__(self)
+
self.setEditable(True)
self.setToolTip('Current folding pattern.')
diff --git a/nephilim/plugins/Lyrics.py b/nephilim/plugins/Lyrics.py
index 35bb477..b569094 100644
--- a/nephilim/plugins/Lyrics.py
+++ b/nephilim/plugins/Lyrics.py
@@ -15,7 +15,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore, QtNetwork
+from PyQt5 import QtGui, QtWidgets, QtCore, QtNetwork
import os
import re
@@ -25,7 +25,7 @@ from ..plugin import Plugin
from .. import common, metadata_fetcher
from .. import icons
-class LyricsWidget(QtGui.QWidget):
+class LyricsWidget(QtWidgets.QWidget):
#public
lyrics_loaded = None
@@ -40,20 +40,20 @@ class LyricsWidget(QtGui.QWidget):
#### private
def __init__(self, plugin):
- QtGui.QWidget.__init__(self)
+ QtWidgets.QWidget.__init__(self)
self.plugin = plugin
self.logger = plugin.logger
self.curLyrics = ''
- self.__label = QtGui.QLabel(self)
+ self.__label = QtWidgets.QLabel(self)
self.__label.setWordWrap(True)
# add text area
- self.__text_view = QtGui.QTextEdit(self)
+ self.__text_view = QtWidgets.QTextEdit(self)
self.__text_view.setReadOnly(True)
# add toolbar
- self.__toolbar = QtGui.QToolBar('Lyrics toolbar', self)
+ self.__toolbar = QtWidgets.QToolBar('Lyrics toolbar', self)
self.__toolbar.setOrientation(QtCore.Qt.Vertical)
self.__toolbar.addAction(QtGui.QIcon(':icons/refresh.png'), 'Refresh lyrics', self.plugin.refresh)
@@ -64,9 +64,9 @@ class LyricsWidget(QtGui.QWidget):
self.__toolbar.addAction(QtGui.QIcon(':icons/save.png'), 'Save lyrics', self.__save_lyrics)
self.__toolbar.addAction(QtGui.QIcon(':icons/delete.png'), 'Delete stored file', self.plugin.del_lyrics_file)
- self.setLayout(QtGui.QGridLayout())
+ self.setLayout(QtWidgets.QGridLayout())
self.layout().setSpacing(0)
- self.layout().setMargin(0)
+ self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().addWidget(self.__toolbar, 0, 0, -1, 1, QtCore.Qt.AlignTop)
self.layout().addWidget(self.__label, 0, 1)
self.layout().addWidget(self.__text_view, 1, 1)
@@ -155,44 +155,44 @@ class Lyrics(Plugin):
# store lyrics groupbox
- self.store = QtGui.QGroupBox('Store lyrics.')
+ self.store = QtWidgets.QGroupBox('Store lyrics.')
self.store.setToolTip('Should %s store its own copy of lyrics?'%common.APPNAME)
self.store.setCheckable(True)
self.store.setChecked(int(self.settings.value('store')))
- self.store.setLayout(QtGui.QGridLayout())
+ self.store.setLayout(QtWidgets.QGridLayout())
# paths to lyrics
- self.lyricdir = QtGui.QLineEdit(self.settings.value('lyricdir'))
+ self.lyricdir = QtWidgets.QLineEdit(self.settings.value('lyricdir'))
self.lyricdir.setToolTip('Where should %s store lyrics.\n'
'${musicdir} will be expanded to path to MPD music library (as set by user)\n'
'${songdir} will be expanded to path to the song (relative to ${musicdir}\n'
'other tags same as in lyricname'
%common.APPNAME)
- self.lyricname = QtGui.QLineEdit(self.settings.value('lyricname'))
+ self.lyricname = QtWidgets.QLineEdit(self.settings.value('lyricname'))
self.lyricname.setToolTip('Filename for %s lyricsfiles.\n'
'All tags supported by MPD will be expanded to their\n'
'values for current song, e.g. ${title}, ${track}, ${artist},\n'
'${album}, ${genre} etc.'%common.APPNAME)
- self.store.layout().addWidget(QtGui.QLabel('Lyrics directory'), 0, 0)
+ self.store.layout().addWidget(QtWidgets.QLabel('Lyrics directory'), 0, 0)
self.store.layout().addWidget(self.lyricdir, 0, 1)
- self.store.layout().addWidget(QtGui.QLabel('Lyrics filename'), 1, 0)
+ self.store.layout().addWidget(QtWidgets.QLabel('Lyrics filename'), 1, 0)
self.store.layout().addWidget(self.lyricname, 1, 1)
# fetchers list
fetchers = self.settings.value('fetchers')
- self.fetcherlist = QtGui.QListWidget(self)
- self.fetcherlist.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
+ self.fetcherlist = QtWidgets.QListWidget(self)
+ self.fetcherlist.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
for fetcher in fetchers:
- it = QtGui.QListWidgetItem(fetcher)
+ it = QtWidgets.QListWidgetItem(fetcher)
it.setCheckState(QtCore.Qt.Checked)
self.fetcherlist.addItem(it)
for fetcher in self.plugin.available_fetchers:
if not fetcher.name in fetchers:
- it = QtGui.QListWidgetItem(fetcher.name)
+ it = QtWidgets.QListWidgetItem(fetcher.name)
it.setCheckState(QtCore.Qt.Unchecked)
self.fetcherlist.addItem(it)
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self.layout().addWidget(self.store)
self._add_widget(self.fetcherlist, label = 'Sites', tooltip = 'A list of sources used for fetching lyrics.\n'
'Use drag and drop to change their priority.')
@@ -308,9 +308,12 @@ class FetchLyricwiki(metadata_fetcher.MetadataFetcher):
__apiaddress = 'http://lyrics.wikia.com/api.php'
def fetch(self, song):
+ query = QtCore.QUrlQuery()
+ query.setQueryItems([('func', 'getArtist'), ('artist', song['?artist']),
+ ('fmt', 'xml'), ('action', 'lyrics')])
+
url = QtCore.QUrl(self.__apiaddress)
- url.setQueryItems([('func', 'getArtist'), ('artist', song['?artist']),
- ('fmt', 'xml'), ('action', 'lyrics')])
+ url.setQuery(query)
self.fetch2(song, url)
self.rep.finished.connect(self.__handle_artist_res)
@@ -328,9 +331,11 @@ class FetchLyricwiki(metadata_fetcher.MetadataFetcher):
return self.finish()
self.logger.info('Found artist: %s'%artist)
+ query = QtCore.QUrlQuery()
+ query.setQueryItems([('action', 'lyrics'), ('func', 'getSong'), ('artist', artist),
+ ('song', self.song['?title']), ('fmt', 'xml')])
url = QtCore.QUrl(self.__apiaddress)
- url.setQueryItems([('action', 'lyrics'), ('func', 'getSong'), ('artist', artist),
- ('song', self.song['?title']), ('fmt', 'xml')])
+ url.setQuery(query)
self.rep = self.nam.get(QtNetwork.QNetworkRequest(url))
self.rep.finished.connect(self.__handle_search_res)
self.rep.error.connect(self.handle_error)
@@ -370,8 +375,10 @@ class FetchAnimelyrics(metadata_fetcher.MetadataFetcher):
name = 'Animelyrics'
def fetch(self, song):
+ query = QtCore.QUrlQuery()
+ query.setQueryItems([('t', 'performer'), ('q', song['?artist'])])
url = QtCore.QUrl('http://www.animelyrics.com/search.php')
- url.setQueryItems([('t', 'performer'), ('q', song['?artist'])])
+ url.setQuery(query)
self.fetch2(song, url)
self.rep.finished.connect(self.__handle_search_res)
diff --git a/nephilim/plugins/Notify.py b/nephilim/plugins/Notify.py
index bb01aab..6ac0be3 100644
--- a/nephilim/plugins/Notify.py
+++ b/nephilim/plugins/Notify.py
@@ -16,7 +16,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
from ..common import sec2min, APPNAME, expand_tags
from ..plugin import Plugin
@@ -25,7 +25,7 @@ from .. import plugins
NOTIFY_PRIORITY_SONG = 1
NOTIFY_PRIORITY_VOLUME = 2
-class winNotify(QtGui.QWidget):
+class winNotify(QtWidgets.QWidget):
parent = None
p = None
@@ -36,7 +36,7 @@ class winNotify(QtGui.QWidget):
text_label = None
def __init__(self, p):
- QtGui.QWidget.__init__(self, p.parent())
+ QtWidgets.QWidget.__init__(self, p.parent())
self.p = p
self.parent = p.parent()
@@ -44,12 +44,12 @@ class winNotify(QtGui.QWidget):
self.timer.setSingleShot(True)
self.timer.timeout.connect(self._hide)
- layout = QtGui.QHBoxLayout()
- self.cover_label = QtGui.QLabel()
- self.text_label = QtGui.QLabel()
+ layout = QtWidgets.QHBoxLayout()
+ self.cover_label = QtWidgets.QLabel()
+ self.text_label = QtWidgets.QLabel()
self.text_label.setWordWrap(True)
- self.setLayout(QtGui.QHBoxLayout())
+ self.setLayout(QtWidgets.QHBoxLayout())
self.layout().addWidget(self.cover_label)
self.layout().addWidget(self.text_label)
@@ -60,7 +60,7 @@ class winNotify(QtGui.QWidget):
font.setPixelSize(20)
self.setFont(font)
- ac = QtGui.QApplication.instance().plugins.plugin('AlbumCover')
+ ac = QtWidgets.QApplication.instance().plugins.plugin('AlbumCover')
if ac:
ac.cover_changed.connect(self.on_cover_changed)
@@ -91,7 +91,7 @@ class winNotify(QtGui.QWidget):
self._current_priority = -1
def centerH(self):
- screen = QtGui.QDesktopWidget().screenGeometry()
+ screen = QtWidgets.QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width()-size.width())/2, 100)
@@ -142,12 +142,12 @@ class Notify(Plugin):
Plugin.SettingsWidget.__init__(self, plugin)
self.settings.beginGroup(self.plugin.name)
- self.format = QtGui.QLineEdit(self.settings.value('songformat'))
+ self.format = QtWidgets.QLineEdit(self.settings.value('songformat'))
- self.timer = QtGui.QLineEdit(self.settings.value('timer'))
+ self.timer = QtWidgets.QLineEdit(self.settings.value('timer'))
self.timer.setValidator(QtGui.QIntValidator(self.timer))
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self._add_widget(self.format, 'Format', 'Format of notifications. All tags supported by MPD\n'
'will be expanded to their values for current song,\n'
'e.g. ${track}, ${title}, ${artist}, ${album}, ${length}, ${date}, etc.')
diff --git a/nephilim/plugins/PlayControl.py b/nephilim/plugins/PlayControl.py
index 4bba711..c7bafa3 100644
--- a/nephilim/plugins/PlayControl.py
+++ b/nephilim/plugins/PlayControl.py
@@ -15,13 +15,13 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
from ..common import Button
from ..plugin import Plugin
from .. import icons
-class wgPlayControl(QtGui.QToolBar):
+class wgPlayControl(QtWidgets.QToolBar):
"""Displays controls for interacting with playing, like play, volume ..."""
" control buttons"
play_icon = None
@@ -40,10 +40,10 @@ class wgPlayControl(QtGui.QToolBar):
logger = None
xfade = None
- class VolumeSlider(QtGui.QSlider):
+ class VolumeSlider(QtWidgets.QSlider):
def __init__(self, parent):
- QtGui.QSlider.__init__(self, parent)
+ QtWidgets.QSlider.__init__(self, parent)
self.setOrientation(parent.orientation())
self.setMaximum(100)
self.setToolTip('Volume control')
@@ -62,7 +62,7 @@ class wgPlayControl(QtGui.QToolBar):
painter.fillRect(rect, QtGui.QBrush(grad))
def __init__(self, p, parent = None):
- QtGui.QToolBar.__init__(self, p.name, parent)
+ QtWidgets.QToolBar.__init__(self, p.name, parent)
self.setMovable(True)
self.p = p
self.logger = p.logger
@@ -109,14 +109,14 @@ class wgPlayControl(QtGui.QToolBar):
self.p.mpclient.consume_changed.connect(self.consume.setChecked)
self.consume.toggled.connect(self.p.mpclient.consume)
- self.xfade = QtGui.QSpinBox(self)
+ self.xfade = QtWidgets.QSpinBox(self)
self.xfade.setValue(self.p.mpclient.status['xfade'])
self.p.mpclient.crossfade_changed.connect(self.xfade.setValue)
self.xfade.valueChanged.connect(self.p.mpclient.crossfade)
self.xfade.setToolTip('Set crossfade between songs in seconds.')
self.addWidget(self.xfade)
- self.outputs_menu = QtGui.QMenu('Audio outputs')
+ self.outputs_menu = QtWidgets.QMenu('Audio outputs')
outputs = self.addAction(QtGui.QIcon(':icons/outputs.png'), 'Audio outputs')
outputs.triggered.connect(lambda : self.outputs_menu.popup(QtGui.QCursor.pos()))
self.__update_outputs()
@@ -181,7 +181,7 @@ class PlayControl(Plugin):
def _load(self):
self.o = wgPlayControl(self, None)
- QtGui.QApplication.instance().main_win.addToolBar(QtCore.Qt.TopToolBarArea, self.o)
+ QtWidgets.QApplication.instance().main_win.addToolBar(QtCore.Qt.TopToolBarArea, self.o)
def _unload(self):
- QtGui.QApplication.instance().main_win.removeToolBar(self.o)
+ QtWidgets.QApplication.instance().main_win.removeToolBar(self.o)
self.o = None
diff --git a/nephilim/plugins/Playlist.py b/nephilim/plugins/Playlist.py
index d7a2f4e..a3373a1 100644
--- a/nephilim/plugins/Playlist.py
+++ b/nephilim/plugins/Playlist.py
@@ -15,7 +15,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
from ..plugin import Plugin
from ..common import MIMETYPES, SongsMimeData
@@ -39,39 +39,39 @@ class Playlist(Plugin):
def _get_dock_widget(self):
return self._create_dock(self.o)
-class PlaylistWidget(QtGui.QWidget):
+class PlaylistWidget(QtWidgets.QWidget):
plugin = None
playlist = None
toolbar = None
def __init__(self, plugin):
- QtGui.QWidget.__init__(self)
+ QtWidgets.QWidget.__init__(self)
self.plugin = plugin
self.playlist = PlaylistTree(self.plugin)
- self.toolbar = QtGui.QToolBar(self.plugin.name + ' toolbar', self)
+ self.toolbar = QtWidgets.QToolBar(self.plugin.name + ' toolbar', self)
self.toolbar.addAction(QtGui.QIcon(':icons/shuffle.png'), 'Shuffle current playlist.', self.plugin.mpclient.shuffle)
self.toolbar.addAction(QtGui.QIcon(':icons/delete.png'), 'Clear current playlist.', self.plugin.mpclient.clear)
add_url = PlaylistAddURL(self.plugin.mpclient, self)
add_url.setToolTip('Add an URL to current playlist.')
self.toolbar.addWidget(add_url)
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self.layout().setSpacing(0)
- self.layout().setMargin(0)
+ self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().addWidget(self.toolbar)
self.layout().addWidget(self.playlist)
self.plugin.mpclient.playlist(self.playlist.fill)
-class PlaylistAddURL(QtGui.QLineEdit):
+class PlaylistAddURL(QtWidgets.QLineEdit):
### PRIVATE ####
_mpclient = None
def __init__(self, mpclient, parent = None):
- QtGui.QLineEdit.__init__(self, parent)
+ QtWidgets.QLineEdit.__init__(self, parent)
self._mpclient = mpclient
self.returnPressed.connect(self._return_pressed)
@@ -79,7 +79,7 @@ class PlaylistAddURL(QtGui.QLineEdit):
self._mpclient.add([self.text()])
self.clear()
-class PlaylistTree(QtGui.QTreeWidget):
+class PlaylistTree(QtWidgets.QTreeWidget):
plugin = None
### PRIVATE ###
@@ -91,17 +91,17 @@ class PlaylistTree(QtGui.QTreeWidget):
_cur_song = None
def __init__(self, plugin):
- QtGui.QTreeWidget.__init__(self)
+ QtWidgets.QTreeWidget.__init__(self)
self.plugin = plugin
- self.setSelectionMode(QtGui.QTreeWidget.ExtendedSelection)
+ self.setSelectionMode(QtWidgets.QTreeWidget.ExtendedSelection)
self.setAlternatingRowColors(True)
self.setRootIsDecorated(False)
# drag&drop
self.viewport().setAcceptDrops(True)
self.setDropIndicatorShown(True)
- self.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
+ self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)
columns = self.plugin.settings.value(self.plugin.name + '/columns')
self.setColumnCount(len(columns))
@@ -109,7 +109,7 @@ class PlaylistTree(QtGui.QTreeWidget):
self.header().restoreState(self.plugin.settings.value(self.plugin.name + '/header_state'))
# menu
- self._menu = QtGui.QMenu()
+ self._menu = QtWidgets.QMenu()
self._same_menu = self._menu.addMenu('Add same...')
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self._show_context_menu)
@@ -158,7 +158,7 @@ class PlaylistTree(QtGui.QTreeWidget):
self.plugin.mpclient.delete(ids)
else:
- QtGui.QTreeWidget.keyPressEvent(self, event)
+ QtWidgets.QTreeWidget.keyPressEvent(self, event)
def mimeData(self, items):
data = SongsMimeData()
@@ -202,12 +202,12 @@ class PlaylistTree(QtGui.QTreeWidget):
return
self._menu.popup(self.mapToGlobal(pos))
-class PlaylistSongItem(QtGui.QTreeWidgetItem):
+class PlaylistSongItem(QtWidgets.QTreeWidgetItem):
### PUBLIC ###
song = None
def __init__(self, song):
- QtGui.QTreeWidgetItem.__init__(self)
+ QtWidgets.QTreeWidgetItem.__init__(self)
self.song = song
def set_current(self, val):
diff --git a/nephilim/plugins/Songinfo.py b/nephilim/plugins/Songinfo.py
index 88496f6..d0d8ced 100644
--- a/nephilim/plugins/Songinfo.py
+++ b/nephilim/plugins/Songinfo.py
@@ -15,7 +15,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
from ..plugin import Plugin
@@ -71,7 +71,7 @@ class Songinfo(Plugin):
self.o.set_metadata(metadata)
self.mpclient.sticker_list(song['file'], self.o.set_stickers)
-class SonginfoWidget(QtGui.QWidget):
+class SonginfoWidget(QtWidgets.QWidget):
#### PUBLIC ####
"parent plugin"
@@ -84,16 +84,16 @@ class SonginfoWidget(QtGui.QWidget):
#### PUBLIC ####
def __init__(self, plugin):
- QtGui.QWidget.__init__(self)
+ QtWidgets.QWidget.__init__(self)
self.plugin = plugin
self._labels = {}
- self._st_label = QtGui.QLabel('<b>Stickers:</b>', self)
+ self._st_label = QtWidgets.QLabel('<b>Stickers:</b>', self)
self._st_label.setAlignment(QtCore.Qt.AlignHCenter)
self._stickers = StickersList(self.plugin.mpclient, self)
- self.setLayout(QtGui.QGridLayout())
+ self.setLayout(QtWidgets.QGridLayout())
self.layout().setColumnStretch(1, 1)
def set_tagtypes(self, tagtypes):
@@ -113,8 +113,8 @@ class SonginfoWidget(QtGui.QWidget):
self.layout().removeWidget(self._stickers)
for tag in tagtypes:
- label = QtGui.QLabel('<b>%s</b>'%tag) #TODO sort known tags
- label1 = QtGui.QLabel() # tag value will go here
+ label = QtWidgets.QLabel('<b>%s</b>'%tag) #TODO sort known tags
+ label1 = QtWidgets.QLabel() # tag value will go here
label1.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
label.setWordWrap(True)
label1.setWordWrap(True)
@@ -148,12 +148,12 @@ class SettingsWidgetSonginfo(Plugin.SettingsWidget):
Plugin.SettingsWidget.__init__(self, plugin)
self.settings.beginGroup(self.plugin.name)
- self._taglist = QtGui.QListWidget(self)
- self._taglist.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
+ self._taglist = QtWidgets.QListWidget(self)
+ self._taglist.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
self._update_tags()
self.plugin.mpclient.connect_changed.connect(self._update_tags)
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self._add_widget(self._taglist, label = 'Tags', tooltip = 'A list of tags that should be displayed.\n'
'Use drag and drop to change their order')
@@ -181,21 +181,21 @@ class SettingsWidgetSonginfo(Plugin.SettingsWidget):
tags_enabled = self.settings.value('tagtypes')
tags = self.plugin.mpclient.tagtypes
for tag in [tag for tag in tags_enabled if tag in tags]:
- it = QtGui.QListWidgetItem(tag)
+ it = QtWidgets.QListWidgetItem(tag)
it.setCheckState(QtCore.Qt.Checked)
self._taglist.addItem(it)
for tag in [tag for tag in tags if tag not in tags_enabled]:
- it = QtGui.QListWidgetItem(tag)
+ it = QtWidgets.QListWidgetItem(tag)
it.setCheckState(QtCore.Qt.Unchecked)
self._taglist.addItem(it)
-class StickersList(QtGui.QTreeWidget):
+class StickersList(QtWidgets.QTreeWidget):
#### PUBLIC ####
mpclient = None
def __init__(self, mpclient, parent):
- QtGui.QTreeWidget.__init__(self, parent)
+ QtWidgets.QTreeWidget.__init__(self, parent)
self.mpclient = mpclient
self.setAlternatingRowColors(True)
@@ -207,5 +207,5 @@ class StickersList(QtGui.QTreeWidget):
"""Set displayed stickers from a (key, value) iterator."""
self.clear()
for key, value in stickers:
- it = QtGui.QTreeWidgetItem([key, value])
+ it = QtWidgets.QTreeWidgetItem([key, value])
self.addTopLevelItem(it)
diff --git a/nephilim/plugins/Systray.py b/nephilim/plugins/Systray.py
index 2411309..749a0c6 100644
--- a/nephilim/plugins/Systray.py
+++ b/nephilim/plugins/Systray.py
@@ -16,7 +16,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
from ..plugin import Plugin
from ..common import sec2min, APPNAME, appIcon, expand_tags
@@ -40,14 +40,14 @@ class Systray(Plugin):
"""This class listens for systray-wheel events"""
def eventFilter(self, object, event):
if type(event)==QtGui.QWheelEvent:
- numDegrees=event.delta() / 8
+ numDegrees=event.angleDelta().y() / 8
numSteps=5*numDegrees/15
self.plugin.mpclient.set_volume(self.plugin.mpclient.status['volume'] + numSteps)
event.accept()
return True
return False
- self.o = QtGui.QSystemTrayIcon(QtGui.QIcon(appIcon), self.parent())
+ self.o = QtWidgets.QSystemTrayIcon(QtGui.QIcon(appIcon), self.parent())
self.eventObj=SystrayWheelEventObject()
self.eventObj.plugin = self
self.o.installEventFilter(self.eventObj)
@@ -99,9 +99,9 @@ class Systray(Plugin):
def __init__(self, plugin):
Plugin.SettingsWidget.__init__(self, plugin)
- self.format = QtGui.QLineEdit(self.settings.value(self.plugin.name + '/format'))
+ self.format = QtWidgets.QLineEdit(self.settings.value(self.plugin.name + '/format'))
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self._add_widget(self.format, 'Tooltip format')
def save_settings(self):
diff --git a/nephilim/settings_wg.py b/nephilim/settings_wg.py
index c1ae182..9710176 100644
--- a/nephilim/settings_wg.py
+++ b/nephilim/settings_wg.py
@@ -16,14 +16,14 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtGui, QtCore
+from PyQt5 import QtGui, QtWidgets, QtCore
import os
from common import Button
import plugin
-class SettingsWidget(QtGui.QWidget):
+class SettingsWidget(QtWidgets.QWidget):
save_btn = None
close_btn = None
pluginlist = None
@@ -45,15 +45,15 @@ class SettingsWidget(QtGui.QWidget):
self.mpclient = mpclient
self.settings.beginGroup('MPD')
- self.host_txt = QtGui.QLineEdit(self.settings.value('host', 'localhost'))
- self.port_txt = QtGui.QLineEdit(self.settings.value('port', '6600'))
+ self.host_txt = QtWidgets.QLineEdit(self.settings.value('host', 'localhost'))
+ self.port_txt = QtWidgets.QLineEdit(self.settings.value('port', '6600'))
self.port_txt.setValidator(QtGui.QIntValidator(0, 65535, self))
- self.pass_txt = QtGui.QLineEdit(self.settings.value('password'))
- self.pass_txt.setEchoMode(QtGui.QLineEdit.Password)
- self.lib_txt = QtGui.QLineEdit(self.settings.value('music_dir', os.path.expanduser('~/music/')))
+ self.pass_txt = QtWidgets.QLineEdit(self.settings.value('password'))
+ self.pass_txt.setEchoMode(QtWidgets.QLineEdit.Password)
+ self.lib_txt = QtWidgets.QLineEdit(self.settings.value('music_dir', os.path.expanduser('~/music/')))
self.settings.endGroup()
- self.setLayout(QtGui.QVBoxLayout())
+ self.setLayout(QtWidgets.QVBoxLayout())
self._add_widget(self.host_txt, 'Host', 'Host or socket to connect to')
self._add_widget(self.port_txt, 'Port', 'Port to use (empty when using sockets)')
self._add_widget(self.pass_txt, 'Password', 'Password')
@@ -81,7 +81,7 @@ class SettingsWidget(QtGui.QWidget):
self.mpclient.connect_mpd(self.host_txt.text(), int(self.port_txt.text()), self.pass_txt.text())
def __init__(self, mpclient, plugins):
- QtGui.QWidget.__init__(self, None, QtCore.Qt.Window)
+ QtWidgets.QWidget.__init__(self, None, QtCore.Qt.Window)
self.settings = QtCore.QSettings()
self.plugins = plugins
self.mpclient = mpclient
@@ -89,12 +89,12 @@ class SettingsWidget(QtGui.QWidget):
self.save_btn = Button('save all', self.save_clicked)
self.close_btn = Button('close', self.close_clicked)
- tab_wg = QtGui.QTabWidget(self)
+ tab_wg = QtWidgets.QTabWidget(self)
self.settings_wg = []
self.settings_wg.append(self.SettingsWidgetMPD(mpclient))
tab_wg.addTab(self.settings_wg[-1], 'MPD settings')
- self.pluginlist = QtGui.QListWidget(self)
+ self.pluginlist = QtWidgets.QListWidget(self)
self.fill_pluginlist()
tab_wg.addTab(self.pluginlist, 'Plugins')
@@ -104,7 +104,7 @@ class SettingsWidget(QtGui.QWidget):
self.settings_wg.append(wg)
tab_wg.addTab(self.settings_wg[-1], plugin.name)
- self.setLayout(QtGui.QGridLayout())
+ self.setLayout(QtWidgets.QGridLayout())
self.layout().addWidget(tab_wg, 0, 0, 1, 2)
self.layout().addWidget(self.save_btn, 1, 0)
self.layout().addWidget(self.close_btn, 1, 1)
@@ -119,7 +119,7 @@ class SettingsWidget(QtGui.QWidget):
def fill_pluginlist(self):
self.pluginlist.clear()
for plugin in self.plugins.plugins():
- item = QtGui.QListWidgetItem("%s\t%s"%(plugin.name, plugin.info))
+ item = QtWidgets.QListWidgetItem("%s\t%s"%(plugin.name, plugin.info))
if plugin.loaded:
item.setCheckState(QtCore.Qt.Checked)
else:
@@ -128,7 +128,7 @@ class SettingsWidget(QtGui.QWidget):
self.pluginlist.addItem(item)
def center(self):
- screen = QtGui.QDesktopWidget().screenGeometry()
+ screen = QtWidgets.QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2+100)
diff --git a/nephilim/song.py b/nephilim/song.py
index d68b21c..b0891df 100644
--- a/nephilim/song.py
+++ b/nephilim/song.py
@@ -15,7 +15,7 @@
# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
#
-from PyQt4 import QtCore
+from PyQt5 import QtCore
import os
from string import Template