Hi.
I have completed the plugin.
You can select everything in the right panel or any number and order.
After each selection (blue background of the bar) you need to call the plugin.
|
|
Code:
PLUGIN_NAME = "Statistics"
PLUGIN_AUTHOR = "Echelon"
PLUGIN_DESCRIPTION = "Counts the types of albums from the selection in the right Picard panel"
PLUGIN_VERSION = '0.1'
PLUGIN_API_VERSIONS = ['2.2']
PLUGIN_LICENSE = "GPL-2.0-or-later"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.html"
from PyQt5 import QtGui
from PyQt5.QtWidgets import QLabel, QGridLayout, QWidget
from PyQt5.QtGui import QPixmap, QIcon
from picard.ui.itemviews import BaseAction, register_album_action
statwindow = QWidget()
statwindow.setStyleSheet("font-size:12pt;")
grid = QGridLayout()
statwindow.setLayout(grid)
statwindow.setGeometry(750, 200, 400, 150)
statwindow.setWindowTitle("Statistics")
statwindow.setWindowIcon(QtGui.QIcon(":/images/16x16/org.musicbrainz.Picard.png"))
class AlbumCounter(BaseAction):
NAME = "Statistics"
def callback(self, objs):
A = 0
B = 0
C = 0
D = 0
E = 0
T = 0
while grid.count():
item = grid.takeAt(0)
widget = item.widget()
if widget is not None:
widget.clear()
text1 = QLabel("Album unchanged")
text2 = QLabel("Album modified")
text3 = QLabel("Album unchanged and complete ")
text4 = QLabel("Album modified and complete")
text5 = QLabel("Album errors")
text6 = QLabel("Total")
grid.addWidget(text1, 0, 0)
grid.addWidget(text2, 1, 0)
grid.addWidget(text3, 2, 0)
grid.addWidget(text4, 3, 0)
grid.addWidget(text5, 4, 0)
grid.addWidget(text6, 5, 0)
icon1 = QLabel()
icon1.setPixmap(QPixmap(":/images/22x22/media-optical.png"))
icon2 = QLabel()
icon2.setPixmap(QPixmap(":/images/22x22/media-optical-modified.png"))
icon3 = QLabel()
icon3.setPixmap(QPixmap(":/images/22x22/media-optical-saved.png"))
icon4 = QLabel()
icon4.setPixmap(QPixmap(":/images/22x22/media-optical-saved-modified.png"))
icon5 = QLabel()
icon5.setPixmap(QPixmap(":/images/22x22/media-optical-error.png"))
grid.addWidget(icon1, 0, 2)
grid.addWidget(icon2, 1, 2)
grid.addWidget(icon3, 2, 2)
grid.addWidget(icon4, 3, 2)
grid.addWidget(icon5, 4, 2)
for album in objs:
if album.errors:
E = E + 1
elif album.is_complete():
if album.is_modified():
D = D + 1
else:
C = C + 1
else:
if album.is_modified():
B = B + 1
else:
A = A + 1
T = A + B + C + D + E
text1a = QLabel(str(A))
text2b = QLabel(str(B))
text3c = QLabel(str(C))
text4d = QLabel(str(D))
text5e = QLabel(str(E))
text6t = QLabel(str(T))
grid.addWidget(text1a, 0, 1)
grid.addWidget(text2b, 1, 1)
grid.addWidget(text3c, 2, 1)
grid.addWidget(text4d, 3, 1)
grid.addWidget(text5e, 4, 1)
grid.addWidget(text6t, 5, 1)
statwindow.show()
register_album_action(AlbumCounter())