Skip to content
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

Closed
wants to merge 0 commits into from
Closed

PICARD-1177 : Add a option to remove plugins #804

wants to merge 0 commits into from

Conversation

vishichoudhary
Copy link
Contributor

@vishichoudhary vishichoudhary commented Jan 20, 2018

Summary

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other
  • This will add a button to uninstall a plugin:

Problem

Solution

Added a new column in Plugin gui , to uninstall a plugin . Added a confirmation box too

Action

@@ -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)
Copy link
Collaborator

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address this.

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')
Copy link
Collaborator

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.

button.setMaximumHeight(button.fontMetrics().boundingRect(label).height() + 7)
self.ui.plugins.setItemWidget(item, 3, button)

def plugin_remove():
Copy link
Collaborator

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.

msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
msgbox.exec_()
button.released.connect(plugin_remove)
Copy link
Collaborator

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.

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.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/remove/removed

@samj1912
Copy link
Collaborator

Please fix the PR template and link to the Jira ticket.

@samj1912
Copy link
Collaborator

samj1912 commented Jan 21, 2018

image
This is how my picard looks. Why do we need an extra Remove column? you could simply modify the install button to become the uninstall buttons once its installed.Or better yet, keep Status as is and change its value to Installed/ Not installed and keep the install/uninstall button on the side.

@chhavijustme any thoughts on this?

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address this.

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'):
Copy link
Collaborator

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do something like this.
screen shot 2018-01-21 at 7 17 28 pm
Instead of course, following=> uninstall and follow=>install. The important thing here is to keep it looking like a button so that people know it can be clicked.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishichoudhary

  1. 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.

  2. If an update is available for all the plugins all the time, then having install/uninstall button and an update button makes more sense.

Copy link
Contributor Author

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?

@vishichoudhary
Copy link
Contributor Author

vishichoudhary commented Jan 21, 2018

@chhavijustme @samj1912 There is already a second operation UPDATE on it so i can't add REMOVE on the same button. :-(

@vishichoudhary
Copy link
Contributor Author

@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?

@samj1912
Copy link
Collaborator

@vishichoudhary yes and you don't need to do any of that. Simply the last line will suffice.
self.tagger.pluginmanager.remove_plugin(plugin.module_name)

You don't need to do the extension checks.

@vishichoudhary
Copy link
Contributor Author

ok @samj1912 i will make changes accordingly. :-)

@vishichoudhary
Copy link
Contributor Author

@chhavijustme i didn't get you on your last point. Can you please explain it bit more? :-)

@@ -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"))
Copy link
Collaborator

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.

@vishichoudhary
Copy link
Contributor Author

Messed up with this branch, as it's on my master branch , will pr again with new branch and with some more fixes. Sorry :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants