Tuesday, July 8, 2008

A new Location Bar

This past weekend I have been hacking on a replacement for one of the classes in Arora. ExLineEdit was the the base class for the location bar and the search widgets and was a big hack that only allowed for one widget on either side of the text. The new class is cleaner in every way and allows for any number of widgets on either side.

The location bar, search widget, and toolbar search were based on ExLineEdit. Unfortunately when first creating this classes I couldn't find a good solution to add side widgets and ended up with a solution that worked, but it was a hack where I put a QLineEdit inside of a widget and did a lot of painting and event handling myself. When originally developing the demo browser I tried to not have any hacks. If Qt didn't support a feature I didn't either. This made life a lot easier and the code cleaner. The one place I didn't follow that was with the Location Bar because a web browser absolutely must have the website icon in the location bar. Unable to find a good solution I ended up writing a class that was inflexible, had a horrible API, plays badly with new styles and I have been unhappy with it ever sense.

Now that things have settled down I took another look at the problem and was able to find an elegant solution for Qt 4.4 and made a patch for QLineEdit for an even cleaner solution in 4.5. Beyond the technical solution to the bug I made a new subclass of QLineEdit called LineEdit that added a few functions to put widgets inside of the line edit on the left or right hand side. This new class is the base class for the new LocationBar class and search widgets. The side widgets are automatically handled by a layout so they can be shown and hidden whenever you want.

Before merging this class into Arora I wrote autotests and a manualtest. Below is the manual test for the line edit class where you can see multiple widgets on either side of the line edit.

From the users perspective the only thing that should be different is that the completer will now line up under the location bar rather then slightly offset as it has been, but under the covers the code is much cleaner and more maintainable.

Having the ability to add widgets and show/hide them on the fly in a clean way will be very useful for Arora in the future. There are many extensions that people have talked about writing such as the FireFox3 bookmark star, a Go! button, rss feeds, and more. With the ability to add widget easily all of these features will be easy to make. With a good set of core classes Arora should do well.

The new LineEdit, LocationBar, updated search widgets, manualtests and autotests have been merged into Arora this evening. Enjoy!

Wednesday, July 2, 2008

A better tab bar

The past six weeks or so I have hacking on the QTabWidget and QTabBar classes in Qt. One of the first feature requests in Arora was the ability to have the close buttons on the tabs. Qt didn't allow this without a bunch of work and hacks. Knowing that a lot of other people wanted this same feature in Qt I took some time to implement it and other features (the two classes were not being very actively feature maintained). These went into Qt main (what will be 4.5).

From the user perspective when running against the Qt main snapshot you will see the following

  • Close buttons are now placed on each tabs

  • The buttons to the left and right of the tabs (new and close) are gone

  • The 2px useless frame on the left/bottom/right side of the webpage is now gone. When maximized and your mouse is on the far right it actually scrolls as you would expect.

  • Rather then clicking and dragging (a dnd box) and dropping it where you want a tab to go and then having all the tabs suddenly re-arrange you can now actually drag a tab to where you want it to go and it actually moves with your mouse and the other tabs automatically slide out of your way.

  • In OS X the tabs use the same styling as Safari, Terminal and other tab based applications.

For the more technical details and a video of the animation check out my labs.trolltech.com Some QTabBar & QTabWidget Love blog entry.

Beyond just that tab bar I have put in some time to make Arora feel more at home in OS X. The combination of that work finally makes Arora look not half bad in OS X.