: QWidget(parent)
{
ui.setupUi(this);
+ effectedit=new EffectStackEdit(ui.frame,this);
//ui.effectlist->horizontalHeader()->setVisible(false);
//ui.effectlist->verticalHeader()->setVisible(false);
- activeRow=-1;
clipref=NULL;
ui.buttonNew->setIcon(KIcon("document-new"));
+ ui.buttonNew->setToolTip(i18n("Add new effect"));
ui.buttonUp->setIcon(KIcon("go-up"));
+ ui.buttonUp->setToolTip(i18n("Move effect up"));
ui.buttonDown->setIcon(KIcon("go-down"));
+ ui.buttonDown->setToolTip(i18n("Move effect down"));
ui.buttonDel->setIcon(KIcon("trash-empty"));
-
- ui.buttonLeftRight->setIcon(KIcon("go-next"));//better icons needed
- ui.buttonUpDown->setIcon(KIcon("go-up"));
- ui.buttonShowInTimeline->setIcon(KIcon("kmplayer"));
- ui.buttonHelp->setIcon(KIcon("help-about"));
- ui.buttonNewPoints->setIcon(KIcon("xedit"));
+ ui.buttonDel->setToolTip(i18n("Delete effect"));
+ ui.buttonReset->setIcon(KIcon("view-refresh"));
+ ui.buttonReset->setToolTip(i18n("Reset effect"));
+
ui.effectlist->setDragDropMode(QAbstractItemView::NoDragDrop);//use internal if drop is recognised right
connect (ui.buttonUp, SIGNAL (clicked()), this, SLOT (slotItemUp()) );
connect (ui.buttonDown, SIGNAL (clicked()), this, SLOT (slotItemDown()) );
connect (ui.buttonDel, SIGNAL (clicked()), this, SLOT (slotItemDel()) );
- connect (ui.buttonLeftRight, SIGNAL (clicked()), this , SLOT ( slotSetMoveX() ) );
- connect (ui.buttonUpDown, SIGNAL (clicked()), this , SLOT ( slotSetMoveY() ) );
- connect (ui.buttonShowInTimeline, SIGNAL (clicked()), this , SLOT ( slotShowInTimeline() ) );
- connect (ui.buttonNewPoints, SIGNAL (clicked()), this , SLOT ( slotSetNew() ) );
- connect (ui.buttonHelp, SIGNAL (clicked()), this , SLOT ( slotSetHelp() ) );
- connect (ui.parameterList, SIGNAL (currentIndexChanged ( const QString & ) ), this, SLOT( slotParameterChanged(const QString&) ) );
- connect (ui.effectlist, SIGNAL (itemSelectionChanged() ) , this, SLOT ( itemSelectionChanged()));
-
+ connect (ui.buttonReset, SIGNAL (clicked()), this, SLOT (slotResetEffect()) );
+ connect( this, SIGNAL (transferParamDesc(const QDomElement&,int ,int) ), effectedit , SLOT(transferParamDesc(const QDomElement&,int ,int)));
+ connect(effectedit, SIGNAL (parameterChanged( const QDomElement&, const QDomElement& ) ), this , SLOT (slotUpdateEffectParams( const QDomElement&, const QDomElement& )));
effectLists["audio"]=audioEffectList;
effectLists["video"]=videoEffectList;
effectLists["custom"]=customEffectList;
- ui.infoBox->hide();
- updateButtonStatus();
-
-
- QList< QPair<QString, QMap<int,QVariant> > > points;
- QMap<int,QVariant> data;
- data[0]=0.1;
- data[100]=30;
- data[255]=50;
- data[300]=100;
- QPair<QString,QMap<int,QVariant> > testpair("gray",data);
- points.append(testpair);
-
- QMap<int,QVariant> data1;
- data1[0]=20;
- data1[10]=70;
- data1[155]=110;
- data1[300]=133;
- QPair<QString,QMap<int,QVariant> > testpair1("dx",data1);
- points.append(testpair1);
- ui.parameterList->addItem("all");
- ui.parameterList->addItem("gray");
- ui.parameterList->addItem("dx");
-
- ui.kplotwidget->setPointLists(points,0,305);
+ ui.infoBox->hide();
+ setEnabled(false);
+ setEnabled(false);
}
+void EffectStackView::slotUpdateEffectParams(const QDomElement& old, const QDomElement& e){
+ if (clipref)
+ emit updateClipEffect(clipref, old, e);
+}
+
void EffectStackView::slotClipItemSelected(ClipItem* c)
{
clipref=c;
- if (clipref==NULL)
+ if (clipref==NULL) {
+ setEnabled(false);
return;
- effects=clipref->effectNames();
- setupListView(effects);
+ }
+ setEnabled(true);
+ setupListView();
}
-void EffectStackView::setupListView(const QStringList& effects_list){
+void EffectStackView::setupListView(){
ui.effectlist->clear();
- ui.effectlist->addItems(effects);
- for (int i=0;i< ui.effectlist->count();i++){
- QListWidgetItem* item=ui.effectlist->item(i);
- item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
- item->setCheckState(Qt::Checked);
- if (activeRow==i){
- item->setSelected(true);
- ui.effectlist->setCurrentRow(activeRow);
+ for (int i=0;i<clipref->effectsCount();i++){
+ QDomElement d=clipref->effectAt(i);
+ QDomNode namenode = d.elementsByTagName("name").item(0);
+ if (!namenode.isNull()) {
+ QListWidgetItem* item = new QListWidgetItem(namenode.toElement().text(), ui.effectlist);
+ item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
+ item->setCheckState(Qt::Checked);
}
}
-
+ if (clipref->effectsCount() == 0)
+ emit transferParamDesc(QDomElement(), 0, 100);
+ ui.effectlist->setCurrentRow(0);
+
}
void EffectStackView::slotItemSelectionChanged(){
-
- if (ui.effectlist->currentItem() && ui.effectlist->currentItem()->isSelected() ){
- activeRow=ui.effectlist->row( ui.effectlist->currentItem() );
- }else{
- activeRow=-1;
+ bool hasItem = ui.effectlist->currentItem();
+ int activeRow = ui.effectlist->currentRow();
+ if (hasItem && ui.effectlist->currentItem()->isSelected() ){
+ emit transferParamDesc(clipref->effectAt(activeRow), 0, 100);//minx max frame
}
- ui.buttonDel->setEnabled( activeRow!=-1);
+ ui.buttonDel->setEnabled( hasItem );
+ ui.buttonReset->setEnabled( hasItem );
ui.buttonUp->setEnabled( activeRow >0 );
- ui.buttonDown->setEnabled( (activeRow<ui.effectlist->count()-1) && activeRow>=0 );
+ ui.buttonDown->setEnabled( (activeRow < ui.effectlist->count()-1) && hasItem );
}
void EffectStackView::slotItemUp(){
- if (activeRow>0 && activeRow <effects.size() ){
- effects.swap(activeRow, activeRow-1);
+ int activeRow = ui.effectlist->currentRow();
+ if (activeRow>0){
+ QDomElement act = clipref->effectAt(activeRow).cloneNode().toElement();
+ QDomElement before = clipref->effectAt(activeRow-1).cloneNode().toElement();
+ clipref->setEffectAt(activeRow-1, act);
+ clipref->setEffectAt(activeRow, before);
}
- activeRow--;
- setupListView(effects);
-
+ QListWidgetItem *item = ui.effectlist->takeItem(activeRow);
+ ui.effectlist->insertItem (activeRow-1, item);
+ ui.effectlist->setCurrentItem(item);
+ emit refreshEffectStack(clipref);
}
void EffectStackView::slotItemDown(){
- if (activeRow<effects.size()-1 ){
- effects.swap(activeRow, activeRow+1);
+ int activeRow = ui.effectlist->currentRow();
+ if (activeRow < ui.effectlist->count()-1){
+ QDomElement act = clipref->effectAt(activeRow).cloneNode().toElement();
+ QDomElement after = clipref->effectAt(activeRow+1).cloneNode().toElement();
+ clipref->setEffectAt(activeRow+1, act);
+ clipref->setEffectAt(activeRow, after);
}
- activeRow++;
- setupListView(effects);
-
+ QListWidgetItem *item = ui.effectlist->takeItem(activeRow);
+ ui.effectlist->insertItem (activeRow+1, item);
+ ui.effectlist->setCurrentItem(item);
+ emit refreshEffectStack(clipref);
}
void EffectStackView::slotItemDel(){
- if (activeRow<effects.size() && activeRow>=0 ){
- effects.removeAt(activeRow);
+ int activeRow = ui.effectlist->currentRow();
+ if ( activeRow>=0 ){
+ emit removeEffect(clipref, clipref->effectAt(activeRow));
}
- if (effects.size()>0 && activeRow>0)
- activeRow--;
- setupListView(effects);
-
-}
-
-void EffectStackView::slotSetMoveX(){
- ui.kplotwidget->setMoveX(!ui.kplotwidget->isMoveX());
- updateButtonStatus();
-}
-
-void EffectStackView::slotSetMoveY(){
- ui.kplotwidget->setMoveY(!ui.kplotwidget->isMoveY());
- updateButtonStatus();
}
-void EffectStackView::slotSetNew(){
- ui.kplotwidget->setNewPoints(!ui.kplotwidget->isNewPoints());
- updateButtonStatus();
-}
-
-void EffectStackView::slotSetHelp(){
- ui.infoBox->setVisible(!ui.infoBox->isVisible());
- ui.buttonHelp->setDown(ui.infoBox->isVisible());
-}
-
-void EffectStackView::slotShowInTimeline(){
-
- ui.kplotwidget->setMoveTimeLine(!ui.kplotwidget->isMoveTimeline());
- updateButtonStatus();
-
-}
-
-void EffectStackView::updateButtonStatus(){
- ui.buttonLeftRight->setDown(ui.kplotwidget->isMoveX());
- ui.buttonUpDown->setDown(ui.kplotwidget->isMoveY());
-
- ui.buttonShowInTimeline->setEnabled( ui.kplotwidget->isMoveX() || ui.kplotwidget->isMoveY () );
- ui.buttonShowInTimeline->setDown(ui.kplotwidget->isMoveTimeline());
-
- ui.buttonNewPoints->setEnabled(ui.parameterList->currentText()!="all");
- ui.buttonNewPoints->setDown(ui.kplotwidget->isNewPoints());
-}
-
-void EffectStackView::slotParameterChanged(const QString& text){
-
- //ui.buttonNewPoints->setEnabled(text!="all");
- updateButtonStatus();
+void EffectStackView::slotResetEffect()
+{
+ int activeRow = ui.effectlist->currentRow();
+ QDomElement old = clipref->effectAt(activeRow).cloneNode().toElement();
+ QDomElement dom;
+ QString effectName = ui.effectlist->currentItem()->text();
+ foreach (QString type, effectLists.keys() ){
+ EffectsList *list=effectLists[type];
+ if (list->effectNames().contains(effectName)) {
+ dom = list->getEffectByName(effectName);
+ break;
+ }
+ }
+ if (!dom.isNull()) emit updateClipEffect(clipref, old, dom);
}
void EffectStackView::slotNewEffect(){
QAction *result=displayMenu->exec(mapToGlobal(ui.buttonNew->pos()+ui.buttonNew->rect().bottomRight()));
if (result){
- effects.append(result->data().toString());
- setupListView(effects);
- kDebug()<< result->data();
+ //TODO effects.append(result->data().toString());
+ foreach (EffectsList* e, effectLists.values()){
+ QDomElement dom=e->getEffectByName(result->data().toString());
+ if (clipref)
+ clipref->addEffect(dom);
+ slotClipItemSelected(clipref);
+ }
+
+ setupListView();
+ //kDebug()<< result->data();
}
delete displayMenu;