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
PICARD-1177 : Add a option to remove plugins #804
Conversation
picard/ui/options/plugins.py
Outdated
@@ -269,6 +269,22 @@ def download_button_process(): | |||
else: | |||
label = _("Installed") | |||
self.ui.plugins.setItemWidget(item, 2, QtWidgets.QLabel(label)) | |||
button = QtWidgets.QPushButton(_("Uninstall")) | |||
button.setMaximumHeight(button.fontMetrics().boundingRect(label).height() + 7) |
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.
Why this arbitrary +7? Do not make UI changes in non ui_*.py files.
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.
Please address this.
picard/ui/options/plugins.py
Outdated
def plugin_remove(): | ||
self.ui.plugins.setCurrentItem(item) | ||
plugin = self.items[self.ui.plugins.selectedItems()[0]] | ||
self.tagger.pluginmanager.remove_plugin(plugin.module_name + '.zip') |
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.
It isn't always a zip. It could also be a single py file or a folder.
picard/ui/options/plugins.py
Outdated
button.setMaximumHeight(button.fontMetrics().boundingRect(label).height() + 7) | ||
self.ui.plugins.setItemWidget(item, 3, button) | ||
|
||
def plugin_remove(): |
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.
Do not introduce function definitions inside other functions.
picard/ui/options/plugins.py
Outdated
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) | ||
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok) | ||
msgbox.exec_() | ||
button.released.connect(plugin_remove) |
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.
You might want to ask for user confirmation here.
picard/ui/options/plugins.py
Outdated
self.tagger.pluginmanager.remove_plugin(plugin.module_name + '.zip') | ||
msgbox = QtWidgets.QMessageBox(self) | ||
msgbox.setText( | ||
_("The plugin '%s' will be remove on next run of Picard.") |
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.
s/remove/removed
Please fix the PR template and link to the Jira ticket. |
@chhavijustme any thoughts on this? |
picard/ui/options/plugins.py
Outdated
@@ -269,6 +269,22 @@ def download_button_process(): | |||
else: | |||
label = _("Installed") | |||
self.ui.plugins.setItemWidget(item, 2, QtWidgets.QLabel(label)) | |||
button = QtWidgets.QPushButton(_("Uninstall")) | |||
button.setMaximumHeight(button.fontMetrics().boundingRect(label).height() + 7) |
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.
Please address this.
picard/ui/options/plugins.py
Outdated
buttonReply = QtWidgets.QMessageBox.question(self,'Uninstall?', "Do you want to uninstall?", | ||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) | ||
if buttonReply == QtWidgets.QMessageBox.Yes: | ||
if os.path.isfile(USER_PLUGIN_DIR+plugin.module_name+'.zip'): |
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 cannot fathom why you need to add extensions to the plugin names. It will only cause erroneous results with remove_plugin. Remove_plugin just expects the plugin name by default. Nothing else. It handles stripping of extensions and deletion of files.
See https://github.com/metabrainz/picard/blob/master/picard/plugin.py#L351
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.
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 don't know the case here, but if update is available for only a few plugins at a time,
You can add an "update" link in front of all plugins whose update is available. -
If an update is available for all the plugins all the time, then having install/uninstall button and an update button makes more sense.
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.
@chhavijustme what about having only one button for install / uninstall and update automatically?
@chhavijustme @samj1912 There is already a second operation UPDATE on it so i can't add REMOVE on the same button. :-( |
@samj1912 , i am extracting the module name only, then i am checking that whether this moudule name exists as .zip or .py or as a folder? |
@vishichoudhary yes and you don't need to do any of that. Simply the last line will suffice. You don't need to do the extension checks. |
ok @samj1912 i will make changes accordingly. :-) |
@chhavijustme i didn't get you on your last point. Can you please explain it bit more? :-) |
picard/ui/ui_options_plugins.py
Outdated
@@ -129,6 +129,7 @@ def retranslateUi(self, PluginsOptionsPage): | |||
self.plugins.headerItem().setText(0, _("Name")) | |||
self.plugins.headerItem().setText(1, _("Version")) | |||
self.plugins.headerItem().setText(2, _("Status")) | |||
self.plugins.headerItem().setText(3, _("Remove")) |
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 would prefer Uninstall
here, if the actual effect for the user is a plugin uninstallation
And since only an installed plugin can be uninstalled, only one button is needed.
Messed up with this branch, as it's on my master branch , will pr again with new branch and with some more fixes. Sorry :-( |
Summary
Problem
Solution
Added a new column in Plugin gui , to uninstall a plugin . Added a confirmation box too
Action