@@ -758,7 +758,22 @@ bool QgsColorSwatchDelegate::editorEvent( QEvent *event, QAbstractItemModel *mod
758
758
// item not editable
759
759
return false ;
760
760
}
761
+
761
762
QColor color = index .model ()->data ( index , Qt::DisplayRole ).value <QColor>();
763
+
764
+ QgsPanelWidget* panel = QgsPanelWidget::findParentPanel ( qobject_cast< QWidget* >( parent () ) );
765
+ if ( panel && panel->dockMode () )
766
+ {
767
+ QgsCompoundColorWidget* colorWidget = new QgsCompoundColorWidget ( panel, color, QgsCompoundColorWidget::LayoutVertical );
768
+ colorWidget->setPanelTitle ( tr ( " Select color" ) );
769
+ colorWidget->setAllowAlpha ( true );
770
+ colorWidget->setProperty ( " index" , index );
771
+ connect ( colorWidget, SIGNAL ( currentColorChanged ( QColor ) ), this , SLOT ( colorChanged () ) );
772
+ panel->openPanel ( colorWidget );
773
+ return true ;
774
+ }
775
+
776
+
762
777
QColor newColor = QgsColorDialog::getColor ( color, mParent , tr ( " Select color" ), true );
763
778
if ( !newColor.isValid () )
764
779
{
@@ -770,3 +785,12 @@ bool QgsColorSwatchDelegate::editorEvent( QEvent *event, QAbstractItemModel *mod
770
785
771
786
return false ;
772
787
}
788
+
789
+ void QgsColorSwatchDelegate::colorChanged ()
790
+ {
791
+ if ( QgsCompoundColorWidget* colorWidget = qobject_cast< QgsCompoundColorWidget* >( sender () ) )
792
+ {
793
+ QModelIndex index = colorWidget->property ( " index" ).toModelIndex ();
794
+ const_cast < QAbstractItemModel* >( index .model () )->setData ( index , colorWidget->color (), Qt::EditRole );
795
+ }
796
+ }
0 commit comments