#include "monitoreditwidget.h"
#include "monitorscene.h"
#include "kdenlivesettings.h"
+#include "collapsibleeffect.h"
+#include "collapsiblegroup.h"
#include <KDebug>
#include <KLocale>
#include <QTextStream>
#include <QFile>
#include <QInputDialog>
+#include <QScrollBar>
EffectStackView2::EffectStackView2(Monitor *monitor, QWidget *parent) :
m_ui.checkAll->setToolTip(i18n("Enable/Disable all effects"));
m_ui.buttonShowComments->setIcon(KIcon("help-about"));
m_ui.buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
-
+
+ connect(m_ui.checkAll, SIGNAL(stateChanged(int)), this, SLOT(slotCheckAll(int)));
+ connect(m_ui.buttonShowComments, SIGNAL(clicked()), this, SLOT(slotShowComments()));
+ m_ui.labelComment->setHidden(true);
setEnabled(false);
- QPalette p = palette();
- KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
- QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
- QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
- QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
- QColor light_bg = scheme.shade(KColorScheme::LightShade);
- QString stylesheet(QString("QProgressBar:horizontal {border: 1px solid %1;border-radius:0px;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right: 0px;background:%4;padding: 0px;text-align:left center}\
- QProgressBar:horizontal#dragOnly {background: %1} QProgressBar:horizontal:hover#dragOnly {background: %3} QProgressBar:horizontal:hover {border: 1px solid %3;border-right: 0px;}\
- QProgressBar::chunk:horizontal {background: %1;} QProgressBar::chunk:horizontal:hover {background: %3;}\
- QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;}\
- QAbstractSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;}\
- QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ")
- .arg(dark_bg.name()).arg(selected_bg.name()).arg(hover_bg.name()).arg(light_bg.name()));
- setStyleSheet(stylesheet);
+ setStyleSheet(CollapsibleEffect::getStyleSheet(palette()));
}
EffectStackView2::~EffectStackView2()
m_effects.at(i)->slotSyncEffectsPos(pos);
}
-void EffectStackView2::setMenu(QMenu *menu)
-{
- //m_ui.buttonNew->setMenu(menu);
-}
-
void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix)
{
if (c && !c->isEnabled()) return;
m_ui.checkAll->setToolTip(QString());
m_ui.checkAll->setText(i18n("Effects for %1").arg(cname));
}
+ m_ui.checkAll->setEnabled(true);
ix = c->selectedEffectIndex();
QString size = c->baseClip()->getProperty("frame_size");
double factor = c->baseClip()->getProperty("aspect_ratio").toDouble();
void EffectStackView2::setupListView(int ix)
{
- //TODO: clear list
-
blockSignals(true);
m_draggedEffect = NULL;
disconnect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
QVBoxLayout *vbox1 = new QVBoxLayout(view);
vbox1->setContentsMargins(0, 0, 0, 0);
vbox1->setSpacing(0);
+
+ if (m_currentEffectList.isEmpty()) m_ui.labelComment->setHidden(true);
for (int i = 0; i < m_currentEffectList.count(); i++) {
QDomElement d = m_currentEffectList.at(i).cloneNode().toElement();
continue;
}
- CollapsibleEffect *group = NULL;
+ CollapsibleGroup *group = NULL;
EffectInfo effectInfo;
effectInfo.fromString(d.attribute("kdenlive_info"));
if (effectInfo.groupIndex >= 0) {
+ // effect is in a group
+
for (int j = 0; j < vbox1->count(); j++) {
- CollapsibleEffect *gp = static_cast<CollapsibleEffect *>(vbox1->itemAt(j)->widget());
- if (gp->groupIndex() == effectInfo.groupIndex) {
- group = gp;
+ CollapsibleGroup *eff = static_cast<CollapsibleGroup *>(vbox1->itemAt(j)->widget());
+ if (eff->isGroup() && eff->groupIndex() == effectInfo.groupIndex) {
+ group = eff;
break;
}
}
if (group == NULL) {
- group = new CollapsibleEffect(QDomElement(), QDomElement(), ItemInfo(), effectInfo.groupIndex, &m_effectMetaInfo, false, true, m_ui.container->widget());
+ group = new CollapsibleGroup(effectInfo.groupIndex, i == 0, i == m_currentEffectList.count() - 1, m_ui.container->widget());
if (!effectInfo.groupName.isEmpty()) group->title->setText(effectInfo.groupName);
- connect(group, SIGNAL(moveEffect(int,int,CollapsibleEffect*)), this, SLOT(slotMoveEffect(int,int,CollapsibleEffect*)));
- connect(group, SIGNAL(unGroup(CollapsibleEffect*)), this , SLOT(slotUnGroup(CollapsibleEffect*)));
+ connect(group, SIGNAL(moveEffect(int,int,int)), this, SLOT(slotMoveEffect(int,int,int)));
+ connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*)));
vbox1->addWidget(group);
}
if (effectInfo.groupIndex >= m_groupIndex) m_groupIndex = effectInfo.groupIndex + 1;
}
else info = m_clipref->info();
- CollapsibleEffect *currentEffect = new CollapsibleEffect(d, m_currentEffectList.at(i), info, i, &m_effectMetaInfo, i == m_currentEffectList.count() - 1, false, view);
+ CollapsibleEffect *currentEffect = new CollapsibleEffect(d, m_currentEffectList.at(i), info, &m_effectMetaInfo, i == m_currentEffectList.count() - 1, view);
m_effects.append(currentEffect);
if (group) {
group->addGroupEffect(currentEffect);
connect(currentEffect, SIGNAL(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
connect(currentEffect, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int)));
connect(currentEffect, SIGNAL(createGroup(int)), this , SLOT(slotCreateGroup(int)));
- connect(currentEffect, SIGNAL(moveEffect(int,int,CollapsibleEffect*)), this , SLOT(slotMoveEffect(int,int,CollapsibleEffect*)));
+ connect(currentEffect, SIGNAL(moveEffect(int,int,int)), this , SLOT(slotMoveEffect(int,int,int)));
connect(currentEffect, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement)));
//ui.title->setPixmap(icon.pixmap(QSize(12, 12)));
}
vbox1->addStretch(10);
+ slotUpdateCheckAllButton();
connect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
+
+ // Wait a little bit for the new layout to be ready, then check if we have a scrollbar
+ QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter()));
+}
+
+
+void EffectStackView2::slotCheckWheelEventFilter()
+{
+ // If the effect stack widget has no scrollbar, we will not filter the
+ // mouse wheel events, so that user can easily adjust effect params
+ bool filterWheelEvent = false;
+ if (m_ui.container->verticalScrollBar() && m_ui.container->verticalScrollBar()->isVisible()) {
+ // widget has scroll bar,
+ filterWheelEvent = true;
+ }
+ for (int i = 0; i < m_effects.count(); i++) {
+ m_effects.at(i)->filterWheelEvent = filterWheelEvent;
+ }
+}
+
+void EffectStackView2::resizeEvent ( QResizeEvent * event )
+{
+ slotCheckWheelEventFilter();
+ QWidget::resizeEvent(event);
}
bool EffectStackView2::eventFilter( QObject * o, QEvent * e )
emit changeEffectState(NULL, m_trackindex, index, disable);
else
emit changeEffectState(m_clipref, -1, index, disable);
+ slotUpdateCheckAllButton();
}
}
m_ui.checkAll->setToolTip(QString());
m_ui.checkAll->setText(QString());
+ m_ui.checkAll->setEnabled(false);
+ m_ui.labelComment->setText(QString());
setEnabled(false);
}
-void EffectStackView2::updateProjectFormat(MltVideoProfile profile, Timecode t)
+void EffectStackView2::slotCheckAll(int state)
{
- m_effectMetaInfo.profile = profile;
- m_effectMetaInfo.timecode = t;
+ if (state == 1) {
+ state = 2;
+ m_ui.checkAll->blockSignals(true);
+ m_ui.checkAll->setCheckState(Qt::Checked);
+ m_ui.checkAll->blockSignals(false);
+ }
+
+ bool disabled = (state != 2);
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (!m_effects.at(i)->isGroup()) {
+ m_effects.at(i)->slotEnable(!disabled);
+ }
+ }
+}
+
+void EffectStackView2::slotUpdateCheckAllButton()
+{
+ bool hasEnabled = false;
+ bool hasDisabled = false;
+
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->enabledBox->isChecked()) hasEnabled = true;
+ else hasDisabled = true;
+ }
+
+ m_ui.checkAll->blockSignals(true);
+ if (hasEnabled && hasDisabled)
+ m_ui.checkAll->setCheckState(Qt::PartiallyChecked);
+ else if (hasEnabled)
+ m_ui.checkAll->setCheckState(Qt::Checked);
+ else
+ m_ui.checkAll->setCheckState(Qt::Unchecked);
+ m_ui.checkAll->blockSignals(false);
}
-void EffectStackView2::slotItemDel()
+void EffectStackView2::deleteCurrentEffect()
{
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->isActive()) {
+ slotDeleteEffect(m_effects.at(i)->effect());
+ break;
+ }
+ }
+}
+void EffectStackView2::updateProjectFormat(MltVideoProfile profile, Timecode t)
+{
+ m_effectMetaInfo.profile = profile;
+ m_effectMetaInfo.timecode = t;
}
void EffectStackView2::updateTimecodeFormat()
// Make sure the changed effect is currently displayed
slotSetCurrentEffect(ix);
}
+ QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter()));
}
void EffectStackView2::slotSetCurrentEffect(int ix)
if (m_clipref && ix != m_clipref->selectedEffectIndex())
m_clipref->setSelectedEffect(ix);
for (int i = 0; i < m_effects.count(); i++) {
- m_effects.at(i)->setActive(m_effects.at(i)->effectIndex() == ix);
+ if (m_effects.at(i)->effectIndex() == ix) {
+ m_effects.at(i)->setActive(true);
+ m_ui.labelComment->setText(i18n(m_effects.at(i)->effect().firstChildElement("description").firstChildElement("full").text().toUtf8().data()));
+ m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || m_ui.labelComment->text().isEmpty());
+ }
+ else m_effects.at(i)->setActive(false);
}
}
info.cropStart = GenTime(0);
info.startPos = GenTime(-1);
info.track = 0;
- m_effects.at(ix)->updateWidget(info, ix, dom, &m_effectMetaInfo);
+ m_effects.at(ix)->updateWidget(info, dom, &m_effectMetaInfo);
emit updateEffect(NULL, m_trackindex, old, dom, ix);
} else {
m_clipref->initEffect(dom);
- m_effects.at(ix)->updateWidget(m_clipref->info(), ix, dom, &m_effectMetaInfo);
+ m_effects.at(ix)->updateWidget(m_clipref->info(), dom, &m_effectMetaInfo);
//m_ui.region_url->setUrl(KUrl(dom.attribute("region")));
emit updateEffect(m_clipref, -1, old, dom, ix);
}
}
- /*emit showComments(m_ui.buttonShowComments->isChecked());
- m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count());*/
+ emit showComments(m_ui.buttonShowComments->isChecked());
+ m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || m_ui.labelComment->text().isEmpty());
}
+void EffectStackView2::slotShowComments()
+{
+ m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || m_ui.labelComment->text().isEmpty());
+ emit showComments(m_ui.buttonShowComments->isChecked());
+}
void EffectStackView2::slotCreateGroup(int ix)
{
QDomElement oldeffect = m_currentEffectList.itemFromIndex(ix);
QDomElement neweffect = oldeffect.cloneNode().toElement();
- QString groupName = QString::number(m_groupIndex);
EffectInfo effectinfo;
effectinfo.fromString(oldeffect.attribute("kdenlive_info"));
effectinfo.groupIndex = m_groupIndex;
QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
int groupPos = 0;
-
CollapsibleEffect *effectToMove = NULL;
- for (int j = 0; j < l->count(); j++) {
- CollapsibleEffect *gp = static_cast<CollapsibleEffect *>(l->itemAt(j)->widget());
- if (gp->effectIndex() == ix) {
- effectToMove = gp;
- groupPos = l->indexOf(gp);
- l->removeWidget(gp);
+ for (int i = 0; i < m_effects.count(); i++) {
+ if (m_effects.at(i)->effectIndex() == ix) {
+ effectToMove = m_effects.at(i);
+ groupPos = l->indexOf(effectToMove);
+ l->removeWidget(effectToMove);
break;
}
}
- CollapsibleEffect *group = new CollapsibleEffect(QDomElement(), QDomElement(), ItemInfo(), m_groupIndex, &m_effectMetaInfo, false, true, m_ui.container->widget());
+ CollapsibleGroup *group = new CollapsibleGroup(m_groupIndex, ix == 1, ix == m_currentEffectList.count() - 2, m_ui.container->widget());
m_groupIndex++;
- connect(group, SIGNAL(moveEffect(int,int,CollapsibleEffect*)), this , SLOT(slotMoveEffect(int,int,CollapsibleEffect*)));
- connect(group, SIGNAL(unGroup(CollapsibleEffect*)), this , SLOT(slotUnGroup(CollapsibleEffect*)));
+ connect(group, SIGNAL(moveEffect(int,int,int)), this , SLOT(slotMoveEffect(int,int,int)));
+ connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*)));
l->insertWidget(groupPos, group);
group->addGroupEffect(effectToMove);
}
-void EffectStackView2::slotMoveEffect(int currentIndex, int newIndex, CollapsibleEffect* target)
+void EffectStackView2::slotMoveEffect(int currentIndex, int newIndex, int groupIndex)
{
CollapsibleEffect *effectToMove = getEffectByIndex(currentIndex);
if (effectToMove == NULL) return;
EffectInfo effectinfo;
effectinfo.fromString(oldeffect.attribute("kdenlive_info"));
- effectinfo.groupIndex = target->groupIndex();
+ effectinfo.groupIndex = groupIndex;
neweffect.setAttribute("kdenlive_info", effectinfo.toString());
ItemInfo info;
info.cropStart = GenTime(0);
info.startPos = GenTime(-1);
info.track = 0;
- emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->index());
+ emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->effectIndex());
} else {
- emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->index());
+ emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->effectIndex());
}
- if (currentIndex == newIndex) return;
+ //if (currentIndex == newIndex) return;
// Update effect index with new position
if (m_effectMetaInfo.trackMode) {
emit changeEffectPosition(NULL, m_trackindex, currentIndex, newIndex);
}
}
-void EffectStackView2::slotUnGroup(CollapsibleEffect* group)
+void EffectStackView2::slotUnGroup(CollapsibleGroup* group)
{
QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
int ix = l->indexOf(group);