qrevert, need a little help for a change

0 views
Skip to first unread message

André Bachmann

unread,
Feb 10, 2012, 8:33:26 AM2/10/12
to QBzr
Yesterday, a co-worker reported a slight problem with qrevert: If you
open Bazaar, Work, Revert Working Tree... and click OK without doing
anything, you get a BzrCommandError (as it is raised in revert.py in
the function validate). Well, such a message isn't quite user-
friendly. Turning this in to a nicer QtGui.QMessageBox.warning and
returning False isn't a problem. I have changed

raise errors.BzrCommandError("You have not selected anything to
revert.")

to

warningbox = QtGui.QMessageBox.warning(self, self.windowTitle(),
gettext("You have not selected anything to revert."))
return False

to achieve this.

But there are two more points:
1) Perhaps the best way to prevent this is to deactivate the OK button
if no files are selected to revert.
2) The current mechanism in revert.py doesn't get it if you open
qrevert in a working tree with nothing to revert (i.e. the working
tree is at the state of the tip) and check "Select / deselect all". If
you do this, no warning/BzrCommandError is generated - currently it
will simply call "bzr revert" and do nothing further. Ideally it
should also notice that nothing is selected to revert.

I want to fix this behaviour by my own, but I will need some support.
For issue 1, I see that the OK and Cancel buttons are from buttonbox.
Here I couldn't find a way to disable the OK button, because I don't
know how to properly acces it.
For issue 2, I had the following idea: The OK button should begin with
its disabled state. It should only be enabled (=clickable) by a
QtCore.SIGNAL if there is at least one file selected to revert. This
way the user can't even click on this button because it wouldn't do
anything anyway. Here my problem is to get the information if at least
one file is selected or not.

I appreciate any hints on this! :)

Alexander Belchenko

unread,
Feb 10, 2012, 10:03:51 AM2/10/12
to qb...@googlegroups.com
André Bachmann пишет:

> Yesterday, a co-worker reported a slight problem with qrevert: If you
> open Bazaar, Work, Revert Working Tree... and click OK without doing
> anything, you get a BzrCommandError (as it is raised in revert.py in
> the function validate). Well, such a message isn't quite user-
> friendly. Turning this in to a nicer QtGui.QMessageBox.warning and
> returning False isn't a problem. I have changed
>
> raise errors.BzrCommandError("You have not selected anything to
> revert.")
>
> to
>
> warningbox = QtGui.QMessageBox.warning(self, self.windowTitle(),
> gettext("You have not selected anything to revert."))
> return False
>
> to achieve this.

I think that would be good. I see no real reason why we want to raise
BzrCommandError. Possible Gary wanted to have it catched by
qbzr-specific error reporting dialog? In any case show MessageBox
explicitly is good idea here.

>
> But there are two more points:
> 1) Perhaps the best way to prevent this is to deactivate the OK button
> if no files are selected to revert.

I would like to not to. As I remember I've tried to follow the following
design: use any checks in validate method and show any useful warnings
and even maybe prevent command to run.

> 2) The current mechanism in revert.py doesn't get it if you open
> qrevert in a working tree with nothing to revert (i.e. the working
> tree is at the state of the tip) and check "Select / deselect all". If
> you do this, no warning/BzrCommandError is generated - currently it
> will simply call "bzr revert" and do nothing further. Ideally it
> should also notice that nothing is selected to revert.

I think that also should be handled in validate method.

> I want to fix this behaviour by my own, but I will need some support.
> For issue 1, I see that the OK and Cancel buttons are from buttonbox.
> Here I couldn't find a way to disable the OK button, because I don't
> know how to properly acces it.
> For issue 2, I had the following idea: The OK button should begin with
> its disabled state. It should only be enabled (=clickable) by a
> QtCore.SIGNAL if there is at least one file selected to revert. This
> way the user can't even click on this button because it wouldn't do
> anything anyway. Here my problem is to get the information if at least
> one file is selected or not.
>
> I appreciate any hints on this! :)

I would recommend you place additional checks to validate and prevent
command to run if there is user error / no files selected to revert.
I think that should be the easiest way to improve the user experience here.

What do you think?

--
All the dude wanted was his rug back

Alexander Belchenko

unread,
Feb 28, 2012, 11:56:28 AM2/28/12
to qb...@googlegroups.com
André Bachmann пишет:

> Yesterday, a co-worker reported a slight problem with qrevert: If you
> open Bazaar, Work, Revert Working Tree... and click OK without doing
> anything, you get a BzrCommandError (as it is raised in revert.py in
> the function validate). Well, such a message isn't quite user-
> friendly. Turning this in to a nicer QtGui.QMessageBox.warning and
> returning False isn't a problem. I have changed
>
> raise errors.BzrCommandError("You have not selected anything to
> revert.")
>
> to
>
> warningbox = QtGui.QMessageBox.warning(self, self.windowTitle(),
> gettext("You have not selected anything to revert."))
> return False
>
> to achieve this.

https://bugs.launchpad.net/qbzr/+bug/942744

Reply all
Reply to author
Forward
0 new messages