From 568104d96719005ac64f064a9925b4e408f29d69 Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Sun, 6 Oct 2024 23:10:58 +0200 Subject: [PATCH 1/9] Create albums_statistics.py --- .../albums_statistics/albums_statistics.py | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 plugins/albums_statistics/albums_statistics.py diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py new file mode 100644 index 00000000..04a44794 --- /dev/null +++ b/plugins/albums_statistics/albums_statistics.py @@ -0,0 +1,93 @@ +PLUGIN_NAME = "Albums Statistics" +PLUGIN_AUTHOR = "Echelon" +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" +PLUGIN_DESCRIPTION = '''Counts the quality or status of albums. + +A - An integer variable counting albums Incomplete & unchanged, +B - An integer variable counting albums Incomplete & modified, +C - An integer variable counting albums Complete & unchanged, +D - An integer variable counting albums Complete & modified, +E - An integer variable counting albums Errored, +T - An integer variable summing up the above variables''' + +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() +grid = QGridLayout() + +statwindow.setLayout(grid) +statwindow.setGeometry(100, 100, 400, 200) +statwindow.setWindowTitle("Albums Statistics") +statwindow.setWindowIcon(QtGui.QIcon(":/images/16x16/org.musicbrainz.Picard.png")) +statwindow.setStyleSheet("font-size:12pt;") + +class AlbumStats(BaseAction): + NAME = "Statistics" + + def callback(self, objs): + A = B = C = D = E = 0 + + while grid.count(): + item = grid.takeAt(0) + widget = item.widget() + if widget is not None: + widget.clear() + + 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, 1, 0) + grid.addWidget(icon2, 2, 0) + grid.addWidget(icon3, 3, 0) + grid.addWidget(icon4, 4, 0) + grid.addWidget(icon5, 5, 0) + + grid.addWidget(QLabel("The status of the selected Albums is as follows:"), 0, 0, 1, 3) + grid.addWidget(QLabel("Incomplete & unchanged"), 1, 2) + grid.addWidget(QLabel("Incomplete & modified"), 2, 2) + grid.addWidget(QLabel("Complete & unchanged"), 3, 2) + grid.addWidget(QLabel("Complete & modified"), 4, 2) + grid.addWidget(QLabel("Errored"), 5, 2) + grid.addWidget(QLabel("Total"), 6, 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 + + grid.addWidget(QLabel(str(A)), 1, 1) + grid.addWidget(QLabel(str(B)), 2, 1) + grid.addWidget(QLabel(str(C)), 3, 1) + grid.addWidget(QLabel(str(D)), 4, 1) + grid.addWidget(QLabel(str(E)), 5, 1) + grid.addWidget(QLabel(str(T)), 6, 1) + + statwindow.show() + +register_album_action(AlbumStats()) \ No newline at end of file From ba205dd1f75028a2089c4075c820b2c7ad8a408b Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Sun, 6 Oct 2024 23:27:16 +0200 Subject: [PATCH 2/9] Update albums_statistics.py --- plugins/albums_statistics/albums_statistics.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index 04a44794..203b3b98 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -13,7 +13,6 @@ E - An integer variable counting albums Errored, T - An integer variable summing up the above variables''' -from PyQt5 import QtGui from PyQt5.QtWidgets import QLabel, QGridLayout, QWidget from PyQt5.QtGui import QPixmap, QIcon @@ -25,7 +24,7 @@ statwindow.setLayout(grid) statwindow.setGeometry(100, 100, 400, 200) statwindow.setWindowTitle("Albums Statistics") -statwindow.setWindowIcon(QtGui.QIcon(":/images/16x16/org.musicbrainz.Picard.png")) +statwindow.setWindowIcon(QIcon(":/images/16x16/org.musicbrainz.Picard.png")) statwindow.setStyleSheet("font-size:12pt;") class AlbumStats(BaseAction): From f2aa95bd3cf8934d628fe73c92600ed05752b4ed Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Thu, 7 Nov 2024 12:10:03 +0100 Subject: [PATCH 3/9] Update albums_statistics.py --- .../albums_statistics/albums_statistics.py | 125 +++++++++--------- 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index 203b3b98..69cb5578 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -1,92 +1,87 @@ PLUGIN_NAME = "Albums Statistics" PLUGIN_AUTHOR = "Echelon" +PLUGIN_DESCRIPTION = "Summarises the status of selected albums e.g. Changed?, Complete? Error?" 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" -PLUGIN_DESCRIPTION = '''Counts the quality or status of albums. - -A - An integer variable counting albums Incomplete & unchanged, -B - An integer variable counting albums Incomplete & modified, -C - An integer variable counting albums Complete & unchanged, -D - An integer variable counting albums Complete & modified, -E - An integer variable counting albums Errored, -T - An integer variable summing up the above variables''' +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() -grid = QGridLayout() - -statwindow.setLayout(grid) -statwindow.setGeometry(100, 100, 400, 200) -statwindow.setWindowTitle("Albums Statistics") -statwindow.setWindowIcon(QIcon(":/images/16x16/org.musicbrainz.Picard.png")) -statwindow.setStyleSheet("font-size:12pt;") - -class AlbumStats(BaseAction): - NAME = "Statistics" +class AlbumsStats(BaseAction): + NAME = "Albums Statistics" + + def __init__(self): + # Create grid hidden + self.grid = QGridLayout() + self.grid.addWidget(QLabel(_("The status of the selected Albums is as follows:")), 0, 0, 1, 3) + + self.addGridRow(1, ":/images/22x22/media-optical.png", + _("Incomplete & unchanged")) + self.addGridRow(2, ":/images/22x22/media-optical-modified.png", + _("Incomplete & modified")) + self.addGridRow(3, ":/images/22x22/media-optical-saved.png", + _("Complete & unchanged")) + self.addGridRow(4, ":/images/22x22/media-optical-saved-modified.png", + _("Complete & modified")) + self.addGridRow(5, ":/images/22x22/media-optical-error.png", + _("Errored")) + self.addGridRow(6, "", + _("Total")) + + self.grid.addWidget(QLabel("Total"), 6, 2) + + self.window = QWidget() + self.window.setLayout(self.grid) + self.window.setGeometry(100, 100, 400, 200) + self.window.setWindowTitle(_("Albums Statistics")) + self.window.setWindowIcon(QIcon(":/images/16x16/org.musicbrainz.Picard.png")) + self.window.setStyleSheet("font-size:12pt;") + + def addGridRow(self, row, icon_location, description): + icon = QLabel() + if icon_location: + icon.setPixmap(QPixmap(icon_location)) + self.grid.addWidget(icon, row, 0) + + self.grid.addWidget(QLabel(""), row, 1) + + self.grid.addWidget(QLabel(description), row, 2) + + def setCounter(self, row, count): + counter = self.grid.itemAtPosition(row, 1) + counter.setText(str(count)) def callback(self, objs): - A = B = C = D = E = 0 - - while grid.count(): - item = grid.takeAt(0) - widget = item.widget() - if widget is not None: - widget.clear() - - 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, 1, 0) - grid.addWidget(icon2, 2, 0) - grid.addWidget(icon3, 3, 0) - grid.addWidget(icon4, 4, 0) - grid.addWidget(icon5, 5, 0) - - grid.addWidget(QLabel("The status of the selected Albums is as follows:"), 0, 0, 1, 3) - grid.addWidget(QLabel("Incomplete & unchanged"), 1, 2) - grid.addWidget(QLabel("Incomplete & modified"), 2, 2) - grid.addWidget(QLabel("Complete & unchanged"), 3, 2) - grid.addWidget(QLabel("Complete & modified"), 4, 2) - grid.addWidget(QLabel("Errored"), 5, 2) - grid.addWidget(QLabel("Total"), 6, 2) + incomplete_unchanged = incomplete_modified = complete_unchanged = complete_modified = errored = 0 for album in objs: if album.errors: - E = E + 1 + errored += 1 elif album.is_complete(): if album.is_modified(): - D = D + 1 + complete_modified += 1 else: - C = C + 1 + complete_unchanged += 1 else: if album.is_modified(): - B = B + 1 + incomplete_modified += 1 else: - A = A + 1 + incomplete_unchanged += 1 - T = A + B + C + D + E + total = incomplete_unchanged + incomplete_modified + complete_unchanged + complete_modified + errored - grid.addWidget(QLabel(str(A)), 1, 1) - grid.addWidget(QLabel(str(B)), 2, 1) - grid.addWidget(QLabel(str(C)), 3, 1) - grid.addWidget(QLabel(str(D)), 4, 1) - grid.addWidget(QLabel(str(E)), 5, 1) - grid.addWidget(QLabel(str(T)), 6, 1) + self.setCounter(1, incomplete_unchanged) + self.setCounter(2, incomplete_modified) + self.setCounter(3, complete_unchanged) + self.setCounter(4, complete_modified) + self.setCounter(5, errored) + self.setCounter(6, total) - statwindow.show() + self.window.show() -register_album_action(AlbumStats()) \ No newline at end of file +register_album_action(AlbumsStats()) \ No newline at end of file From db2c11e8f43507f89e03415303be19cd6f0f9376 Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Thu, 7 Nov 2024 12:13:32 +0100 Subject: [PATCH 4/9] Update albums_statistics.py --- plugins/albums_statistics/albums_statistics.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index 69cb5578..b587236e 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -6,7 +6,6 @@ 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 edf89bbb52e137459ecdda45ca815f4943e4749b Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:34:42 +0100 Subject: [PATCH 5/9] Update albums_statistics.py I added the 19 line "super().init()" and I detected that setCounter causes Picard to crash. --- plugins/albums_statistics/albums_statistics.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index b587236e..ad9ca471 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -6,6 +6,7 @@ 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 @@ -15,6 +16,8 @@ class AlbumsStats(BaseAction): NAME = "Albums Statistics" def __init__(self): + super().__init__() + # Create grid hidden self.grid = QGridLayout() self.grid.addWidget(QLabel(_("The status of the selected Albums is as follows:")), 0, 0, 1, 3) @@ -73,14 +76,14 @@ def callback(self, objs): incomplete_unchanged += 1 total = incomplete_unchanged + incomplete_modified + complete_unchanged + complete_modified + errored - + ''' self.setCounter(1, incomplete_unchanged) self.setCounter(2, incomplete_modified) self.setCounter(3, complete_unchanged) self.setCounter(4, complete_modified) self.setCounter(5, errored) self.setCounter(6, total) - + ''' self.window.show() register_album_action(AlbumsStats()) \ No newline at end of file From bbc52d079aeaace67969e0e567a9a59bbe914274 Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:42:57 +0100 Subject: [PATCH 6/9] Update albums_statistics.py I removed the 9th unused line and comments to help find the conflict. --- plugins/albums_statistics/albums_statistics.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index ad9ca471..15020dfd 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -6,7 +6,6 @@ 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 @@ -76,14 +75,14 @@ def callback(self, objs): incomplete_unchanged += 1 total = incomplete_unchanged + incomplete_modified + complete_unchanged + complete_modified + errored - ''' + self.setCounter(1, incomplete_unchanged) self.setCounter(2, incomplete_modified) self.setCounter(3, complete_unchanged) self.setCounter(4, complete_modified) self.setCounter(5, errored) self.setCounter(6, total) - ''' + self.window.show() register_album_action(AlbumsStats()) \ No newline at end of file From a696fc5d814395177e361d6ad992172f54d64130 Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:52:29 +0100 Subject: [PATCH 7/9] Update albums_statistics.py I delete Trailing whitespace --- plugins/albums_statistics/albums_statistics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index 15020dfd..e1c6cce7 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -75,14 +75,14 @@ def callback(self, objs): incomplete_unchanged += 1 total = incomplete_unchanged + incomplete_modified + complete_unchanged + complete_modified + errored - + self.setCounter(1, incomplete_unchanged) self.setCounter(2, incomplete_modified) self.setCounter(3, complete_unchanged) self.setCounter(4, complete_modified) self.setCounter(5, errored) self.setCounter(6, total) - + self.window.show() register_album_action(AlbumsStats()) \ No newline at end of file From d6305f933bca48e51481e687bf17f8a26cebc44d Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:37:43 +0100 Subject: [PATCH 8/9] Update albums_statistics.py Current, final, working version --- .../albums_statistics/albums_statistics.py | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index e1c6cce7..9806df0f 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -17,10 +17,16 @@ class AlbumsStats(BaseAction): def __init__(self): super().__init__() - # Create grid hidden self.grid = QGridLayout() - self.grid.addWidget(QLabel(_("The status of the selected Albums is as follows:")), 0, 0, 1, 3) + self.window = QWidget() + self.window.setLayout(self.grid) + self.window.setGeometry(100, 100, 400, 250) + self.window.setWindowTitle(_("Albums Statistics")) + self.window.setWindowIcon(QIcon(":/images/16x16/org.musicbrainz.Picard.png")) + self.window.setStyleSheet("font-size:12pt;") + def createWidget(self): + self.grid.addWidget(QLabel(_("The status of the selected Albums is as follows:")), 0, 0, 1, 3) self.addGridRow(1, ":/images/22x22/media-optical.png", _("Incomplete & unchanged")) self.addGridRow(2, ":/images/22x22/media-optical-modified.png", @@ -33,33 +39,32 @@ def __init__(self): _("Errored")) self.addGridRow(6, "", _("Total")) - self.grid.addWidget(QLabel("Total"), 6, 2) - self.window = QWidget() - self.window.setLayout(self.grid) - self.window.setGeometry(100, 100, 400, 200) - self.window.setWindowTitle(_("Albums Statistics")) - self.window.setWindowIcon(QIcon(":/images/16x16/org.musicbrainz.Picard.png")) - self.window.setStyleSheet("font-size:12pt;") + def clearWidget(self): + while self.grid.count(): + item = self.grid.takeAt(0) + widget = item.widget() + if widget is not None: + widget.clear() def addGridRow(self, row, icon_location, description): icon = QLabel() if icon_location: icon.setPixmap(QPixmap(icon_location)) self.grid.addWidget(icon, row, 0) - self.grid.addWidget(QLabel(""), row, 1) - self.grid.addWidget(QLabel(description), row, 2) def setCounter(self, row, count): - counter = self.grid.itemAtPosition(row, 1) - counter.setText(str(count)) + self.grid.addWidget(QLabel(str(count)), row, 1) def callback(self, objs): incomplete_unchanged = incomplete_modified = complete_unchanged = complete_modified = errored = 0 + self.clearWidget() + self.createWidget() + for album in objs: if album.errors: errored += 1 From 8c07d7b5146e109c647c3f452527422d318aee66 Mon Sep 17 00:00:00 2001 From: Echelon666 <151920667+Echelon666@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:42:47 +0100 Subject: [PATCH 9/9] Update albums_statistics.py I delete one whitespace --- plugins/albums_statistics/albums_statistics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/albums_statistics/albums_statistics.py b/plugins/albums_statistics/albums_statistics.py index 9806df0f..b35d1c20 100644 --- a/plugins/albums_statistics/albums_statistics.py +++ b/plugins/albums_statistics/albums_statistics.py @@ -45,7 +45,7 @@ def clearWidget(self): while self.grid.count(): item = self.grid.takeAt(0) widget = item.widget() - if widget is not None: + if widget is not None: widget.clear() def addGridRow(self, row, icon_location, description):