Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix layout issues with color button editor widget
- widget was not left aligned
- widget would shrink to a small vertical height in crowded forms
  • Loading branch information
nyalldawson committed Apr 6, 2016
1 parent 4c704be commit 76282d5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/gui/editorwidgets/qgscolorwidgetwrapper.cpp
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include "qgscolorwidgetwrapper.h"
#include <QLayout>

QgsColorWidgetWrapper::QgsColorWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent )
: QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
Expand Down Expand Up @@ -42,14 +43,26 @@ void QgsColorWidgetWrapper::showIndeterminateState()

QWidget* QgsColorWidgetWrapper::createWidget( QWidget* parent )
{
QgsColorButtonV2* button = new QgsColorButtonV2( parent );
QWidget* container = new QWidget( parent );
QHBoxLayout* layout = new QHBoxLayout();
container->setLayout( layout );
layout->setMargin( 0 );
layout->setContentsMargins( 0, 0, 0, 0 );
QgsColorButtonV2* button = new QgsColorButtonV2();
button->setContext( QString( "editor" ) );
return button;
layout->addWidget( button );
layout->addStretch();
container->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
return container;
}

void QgsColorWidgetWrapper::initWidget( QWidget* editor )
{
mColorButton = qobject_cast<QgsColorButtonV2*>( editor );
if ( !mColorButton )
{
mColorButton = editor->findChild<QgsColorButtonV2*>();
}

connect( mColorButton, SIGNAL( colorChanged( QColor ) ), this, SLOT( valueChanged() ) );
}
Expand Down

0 comments on commit 76282d5

Please sign in to comment.