QgsEffectStackPropertiesWidget::QgsEffectStackPropertiesWidget( QgsEffectStack *stack, QWidget *parent )
    : QgsPanelWidget( parent )
    , mStack( stack )
    , mPreviewPicture( nullptr )
{

// TODO
#ifdef Q_OS_MAC
  //setWindowModality( Qt::WindowModal );
#endif

  mPresentWidget = nullptr;

  setupUi( this );

  mAddButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) );
  mRemoveButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) );
  mUpButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) );
  mDownButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) );

  mModel = new QStandardItemModel();
  // Set the effect
  mEffectsList->setModel( mModel );

  QItemSelectionModel* selModel = mEffectsList->selectionModel();
  connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( effectChanged() ) );

  loadStack( stack );
  updatePreview();

  connect( mUpButton, SIGNAL( clicked() ), this, SLOT( moveEffectUp() ) );
  connect( mDownButton, SIGNAL( clicked() ), this, SLOT( moveEffectDown() ) );
  connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addEffect() ) );
  connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeEffect() ) );

  updateUi();

  // set first selected effect as active item in the tree
  int initialRow = 0;
  for ( int i = 0; i < stack->count(); ++i )
  {
    // list shows effects in opposite order to stack
    if ( stack->effect( stack->count() - i - 1 )->enabled() )
    {
      initialRow = i;
      break;
    }
  }
  QModelIndex newIndex = mEffectsList->model()->index( initialRow, 0 );
  mEffectsList->setCurrentIndex( newIndex );

  setPanelTitle( tr( "Effects Properties" ) );
}
QgsEffectStackPropertiesWidget::QgsEffectStackPropertiesWidget( QgsEffectStack *stack, QWidget *parent )
    : QWidget( parent )
    , mStack( stack )
    , mPreviewPicture( 0 )
{

// TODO
#ifdef Q_OS_MAC
  //setWindowModality( Qt::WindowModal );
#endif

  mPresentWidget = NULL;

  setupUi( this );

  mAddButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.svg" ) ) );
  mRemoveButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.svg" ) ) );
  mUpButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyUp.svg" ) ) );
  mDownButton->setIcon( QIcon( QgsApplication::iconPath( "symbologyDown.svg" ) ) );

  mModel = new QStandardItemModel();
  // Set the effect
  mEffectsList->setModel( mModel );

  QItemSelectionModel* selModel = mEffectsList->selectionModel();
  connect( selModel, SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( effectChanged() ) );

  loadStack( stack );
  updatePreview();

  connect( mUpButton, SIGNAL( clicked() ), this, SLOT( moveEffectUp() ) );
  connect( mDownButton, SIGNAL( clicked() ), this, SLOT( moveEffectDown() ) );
  connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addEffect() ) );
  connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeEffect() ) );

  updateUi();

  // set effect as active item in the tree
  QModelIndex newIndex = mEffectsList->model()->index( 0, 0 );
  mEffectsList->setCurrentIndex( newIndex );
}