Skip to content

Commit

Permalink
PropertyEditor widget: can now initialise the selection of a colour b…
Browse files Browse the repository at this point in the history
…y double clicking on a colour icon.
  • Loading branch information
agarny committed Nov 2, 2017
1 parent e1ba085 commit 1bddb1e
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/plugins/miscellaneous/Core/src/propertyeditorwidget.cpp
Expand Up @@ -967,12 +967,33 @@ void Property::setColorValue(const QColor &pColorValue)

void Property::setColorValue(const QPoint &pPoint)
{
// Make sure that we are of colour type and that the given point is over our
// colour value icon
// Make sure that we are of colour type and that the given point is either
// null or over our colour value icon

if (mType == Color) {
if (!pPoint.isNull()) {
// The given point is not null, so determine the position and size
// of our colour value icon
// Note: this very much relies on an empirical approach...

QRect iconRect = mOwner->visualRect(mValue->index());

#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
iconRect.translate(3, 1);
#elif defined(Q_OS_MAC)
iconRect.translate(5, 1);
#else
#error Unsupported platform
#endif

iconRect.setSize(QSize(16, 16));

// Check whether the given point is over our colour value icon

if (!iconRect.contains(pPoint))
return;
}

if ( (mType == Color)
&& ( pPoint.isNull()
|| (mOwner->visualRect(mValue->index()).contains(pPoint)))) {
// Select a colour and assign it to ourselves

QColorDialog colorDialog(colorValue());
Expand Down

0 comments on commit 1bddb1e

Please sign in to comment.