-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create albums_statistics.py #384
base: 2.0
Are you sure you want to change the base?
Changes from 2 commits
568104d
ba205dd
f2aa95b
db2c11e
edf89bb
bbc52d0
a696fc5
d6305f9
8c07d7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
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.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;") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually avoid hard coding font sizes so Qt uses system defaults. |
||
|
||
class AlbumStats(BaseAction): | ||
NAME = "Statistics" | ||
|
||
def callback(self, objs): | ||
A = B = C = D = E = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those variables should have proper names There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But now we are testing the @Sophist-UK code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - this PR still has your code in it (regardless of what code you are personally working on) - and it the code you submitted (rather than what I posted in a comment) that @phw Philipp has just taken the time and effort to review. As for my code, you are still welcome to use it even though I think you have made it abundantly clear in the forums that you do not appreciate my help. But if you do then:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a new PR from scratch? How to name the plugin and branch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overwrite new code here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Which bit about "You need to push a commit to your PR with my code in it" was unclear? Did I mention creating a new PR? |
||
|
||
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to put this into it's own class. Something like this:
Then this can be used in the callback function:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phw Philipp See my previous rewrite of this code that I made to try to help Peter - I put all the code inside the class, but I suspect that the above comment is still a useful enhancement to my version..