-/***************************************************************************
+/**************************************************************************
* Copyright (C) 2010 by Till Theato (root@ttill.de) *
* *
* This program is free software; you can redistribute it and/or modify *
#include <QGridLayout>
#include <QLabel>
-#include <QSlider>
#include <QSpinBox>
#include <QToolButton>
#include <KLocalizedString>
-DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, const QString suffix, QWidget *parent) :
+DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, int id, const QString suffix, QWidget *parent) :
QWidget(parent),
- m_default(defaultValue)
+ m_commentLabel(NULL)
{
+ setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
QGridLayout *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
-
- m_name = new QLabel(name, this);
- layout->addWidget(m_name, 0, 0);
-
- m_slider = new QSlider(Qt::Horizontal, this);
- m_slider->setRange(min, max);
- //m_slider->setPageStep((max - min) / 10);
- layout->addWidget(m_slider, 0, 1);
-
- m_dragVal = new DragValue(this);
+
+ m_dragVal = new DragValue(name, defaultValue, id, suffix, this);
m_dragVal->setRange(min, max);
m_dragVal->setPrecision(0);
- layout->addWidget(m_dragVal, 0, 2);
-
- m_spinBox = new QSpinBox(this);
- m_spinBox->setRange(min, max);
- m_spinBox->setKeyboardTracking(false);
- if (!suffix.isEmpty())
- m_spinBox->setSuffix(suffix);
- //layout->addWidget(m_spinBox, 0, 2);
- m_spinBox->setHidden(true);
-
- QToolButton *reset = new QToolButton(this);
- reset->setAutoRaise(true);
- reset->setIcon(KIcon("edit-undo"));
- reset->setToolTip(i18n("Reset to default value"));
- layout->addWidget(reset, 0, 3);
-
- m_commentLabel = new QLabel(comment, this);
- m_commentLabel->setWordWrap(true);
- m_commentLabel->setTextFormat(Qt::RichText);
- m_commentLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
- m_commentLabel->setFrameShape(QFrame::StyledPanel);
- m_commentLabel->setFrameShadow(QFrame::Raised);
- m_commentLabel->setHidden(true);
- layout->addWidget(m_commentLabel, 1, 0, 1, -1);
-
- connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
- connect(m_dragVal, SIGNAL(valueChanged(qreal, bool)), this, SLOT(slotSetValue(qreal, bool)));
- connect(m_spinBox, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
- connect(reset, SIGNAL(clicked(bool)), this, SLOT(slotReset()));
-
- //m_spinBox->setValue(value);
+ layout->addWidget(m_dragVal, 0, 1);
+
+ if (!comment.isEmpty()) {
+ m_commentLabel = new QLabel(comment, this);
+ m_commentLabel->setWordWrap(true);
+ m_commentLabel->setTextFormat(Qt::RichText);
+ m_commentLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ m_commentLabel->setFrameShape(QFrame::StyledPanel);
+ m_commentLabel->setFrameShadow(QFrame::Raised);
+ m_commentLabel->setHidden(true);
+ layout->addWidget(m_commentLabel, 1, 0, 1, -1);
+ }
+ connect(m_dragVal, SIGNAL(valueChanged(int, bool)), this, SLOT(slotSetValue(int, bool)));
+ connect(m_dragVal, SIGNAL(inTimeline(int)), this, SIGNAL(setInTimeline(int)));
m_dragVal->setValue(value);
}
+int DoubleParameterWidget::spinSize()
+{
+ return m_dragVal->spinSize();
+}
+
+void DoubleParameterWidget::setSpinSize(int width)
+{
+ m_dragVal->setSpinSize(width);
+}
+
void DoubleParameterWidget::setValue(int value)
{
- m_slider->blockSignals(true);
- m_spinBox->blockSignals(true);
m_dragVal->blockSignals(true);
-
- m_slider->setValue(value);
- m_spinBox->setValue(value);
m_dragVal->setValue(value);
-
- m_slider->blockSignals(false);
- m_spinBox->blockSignals(false);
m_dragVal->blockSignals(false);
-
- emit valueChanged(value);
+ //emit valueChanged(value);
}
-void DoubleParameterWidget::slotSetValue(qreal value, bool final)
+void DoubleParameterWidget::slotSetValue(int value, bool final)
{
- if (final)
- setValue((int)value);
+ if (final) {
+ emit valueChanged(value);
+ }
}
int DoubleParameterWidget::getValue()
{
- return m_spinBox->value();
+ return m_dragVal->value();
}
-void DoubleParameterWidget::setName(const QString& name)
+void DoubleParameterWidget::slotReset()
{
- m_name->setText(name);
+ m_dragVal->slotReset();
}
-void DoubleParameterWidget::slotReset()
+void DoubleParameterWidget::setInTimelineProperty(bool intimeline)
{
- setValue(m_default);
+ m_dragVal->setInTimelineProperty(intimeline);
}
void DoubleParameterWidget::slotShowComment( bool show)
{
- if (m_commentLabel->text() != QString()) {
+ if (m_commentLabel) {
m_commentLabel->setVisible(show);
if (show)
layout()->setContentsMargins(0, 0, 0, 15);
#include <QWidget>
+
class QLabel;
class QSlider;
class QSpinBox;
* @param comment A comment explaining the parameter. Will be shown for the tooltip.
* @param suffix (optional) Suffix to display in spinbox
* @param parent (optional) Parent Widget */
- DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, const QString suffix = QString(), QWidget* parent = 0);
-
- /** @brief Updates the label to display @param name. */
- void setName(const QString &name);
+ DoubleParameterWidget(const QString &name, int value, int min, int max, int defaultValue, const QString &comment, int id, const QString suffix = QString(), QWidget* parent = 0);
/** @brief Gets the parameter's value. */
int getValue();
+ /** @brief Set the inTimeline property to paint widget with other colors. */
+ void setInTimelineProperty(bool intimeline);
+ /** @brief Returns minimum size for QSpinBox, used to set all spinboxes to the same width. */
+ int spinSize();
+ void setSpinSize(int width);
public slots:
/** @brief Sets the value to @param value. */
/** @brief Shows/Hides the comment label. */
void slotShowComment(bool show);
- void slotSetValue(qreal value, bool final);
+ void slotSetValue(int value, bool final);
private:
- int m_default;
QLabel *m_name;
QSlider *m_slider;
QSpinBox *m_spinBox;
signals:
void valueChanged(int);
+ /** @brief User wants to see this parameter in timeline. */
+ void setInTimeline(int);
};
#endif
/***************************************************************************
* Copyright (C) 2011 by Till Theato (root@ttill.de) *
+ * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* This file is part of Kdenlive (www.kdenlive.org). *
* *
* Kdenlive is free software: you can redistribute it and/or modify *
#include <QApplication>
#include <QMenu>
#include <QAction>
+#include <QLabel>
+#include <QPainter>
+#include <QStyle>
-#include <KColorScheme>
+#include <KIcon>
#include <KLocalizedString>
+#include <KGlobalSettings>
-DragValue::DragValue(QWidget* parent) :
+DragValue::DragValue(const QString &label, int defaultValue, int id, const QString suffix, QWidget* parent) :
QWidget(parent),
m_maximum(100),
m_minimum(0),
m_precision(2),
- m_step(1),
- m_dragMode(false)
+ m_default(defaultValue),
+ m_id(id)
{
- setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
+ setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setFocusPolicy(Qt::StrongFocus);
setContextMenuPolicy(Qt::CustomContextMenu);
-
- QHBoxLayout *l = new QHBoxLayout(this);
+
+ QHBoxLayout *l = new QHBoxLayout;
l->setSpacing(0);
- l->setMargin(0);
-
- m_edit = new QLineEdit(this);
- m_edit->setValidator(new QDoubleValidator(m_minimum, m_maximum, m_precision, this));
- m_edit->setAlignment(Qt::AlignCenter);
- m_edit->setEnabled(false);
+ l->setContentsMargins(0, 0, 0, 0);
+ m_label = new CustomLabel(label, this);
+ m_label->setCursor(Qt::PointingHandCursor);
+ m_label->setRange(m_minimum, m_maximum);
+ l->addWidget(m_label);
+ m_edit = new KIntSpinBox(this);
+ if (!suffix.isEmpty()) m_edit->setSuffix(suffix);
+
+ m_edit->setButtonSymbols(QAbstractSpinBox::NoButtons);
+ m_edit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+ m_edit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
+ m_edit->setRange(m_minimum, m_maximum);
l->addWidget(m_edit);
+ connect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
+ connect(m_label, SIGNAL(valueChanged(int,bool)), this, SLOT(setValue(int,bool)));
+ setLayout(l);
+ m_label->setMaximumHeight(m_edit->sizeHint().height());
m_menu = new QMenu(this);
-
- m_nonlinearScale = new QAction(i18n("Nonlinear scale"), this);
- m_nonlinearScale->setCheckable(true);
- m_nonlinearScale->setChecked(KdenliveSettings::dragvalue_nonlinear());
- m_menu->addAction(m_nonlinearScale);
-
+
+ m_scale = new KSelectAction(i18n("Scaling"), this);
+ m_scale->addAction(i18n("Normal scale"));
+ m_scale->addAction(i18n("Pixel scale"));
+ m_scale->addAction(i18n("Nonlinear scale"));
+ m_scale->setCurrentItem(KdenliveSettings::dragvalue_mode());
+ m_menu->addAction(m_scale);
+
m_directUpdate = new QAction(i18n("Direct update"), this);
m_directUpdate->setCheckable(true);
m_directUpdate->setChecked(KdenliveSettings::dragvalue_directupdate());
m_menu->addAction(m_directUpdate);
-
- QPalette p = palette();
- KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
- QColor bg = scheme.background(KColorScheme::LinkBackground).color();
- QColor fg = scheme.foreground(KColorScheme::LinkText).color();
- QColor editbg = scheme.background(KColorScheme::ActiveBackground).color();
- QColor editfg = scheme.foreground(KColorScheme::ActiveText).color();
- QString stylesheet(QString("QLineEdit { background-color: rgb(%1, %2, %3); border: 1px solid rgb(%1, %2, %3); border-radius: 5px; padding: 0px; color: rgb(%4, %5, %6); } QLineEdit::disabled { color: rgb(%4, %5, %6); }")
- .arg(bg.red()).arg(bg.green()).arg(bg.blue())
- .arg(fg.red()).arg(fg.green()).arg(fg.blue()));
- stylesheet.append(QString("QLineEdit::focus, QLineEdit::enabled { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6); }")
- .arg(editbg.red()).arg(editbg.green()).arg(editbg.blue())
- .arg(editfg.red()).arg(editfg.green()).arg(editfg.blue()));
- setStyleSheet(stylesheet);
-
- updateMaxWidth();
+
+ QAction *reset = new QAction(KIcon("edit-undo"), i18n("Reset value"), this);
+ connect(reset, SIGNAL(triggered()), this, SLOT(slotReset()));
+ m_menu->addAction(reset);
+
+ if (m_id > -1) {
+ QAction *timeline = new QAction(KIcon("go-jump"), i18n("Show %1 in timeline", label), this);
+ connect(timeline, SIGNAL(triggered()), this, SLOT(slotSetInTimeline()));
+ connect(m_label, SIGNAL(setInTimeline()), this, SLOT(slotSetInTimeline()));
+ m_menu->addAction(timeline);
+ }
+
+ m_label->setRange(m_minimum, m_maximum);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotShowContextMenu(const QPoint&)));
- connect(m_nonlinearScale, SIGNAL(triggered(bool)), this, SLOT(slotSetNonlinearScale(bool)));
+ connect(m_scale, SIGNAL(triggered(int)), this, SLOT(slotSetScaleMode(int)));
connect(m_directUpdate, SIGNAL(triggered(bool)), this, SLOT(slotSetDirectUpdate(bool)));
connect(m_edit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
{
delete m_edit;
delete m_menu;
- delete m_nonlinearScale;
+ delete m_scale;
delete m_directUpdate;
}
+int DragValue::spinSize()
+{
+ return m_edit->sizeHint().width();
+}
+
+void DragValue::setSpinSize(int width)
+{
+ m_edit->setMinimumWidth(width);
+}
+
+void DragValue::slotSetInTimeline()
+{
+ emit inTimeline(m_id);
+}
+
int DragValue::precision() const
{
return m_precision;
qreal DragValue::value() const
{
- return m_edit->text().toDouble();
+ return m_edit->value();
}
void DragValue::setMaximum(qreal max)
{
m_maximum = max;
- updateMaxWidth();
+ m_label->setRange(m_minimum, m_maximum);
+ m_edit->setRange(m_minimum, m_maximum);
}
void DragValue::setMinimum(qreal min)
{
m_minimum = min;
- updateMaxWidth();
+ m_label->setRange(m_minimum, m_maximum);
+ m_edit->setRange(m_minimum, m_maximum);
}
void DragValue::setRange(qreal min, qreal max)
{
m_maximum = max;
m_minimum = min;
- updateMaxWidth();
+ m_label->setRange(m_minimum, m_maximum);
+ m_edit->setRange(m_minimum, m_maximum);
}
-void DragValue::setPrecision(int precision)
+void DragValue::setPrecision(int /*precision*/)
{
- m_precision = precision;
+ //TODO: Not implemented, in case we need double value, we should replace the KIntSpinBox with KDoubleNumInput...
+ /*m_precision = precision;
if (precision == 0)
m_edit->setValidator(new QIntValidator(m_minimum, m_maximum, this));
else
- m_edit->setValidator(new QDoubleValidator(m_minimum, m_maximum, precision, this));
+ m_edit->setValidator(new QDoubleValidator(m_minimum, m_maximum, precision, this));*/
}
-void DragValue::setStep(qreal step)
+void DragValue::setStep(qreal /*step*/)
{
- m_step = step;
+ //m_step = step;
}
-void DragValue::setValue(qreal value, bool final)
+void DragValue::slotReset()
{
- value = qBound(m_minimum, value, m_maximum);
+ m_edit->blockSignals(true);
+ m_edit->setValue(m_default);
+ m_label->setValue(m_default);
+ m_edit->blockSignals(false);
+ emit valueChanged(m_default, true);
+}
- m_edit->setText(QString::number(value, 'f', m_precision));
+void DragValue::slotSetValue(int value)
+{
+ setValue(value, KdenliveSettings::dragvalue_directupdate());
+}
+void DragValue::setValue(int value, bool final)
+{
+ value = qBound(m_minimum, value, m_maximum);
+ m_edit->blockSignals(true);
+ m_edit->setValue(value);
+ m_edit->blockSignals(false);
+ m_label->setValue(value);
emit valueChanged(value, final);
}
-void DragValue::mousePressEvent(QMouseEvent* e)
+void DragValue::focusInEvent(QFocusEvent* e)
{
- if (e->button() == Qt::LeftButton) {
- m_dragStartPosition = m_dragLastPosition = e->pos();
- m_dragMode = true;
- e->accept();
+ if (e->reason() == Qt::TabFocusReason || e->reason() == Qt::BacktabFocusReason) {
+ //m_edit->setEnabled(true);
+ m_edit->setFocus(e->reason());
+ } else {
+ QWidget::focusInEvent(e);
}
}
-void DragValue::mouseMoveEvent(QMouseEvent* e)
+void DragValue::slotEditingFinished()
{
- if (m_dragMode && (e->pos() - m_dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) {
- int diff = e->x() - m_dragLastPosition.x();
+ qreal value = m_edit->value();
+ m_edit->clearFocus();
+ emit valueChanged(value, true);
+}
- if (e->modifiers() == Qt::ControlModifier)
- diff *= 2;
- else if (e->modifiers() == Qt::ShiftModifier)
- diff /= 2;
- if (KdenliveSettings::dragvalue_nonlinear())
- diff = (diff > 0 ? 1 : -1) * pow(diff, 2);
+void DragValue::slotShowContextMenu(const QPoint& pos)
+{
+ // values might have been changed by another object of this class
+ m_scale->setCurrentItem(KdenliveSettings::dragvalue_mode());
+ m_directUpdate->setChecked(KdenliveSettings::dragvalue_directupdate());
+ m_menu->exec(mapToGlobal(pos));
+}
- setValue(value() + diff / m_step, KdenliveSettings::dragvalue_directupdate());
- m_dragLastPosition = e->pos();
- e->accept();
- }
+void DragValue::slotSetScaleMode(int mode)
+{
+ KdenliveSettings::setDragvalue_mode(mode);
}
-void DragValue::mouseReleaseEvent(QMouseEvent* e)
+void DragValue::slotSetDirectUpdate(bool directUpdate)
{
- m_dragMode = false;
- if (m_dragLastPosition == m_dragStartPosition) {
- // value was not changed through dragging (mouse position stayed the same since mousePressEvent)
- m_edit->setEnabled(true);
- m_edit->setFocus(Qt::MouseFocusReason);
- } else {
- setValue(value(), true);
- m_dragLastPosition = m_dragStartPosition;
- e->accept();
- }
+ KdenliveSettings::setDragvalue_directupdate(directUpdate);
}
-void DragValue::wheelEvent(QWheelEvent* e)
+void DragValue::setInTimelineProperty(bool intimeline)
{
- if (e->delta() > 0)
- slotValueInc();
- else
- slotValueDec();
+ if (m_label->property("inTimeline").toBool() == intimeline) return;
+ m_label->setProperty("inTimeline", intimeline);
+ m_edit->setProperty("inTimeline", intimeline);
+ style()->unpolish(m_label);
+ style()->polish(m_label);
+ m_label->update();
+ style()->unpolish(m_edit);
+ style()->polish(m_edit);
+ m_edit->update();
}
-void DragValue::focusInEvent(QFocusEvent* e)
+CustomLabel::CustomLabel(const QString &label, QWidget* parent) :
+ QProgressBar(parent),
+ m_dragMode(false),
+ m_step(1)
+
{
- if (e->reason() == Qt::TabFocusReason || e->reason() == Qt::BacktabFocusReason) {
- m_edit->setEnabled(true);
- m_edit->setFocus(e->reason());
- } else {
- QWidget::focusInEvent(e);
- }
+ setFormat(" " + label);
+ setFocusPolicy(Qt::ClickFocus);
+ setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
+ setRange(0, 100);
+ setValue(0);
+ setFont(KGlobalSettings::toolBarFont());
}
-void DragValue::slotValueInc()
+void CustomLabel::mousePressEvent(QMouseEvent* e)
{
- setValue(m_edit->text().toDouble() + m_step);
+ if (e->button() == Qt::LeftButton) {
+ m_dragStartPosition = m_dragLastPosition = e->pos();
+ e->accept();
+ }
+ else QWidget::mousePressEvent(e);
}
-void DragValue::slotValueDec()
+void CustomLabel::mouseMoveEvent(QMouseEvent* e)
{
- setValue(m_edit->text().toDouble() - m_step);
+ if ((e->pos() - m_dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) {
+ m_dragMode = true;
+ if (KdenliveSettings::dragvalue_mode() > 0) {
+ int diff = e->x() - m_dragLastPosition.x();
+
+ if (e->modifiers() == Qt::ControlModifier)
+ diff *= 2;
+ else if (e->modifiers() == Qt::ShiftModifier)
+ diff /= 2;
+ if (KdenliveSettings::dragvalue_mode() == 2)
+ diff = (diff > 0 ? 1 : -1) * pow(diff, 2);
+
+ int nv = value() + diff / m_step;
+ if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+ }
+ else {
+ int nv = minimum() + ((double) maximum() - minimum()) / width() * e->pos().x();
+ if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+ }
+ m_dragLastPosition = e->pos();
+ e->accept();
+ }
+ else QWidget::mouseMoveEvent(e);
}
-void DragValue::slotEditingFinished()
+void CustomLabel::mouseReleaseEvent(QMouseEvent* e)
{
- qreal value = m_edit->text().toDouble();
- m_edit->setEnabled(false);
- emit valueChanged(value, true);
+ if (e->modifiers() == Qt::ControlModifier) {
+ emit setInTimeline();
+ e->accept();
+ return;
+ }
+ if (m_dragMode) {
+ setNewValue(value(), true);
+ m_dragLastPosition = m_dragStartPosition;
+ e->accept();
+ }
+ else {
+ setNewValue((int) (minimum() + ((double)maximum() - minimum()) / width() * e->pos().x()), KdenliveSettings::dragvalue_directupdate());
+ m_dragLastPosition = m_dragStartPosition;
+ e->accept();
+ }
+ m_dragMode = false;
}
-void DragValue::updateMaxWidth()
+void CustomLabel::wheelEvent(QWheelEvent* e)
{
- int val = (int)(log10(qAbs(m_maximum) > qAbs(m_minimum) ? qAbs(m_maximum) : qAbs(m_minimum)) + .5);
- val += m_precision;
- if (m_precision)
- val += 1;
- if (m_minimum < 0)
- val += 1;
- QFontMetrics fm = m_edit->fontMetrics();
- m_edit->setMaximumWidth(fm.width(QString().rightJustified(val, '8')));
+ if (e->delta() > 0) {
+ if (e->modifiers() == Qt::ControlModifier) slotValueInc(10);
+ else slotValueInc();
+ }
+ else {
+ if (e->modifiers() == Qt::ControlModifier) slotValueDec(10);
+ else slotValueDec();
+ }
+ e->accept();
}
-void DragValue::slotShowContextMenu(const QPoint& pos)
+void CustomLabel::slotValueInc(int factor)
{
- // values might have been changed by another object of this class
- m_nonlinearScale->setChecked(KdenliveSettings::dragvalue_nonlinear());
- m_directUpdate->setChecked(KdenliveSettings::dragvalue_directupdate());
- m_menu->exec(mapToGlobal(pos));
+ setNewValue((int) (value() + m_step * factor), true);
}
-void DragValue::slotSetNonlinearScale(bool nonlinear)
+void CustomLabel::slotValueDec(int factor)
{
- KdenliveSettings::setDragvalue_nonlinear(nonlinear);
+ setNewValue((int) (value() - m_step * factor), true);
}
-void DragValue::slotSetDirectUpdate(bool directUpdate)
+void CustomLabel::setNewValue(int value, bool update)
{
- KdenliveSettings::setDragvalue_directupdate(directUpdate);
+ setValue(value);
+ emit valueChanged(value, update);
}
#include "dragvalue.moc"
+
#define DRAGVALUE_H_
#include <QWidget>
+#include <kselectaction.h>
+#include <KIntSpinBox>
+#include <QLabel>
+#include <QProgressBar>
class QValidator;
class QToolButton;
class QLineEdit;
class QAction;
class QMenu;
+class KSelectAction;
+
+
+class CustomLabel : public QProgressBar
+{
+ Q_OBJECT
+public:
+ CustomLabel(const QString &label, QWidget *parent = 0);
+
+protected:
+ //virtual void mouseDoubleClickEvent(QMouseEvent * event);
+ virtual void mousePressEvent(QMouseEvent * event);
+ virtual void mouseReleaseEvent(QMouseEvent *event);
+ virtual void mouseMoveEvent(QMouseEvent *event);
+ //virtual void paintEvent(QPaintEvent *event);
+ virtual void wheelEvent(QWheelEvent * event);
+
+private:
+ QPoint m_dragStartPosition;
+ QPoint m_dragLastPosition;
+ bool m_dragMode;
+ double m_step;
+ //QStyleOptionProgressBarV2 m_progressOptions;
+ void slotValueInc(int factor = 1);
+ void slotValueDec(int factor = 1);
+ void setNewValue(int, bool);
+
+signals:
+ void valueChanged(int, bool);
+ void setInTimeline();
+};
/**
* @brief A widget for modifing numbers by dragging, using the mouse wheel or entering them with the keyboard.
Q_OBJECT
public:
- DragValue(QWidget* parent = 0);
+ DragValue(const QString &label, int defaultValue, int id, const QString suffix, QWidget* parent = 0);
virtual ~DragValue();
/** @brief Returns the precision = number of decimals */
/** @brief Returns the current value */
qreal value() const;
-
+ /** @brief Change the "inTimeline" property to paint the intimeline widget differently. */
+ void setInTimelineProperty(bool intimeline);
+ /** @brief Returns minimum size for QSpinBox, used to set all spinboxes to the same width. */
+ int spinSize();
+ /** @brief Sets the minimum size for QSpinBox, used to set all spinboxes to the same width. */
+ void setSpinSize(int width);
+
public slots:
/** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
- void setValue(qreal value, bool final = true);
+ void setValue(int value, bool final = true);
+ /** @brief Resets to default value */
+ void slotReset();
signals:
- void valueChanged(qreal value, bool final);
-
+ void valueChanged(int value, bool final = true);
+ void inTimeline(int);
*/
protected:
- virtual void mousePressEvent(QMouseEvent *e);
+ /*virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
- virtual void mouseReleaseEvent(QMouseEvent *e);
+ virtual void mouseReleaseEvent(QMouseEvent *e);*/
/** @brief Forwards tab focus to lineedit since it is disabled. */
virtual void focusInEvent(QFocusEvent *e);
//virtual void keyPressEvent(QKeyEvent *e);
- virtual void wheelEvent(QWheelEvent *e);
+ //virtual void wheelEvent(QWheelEvent *e);
+ //virtual void paintEvent( QPaintEvent * event );
private slots:
- void slotValueInc();
- void slotValueDec();
+
void slotEditingFinished();
- void slotSetNonlinearScale(bool nonlinear);
+ void slotSetScaleMode(int mode);
void slotSetDirectUpdate(bool directUpdate);
void slotShowContextMenu(const QPoint &pos);
+ void slotSetValue(int value);
+ void slotSetInTimeline();
private:
- qreal m_maximum;
- qreal m_minimum;
+ int m_maximum;
+ int m_minimum;
int m_precision;
- qreal m_step;
- QLineEdit *m_edit;
- QPoint m_dragStartPosition;
- QPoint m_dragLastPosition;
- bool m_dragMode;
+ KIntSpinBox *m_edit;
+ int m_default;
QMenu *m_menu;
- QAction *m_nonlinearScale;
+ KSelectAction *m_scale;
QAction *m_directUpdate;
-
- /** @brief Sets the maximum width of the widget so that there is enough space for the widest possible value. */
- void updateMaxWidth();
+ CustomLabel *m_label;
+ int m_id;
};
#endif
#include <KDebug>
#include <KLocale>
#include <KFileDialog>
+#include <KColorScheme>
#include <QVBoxLayout>
#include <QLabel>
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setFrameStyle(QFrame::NoFrame);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
-
+
+ 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);
+ QColor mid_bg = scheme.shade(KColorScheme::DarkShade);
+
+ QString stylesheet(QString("QProgressBar:horizontal {border: 1px solid %5;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:hover {border: 1px solid %3;border-right: 0px;} QProgressBar::chunk:horizontal {background: %5;} 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;} QSpinBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QSpinBox::down-button {width:0px;padding:0px;} QSpinBox::up-button {width:0px;padding:0px;} QSpinBox[inTimeline=\"true\"]{ border: 1px solid %2;} QSpinBox:hover {border: 1px solid %3;} ").arg(dark_bg.name()).arg(selected_bg.name()).arg(hover_bg.name()).arg(light_bg.name()).arg(mid_bg.name()));
+ setStyleSheet(stylesheet);
+
setWidget(m_baseWidget);
setWidgetResizable(true);
m_vbox = new QVBoxLayout(m_baseWidget);
m_vbox->setContentsMargins(0, 0, 0, 0);
- m_vbox->setSpacing(0);
- //wid->show();
+ m_vbox->setSpacing(2);
}
EffectStackEdit::~EffectStackEdit()
max = pa.attribute("max").toInt();
DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
- pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
+ pa.attribute("default").toInt(), comment, -1, pa.attribute("suffix"), this);
m_vbox->addWidget(doubleparam);
m_valueItems[paramName] = doubleparam;
connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
if (m_keyframeEditor)
m_keyframeEditor->checkVisibleParam();
+
+ // Make sure all doubleparam spinboxes have the same width, looks much better
+ QList<DoubleParameterWidget *> allWidgets = findChildren<DoubleParameterWidget *>();
+ int minSize = 0;
+ for (int i = 0; i < allWidgets.count(); i++) {
+ if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize();
+ }
+ for (int i = 0; i < allWidgets.count(); i++) {
+ allWidgets.at(i)->setSpinSize(minSize);
+ }
}
wipeInfo EffectStackEdit::getWipeInfo(QString value)
m_ui.setupUi(this);
QVBoxLayout *vbox1 = new QVBoxLayout(m_ui.frame);
m_effectedit = new EffectStackEdit(monitor, m_ui.frame);
- vbox1->setContentsMargins(0, 0, 0, 0);
+ vbox1->setContentsMargins(2, 0, 2, 0);
vbox1->setSpacing(0);
vbox1->addWidget(m_effectedit);
+ m_ui.splitter->setStretchFactor(0, 0);
+ m_ui.splitter->setStretchFactor(1, 200);
//m_ui.region_url->fileDialog()->setFilter(ProjectList::getExtensions());
//m_ui.effectlist->horizontalHeader()->setVisible(false);
m_clipref = c;
if (c) {
QString cname = m_clipref->clipName();
- if (cname.length() > 20) {
+ if (cname.length() > 30) {
m_ui.checkAll->setToolTip(i18n("Effects for %1").arg(cname));
- cname.truncate(17);
+ cname.truncate(27);
m_ui.checkAll->setText(i18n("Effects for %1").arg(cname) + "...");
} else {
m_ui.checkAll->setToolTip(QString());
<label>...</label>
<default>false</default>
</entry>
+ <entry name="dragvalue_mode" type="Int">
+ <label>...</label>
+ <default>0</default>
+ </entry>
<entry name="dragvalue_directupdate" type="Bool">
<label>...</label>
<default>false</default>
#include <KGlobalSettings>
#include <QHeaderView>
-#include <QButtonGroup>
-#include <QRadioButton>
KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, Timecode tc, int activeKeyframe, QWidget* parent) :
QWidget(parent),
m_position = new PositionEdit(i18n("Position"), 0, 0, 1, tc, widgetTable);
((QGridLayout*)widgetTable->layout())->addWidget(m_position, 3, 0, 1, -1);
- m_showButtons = new QButtonGroup(this);
m_slidersLayout = new QGridLayout(param_sliders);
+ //m_slidersLayout->setSpacing(0);
+
+ m_slidersLayout->setContentsMargins(0, 0, 0, 0);
+ m_slidersLayout->setVerticalSpacing(2);
keyframe_list->setSelectionBehavior(QAbstractItemView::SelectRows);
keyframe_list->setSelectionMode(QAbstractItemView::SingleSelection);
addParameter(e, activeKeyframe);
connect(buttonKeyframes, SIGNAL(clicked()), this, SLOT(slotKeyframeMode()));
connect(buttonResetKeyframe, SIGNAL(clicked()), this, SLOT(slotResetKeyframe()));
connect(m_position, SIGNAL(parameterChanged(int)), this, SLOT(slotAdjustKeyframePos(int)));
- connect(m_showButtons, SIGNAL(buttonClicked(int)), this, SLOT(slotUpdateVisibleParameter(int)));
//connect(keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int)));
QString comment;
if (!commentElem.isNull())
comment = i18n(commentElem.text().toUtf8().data());
-
+
int columnId = keyframe_list->columnCount();
keyframe_list->insertColumn(columnId);
keyframe_list->setHorizontalHeaderItem(columnId, new QTableWidgetItem(paramName));
DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, 0,
m_params.at(columnId).attribute("min").toInt(), m_params.at(columnId).attribute("max").toInt(),
- m_params.at(columnId).attribute("default").toInt(), comment, m_params.at(columnId).attribute("suffix"), this);
+ m_params.at(columnId).attribute("default").toInt(), comment, columnId, m_params.at(columnId).attribute("suffix"), this);
connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframeValue(int)));
connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
+ connect(doubleparam, SIGNAL(setInTimeline(int)), this, SLOT(slotUpdateVisibleParameter(int)));
m_slidersLayout->addWidget(doubleparam, columnId, 0);
-
- QRadioButton *radio = new QRadioButton(this);
- radio->setToolTip(i18n("Show %1 in timeline").arg(paramName));
- m_showButtons->addButton(radio, columnId);
- if (e.attribute("intimeline") == "1")
- radio->setChecked(true);
-
- QVBoxLayout *radioLayout = new QVBoxLayout;
- radioLayout->addWidget(radio, 0, Qt::AlignTop);
- m_slidersLayout->addLayout(radioLayout, columnId, 1);
+ if (e.attribute("intimeline") == "1") {
+ doubleparam->setInTimelineProperty(true);
+ }
QStringList frames = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
for (int i = 0; i < frames.count(); i++) {
void KeyframeEdit::slotUpdateVisibleParameter(int id, bool update)
{
- for (int i = 0; i < m_params.count(); ++i)
- m_params[i].setAttribute("intimeline", (i == id ? "1" : "0"));
+ for (int i = 0; i < m_params.count(); ++i) {
+ m_params[i].setAttribute("intimeline", (i == id ? "1" : "0"));
+ }
+ for (int col = 0; col < keyframe_list->columnCount(); col++) {
+ DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget());
+ if (!doubleparam)
+ continue;
+ doubleparam->setInTimelineProperty(col == id);
+ //kDebug()<<"// PARAM: "<<col<<" Set TO: "<<(bool) (col == id);
+
+ }
if (update) emit parameterChanged();
}
{
if (m_params.count() == 0)
return;
-
+
foreach(QDomElement elem, m_params) {
if (elem.attribute("intimeline") == "1")
return;
}
slotUpdateVisibleParameter(0);
- QRadioButton *radio = static_cast<QRadioButton*>(m_slidersLayout->itemAtPosition(0, 1)->layout()->itemAt(0)->widget());
- if (radio)
- radio->setChecked(true);
}
#include "keyframeedit.moc"
QList <QDomElement> m_params;
Timecode m_timecode;
QGridLayout *m_slidersLayout;
- QButtonGroup *m_showButtons;
PositionEdit *m_position;
private slots:
<rect>
<x>0</x>
<y>0</y>
- <width>458</width>
- <height>255</height>
+ <width>207</width>
+ <height>228</height>
</rect>
</property>
<property name="sizePolicy">
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="verticalSpacing">
+ <number>0</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
<item row="0" column="0">
+ <widget class="QCheckBox" name="checkAll">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QToolButton" name="buttonShowComments">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <widget class="QWidget" name="layoutWidget">
- <layout class="QGridLayout" name="gridLayout">
- <property name="horizontalSpacing">
- <number>2</number>
- </property>
- <item row="1" column="0" colspan="7">
+ <widget class="QWidget" name="">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
<widget class="KListWidget" name="effectlist">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QToolButton" name="buttonNew">
- <property name="text">
- <string notr="true">N</string>
- </property>
- <property name="popupMode">
- <enum>QToolButton::InstantPopup</enum>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QToolButton" name="buttonUp">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true">Up</string>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QToolButton" name="buttonDown">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true">Dw</string>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="3">
- <widget class="QToolButton" name="buttonReset">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true">R</string>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="4">
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="5">
- <widget class="QToolButton" name="buttonSave">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true">E</string>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="6">
- <widget class="QToolButton" name="buttonDel">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true">D</string>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="7">
- <widget class="QCheckBox" name="checkAll">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true"/>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
- </widget>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QToolButton" name="buttonNew">
+ <property name="text">
+ <string notr="true">N</string>
+ </property>
+ <property name="popupMode">
+ <enum>QToolButton::InstantPopup</enum>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="buttonUp">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string notr="true">Up</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="buttonDown">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string notr="true">Dw</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="buttonReset">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string notr="true">R</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="buttonSave">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string notr="true">E</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="buttonDel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string notr="true">D</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
- <widget class="QWidget" name="layoutWidget_2">
- <layout class="QGridLayout" name="layoutEdit">
- <item row="1" column="0" colspan="2">
+ <widget class="QWidget" name="">
+ <layout class="QVBoxLayout" name="layoutEdit">
+ <item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QToolButton" name="buttonShowComments">
- <property name="text">
- <string/>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" colspan="2">
+ <item>
<widget class="QLabel" name="labelComment">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">