[Qgis-developer] New QgsColorButton: features and poll

Larry Shaffer larrys at dakotacarto.com
Fri Mar 22 16:51:18 PDT 2013


Hi,

Matthias Kuhn and I reworked the QgsColorButton class and refactored it use
across the project. The following is an overview of its new features, a
poll on how to move forward, and a note about a Mac issue.

Features:
* Now one class based off of QPushButton, with two variants: one with an
icon when there is text (normal OS style), and one purely stylesheet-based
when there is no text (we refer to it as a color 'well'). Comparison of the
two variants [0].

* Code for using the button is much simpler, since the color chooser dialog
is now part of the QgsColorButton class.

* Whenever the color of the button has an alpha < 255 there is a
checkerboard background with the color overlaid, to indicate to the user
that the color has a transparency value. There is currently no graphical
indication that the button's color chooser dialog *offers* transparency
editing (I have figured out how to add this as a small badge, though).

* When the option is checked in Options, a live-updating color chooser
dialog is used and interim color choices update the button. This means any
signal/slot connection to the button's color change will also update,
creating a live preview. Try this with items in Composer (arrow, frame,
background) and when creating/editing a gradient. Some buttons shouldn't
have live updates, so there's a setter function to turn it off per button
(default for live updating is on).

[0] http://drive.dakotacarto.com/qgis/color-button_comparison.png

Poll:
Do you think there should be just color wells, just buttons with icons, or
a mix of both (current situation)? IMHO they should all be wells.

Mac 'triple-modal' issue:
On Mac there is an issue when using the native color dialog with what I
call 'triple-modal' dialogs: where one modal dialog opens another modal
dialog, which offers opening the modal color chooser. When this happens,
upon closing the color chooser, then the topmost modal dialog, the first
modal dialog becomes completely unresponsive (basically like there is still
another modal dialog open on top of it, but there isn't). It does not
happen when there is only one modal dialog and then the modal color chooser
on top.

This is a known Qt Mac issue with 4.8 and 5.0 (and maybe 4.7). I worked
around it by making all instances of base dialogs that present the issue
show as Qt::WindowModal, i.e. as sheet dialogs. This means there should be
no more Qt-style color choosers (only Mac native ones). Please let me know
if you notice any non-native color choosers popping up or any more
'triple-modal' issues.

Regards,

Larry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130322/9b553eff/attachment.html>


More information about the Qgis-developer mailing list