Tuesday, September 11, 2007

me vs girish: clearbutton battles

A while ago i added little clear buttons inside of single-line text edits (QLineEdit/KLineEdit) in kdelibs. I liked it because it gets rid of those fugly and usability-wise pretty bad external clear buttons that only operate on another (poorly associated, visually) widget. I'd seen similar things elsewhere and liked the idea. so in it went.

But not before i could make it so that the text didn't go underneath the embedded clear button. That meant styling the line edit when there was a clear button showing with a stylesheet. This is where Girish entered the picture, for he was working on Qt widget styling using CSS stylesheets. You can find a bunch of examples of just how powerful this is on his Qt dev blog.

Well, eventually he decided to do a Qt-only version of what I did and he was good enough to even provide screenshots, unlike lazy me with this blog entry. But Girish just had to one up me: " The clear button appears only when the line edit has text," he said in his blog entry.

Bring it.

It was discovered that a bug in the stylesheet support screwed up the "no text beneath the button" trick when the line edit was embedded in a drop down or other widget. I figured pointing this out to Girish would be good revenge. ;) By the time I got to show it to him in person at the Oslo offices (I did email him about it previously, though) he had already fixed it. Doh! Stupid productive, responsive Trolls!

Like two swordsmen dueling for the honor of the fair maiden, the ball was once again in my court. (I love how that sentence makes no sense whatsoever.) Well, take this Girish:

The KDE version of the clear-button-in-the-lineedit (otherwise known as the "Seigo Special") now not only shows only when there is text, but it fades gracefully in and out using the full power of the QTimeLine battle-station and Arthur's coolio painting support which made it stupidly trivial. I also dropped using a full on QLabel or QToolButton and whipped up a tiny little QWidget that Does The Deed With Fewer Resources(tm).

For now, I stand atop this ridiculous pixel pushing perfection process mountain and look down upon you in the valleys below, Girish! How will you answer the challenge?

Boo-yah!

p.s. Girish, like virtually all the Trolls is wicked cool (that's an official Boston term), with the possible exception of Andreas-of-QGV. For you see, Andreas is wicked cool with a cherry on top, but then everyone knows that already. ;)

12 comments:

Hans said...

Haha, really enjoyed reading this post. Just a stupid question: can I still middle click the clear button to replace the text in the lineedit with text from the clipboard?

Aaron J. Seigo said...

@hans: of course! it's feature complete with respect to the old clear buttons, only nicer to behold =)

Louis said...

Sweet! I just discovered a new productivity tool! I knew there was something work-related to justify reading this blog!

Hans said...

Yay, that roKs! And it makes sense too (if the lineedit is empty (and clear button hidden), you just simply paste to the text field).

Now I request a video of the fade in/out animation. Why not together with a new Plasma screencast? ;)

mattie said...

Krofl, entertaining post, thank you :)

Karl Ove Hufthammer said...

If I accidentally click the clear button, can I use Ctrl + Z (or right-click and choose Undo) to undo the clearing?

Girish said...

Aaron, you have no idea what is hitting at you at dev days ;)

Anonymous said...

Nice. Now, to make KDE even more usable add keyboard shortcuts to file dialog so I can use it without touching mouse:

- Ctrl+L to set focus on current location (KUrlNavigator, edit mode - like in dolphin)
- F2 to rename file or directory

Thanks!

Daniel "Suslik" D. said...

Next step could be altering the location of the Clear button depending on the RTL / LTR

Aaron J. Seigo said...

@karl: yes, undo works

@anonymous: "add keyboard shortcuts to file dialog"

i'm not sure why, but it bugs me when people post feature request(/demands) for completely unrelated things in the comments to blogs or other stories. really, like wtf.

@Suslik: it already does take RTL into consideration

Anonymous said...

Regarding keyboard shortcuts...
I know that feature request was inappropriate, but if I had filled a bugreport nobody will notice it for a couple of years and I will be forced to do it myself (and learn QT/KDE before that).

To be ontopic: this clearbutton is pretty much redundant, I never used it. I want to clear input only if I need to type something in it and for that I do a "select all" and just type over it. One can select all with:
- double click on the input
- press LMB and move
- press Ctrl+A
- use keyboard to get focus on
input which will automatically
select all.
So, this is the *fifth* way to clear input.

Aaron J. Seigo said...

@anon: "nobody will notice it for a couple of years"

au contrare! (or however you spell it..) i routinely get annoyed at the lack of keyboard shortcuts in the file dialog. it's actually really, really rare that someone brings up a pain point in the shared UI components that i haven't noticed already =)

"this clearbutton is pretty much redundant"

not really, and for three reasons, one of which is fairly esoteric:

0. it's the most 'discoverable' way to quickly clear the edit; the other ways require knowledge of how to use the edits.

1. it lets one clear the edit without selecting the text (and therefore over-writing the contents of SELECTION)

2. it lets one, with a single click, clear and paste in new content, making it very efficient for this relative to other methods.