Commit 6a9528fe authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

some more UI fixes (slider for rotation)

svn path=/trunk/kdenlive/; revision=4214
parent 569e3dbe
......@@ -249,29 +249,29 @@ void KoSliderCombo::mousePressEvent(QMouseEvent *e)
void KoSliderCombo::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Up) setValue(value() + d->slider->singleStep() * maximum() / 256 + 0.5);
else if (e->key() == Qt::Key_Down) setValue(value() - d->slider->singleStep() * maximum() / 256 - 0.5);
if (e->key() == Qt::Key_Up) setValue(value() + d->slider->singleStep() * (maximum() - minimum()) / 256 + 0.5);
else if (e->key() == Qt::Key_Down) setValue(value() - d->slider->singleStep() * (maximum() - minimum()) / 256 - 0.5);
else QComboBox::keyPressEvent(e);
}
void KoSliderCombo::wheelEvent(QWheelEvent *e)
{
if (e->delta() > 0) setValue(value() + d->slider->singleStep() * maximum() / 256 + 0.5);
else setValue(value() - d->slider->singleStep() * maximum() / 256 - 0.5);
if (e->delta() > 0) setValue(value() + d->slider->singleStep() * (maximum() - minimum()) / 256 + 0.5);
else setValue(value() - d->slider->singleStep() * (maximum() - minimum()) / 256 - 0.5);
}
void KoSliderCombo::KoSliderComboPrivate::lineEditFinished()
{
qreal value = thePublic->currentText().toDouble();
slider->blockSignals(true);
slider->setValue(int((value - minimum) * 256 / maximum + 0.5));
slider->setValue(int((value - minimum) * 256 / (maximum - minimum) + 0.5));
slider->blockSignals(false);
emit thePublic->valueChanged(value, true);
}
void KoSliderCombo::KoSliderComboPrivate::sliderValueChanged(int slidervalue)
{
thePublic->setEditText(KGlobal::locale()->formatNumber(minimum + maximum*slidervalue/256, decimals));
thePublic->setEditText(KGlobal::locale()->formatNumber(minimum + (maximum - minimum)*slidervalue/256, decimals));
qreal value = thePublic->currentText().toDouble();
emit thePublic->valueChanged(value, false);
......@@ -328,7 +328,7 @@ void KoSliderCombo::setValue(qreal value)
value = d->maximum;
setEditText(KGlobal::locale()->formatNumber(value, d->decimals));
d->slider->blockSignals(true);
d->slider->setValue(int((value - d->minimum) * 256 / d->maximum + 0.5));
d->slider->setValue(int((value - d->minimum) * 256 / (d->maximum - d->minimum) + 0.5));
d->slider->blockSignals(false);
emit valueChanged(value, true);
}
......
......@@ -90,6 +90,18 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
textOutline->setDecimals(0);
textOutline->setValue(0);
textOutline->setToolTip(i18n("Outline width"));
backgroundAlpha->setMinimum(0);
backgroundAlpha->setMaximum(255);
backgroundAlpha->setDecimals(0);
backgroundAlpha->setValue(0);
backgroundAlpha->setToolTip(i18n("Background color opacity"));
itemrotate->setMinimum(-360);
itemrotate->setMaximum(360);
itemrotate->setDecimals(0);
itemrotate->setValue(0);
itemrotate->setToolTip(i18n("Rotation"));
itemzoom->setSuffix(i18n("%"));
m_frameWidth = render->renderWidth();
......@@ -99,8 +111,8 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
//TODO: get default title duration instead of hardcoded one
title_duration->setText(m_tc.getTimecode(GenTime(5000 / 1000.0)));
connect(kcolorbutton, SIGNAL(clicked()), this, SLOT(slotChangeBackground())) ;
connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeBackground())) ;
connect(backgroundColor, SIGNAL(clicked()), this, SLOT(slotChangeBackground())) ;
connect(backgroundAlpha, SIGNAL(valueChanged(qreal, bool)), this, SLOT(slotChangeBackground())) ;
connect(fontColorButton, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
connect(textOutlineColor, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
......@@ -134,7 +146,7 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
connect(zValue, SIGNAL(valueChanged(int)), this, SLOT(zIndexChanged(int)));
connect(itemzoom, SIGNAL(valueChanged(int)), this, SLOT(itemScaled(int)));
connect(itemrotate, SIGNAL(valueChanged(int)), this, SLOT(itemRotate(int)));
connect(itemrotate, SIGNAL(valueChanged(qreal, bool)), this, SLOT(itemRotate(qreal)));
connect(itemhcenter, SIGNAL(clicked()), this, SLOT(itemHCenter()));
connect(itemvcenter, SIGNAL(clicked()), this, SLOT(itemVCenter()));
connect(itemtop, SIGNAL(clicked()), this, SLOT(itemTop()));
......@@ -251,8 +263,8 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
zoom_slider->setToolTip(i18n("Zoom"));
buttonRealSize->setToolTip(i18n("Original size (1:1)"));
buttonFitZoom->setToolTip(i18n("Fit zoom"));
kcolorbutton->setToolTip(i18n("Select background color"));
horizontalSlider->setToolTip(i18n("Background Transparency"));
backgroundColor->setToolTip(i18n("Select background color"));
backgroundAlpha->setToolTip(i18n("Background Transparency"));
itemhcenter->setIcon(KIcon("kdenlive-align-hor"));
itemhcenter->setToolTip(i18n("Align item horizontally"));
......@@ -1280,8 +1292,8 @@ void TitleWidget::updateAxisButtons(QGraphicsItem *i)
void TitleWidget::slotChangeBackground()
{
QColor color = kcolorbutton->color();
color.setAlpha(horizontalSlider->value());
QColor color = backgroundColor->color();
color.setAlpha(backgroundAlpha->value());
m_frameBorder->setBrush(QBrush(color));
}
......@@ -1421,12 +1433,12 @@ void TitleWidget::itemScaled(int val)
}
}
void TitleWidget::itemRotate(int val)
void TitleWidget::itemRotate(qreal val)
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1) {
Transform x = m_transformations[l.at(0)];
x.rotate = (double)val;
x.rotate = val;
QTransform qtrans;
qtrans.scale(x.scalex, x.scaley);
qtrans.rotate(x.rotate);
......@@ -1644,13 +1656,13 @@ void TitleWidget::setXml(QDomDocument doc)
}
// mbd: Update the GUI color selectors to match the stuff from the loaded document
QColor background_color = m_titledocument.getBackgroundColor();
horizontalSlider->blockSignals(true);
kcolorbutton->blockSignals(true);
horizontalSlider->setValue(background_color.alpha());
backgroundAlpha->blockSignals(true);
backgroundColor->blockSignals(true);
backgroundAlpha->setValue(background_color.alpha());
background_color.setAlpha(255);
kcolorbutton->setColor(background_color);
horizontalSlider->blockSignals(false);
kcolorbutton->blockSignals(false);
backgroundColor->setColor(background_color);
backgroundAlpha->blockSignals(false);
backgroundColor->blockSignals(false);
/*startViewportX->setValue(m_startViewport->data(0).toInt());
startViewportY->setValue(m_startViewport->data(1).toInt());
......@@ -1693,8 +1705,8 @@ void TitleWidget::writeChoices()
titleConfig.writeEntry("rect_background_alpha", rectBAlpha->value());
titleConfig.writeEntry("rect_line_width", rectLineWidth->value());
titleConfig.writeEntry("background_color", kcolorbutton->color());
titleConfig.writeEntry("background_alpha", horizontalSlider->value());
titleConfig.writeEntry("background_color", backgroundColor->color());
titleConfig.writeEntry("background_alpha", backgroundAlpha->value());
//! \todo Not sure if I should sync - it is probably safe to do it
config->sync();
......@@ -1726,8 +1738,8 @@ void TitleWidget::readChoices()
rectBAlpha->setValue(titleConfig.readEntry("rect_background_alpha", rectBAlpha->value()));
rectLineWidth->setValue(titleConfig.readEntry("rect_line_width", rectLineWidth->value()));
kcolorbutton->setColor(titleConfig.readEntry("background_color", kcolorbutton->color()));
horizontalSlider->setValue(titleConfig.readEntry("background_alpha", horizontalSlider->value()));
backgroundColor->setColor(titleConfig.readEntry("background_color", backgroundColor->color()));
backgroundAlpha->setValue(titleConfig.readEntry("background_alpha", backgroundAlpha->value()));
}
void TitleWidget::adjustFrameSize()
......
......@@ -173,7 +173,7 @@ public slots:
void setupViewports();
void zIndexChanged(int);
void itemScaled(int);
void itemRotate(int);
void itemRotate(qreal);
void saveTitle(KUrl url = KUrl());
void loadTitle(KUrl url = KUrl());
......
......@@ -252,16 +252,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KIntSpinBox" name="itemrotate">
<property name="minimum">
<number>-360</number>
</property>
<property name="maximum">
<number>360</number>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
......@@ -524,14 +514,21 @@
<string>Background</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="2">
<widget class="KColorButton" name="kcolorbutton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="2" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="KColorButton" name="backgroundColor">
<property name="color">
<color>
<red>0</red>
......@@ -548,34 +545,8 @@
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QSlider" name="horizontalSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<item row="0" column="1">
<widget class="KoSliderCombo" name="backgroundAlpha"/>
</item>
</layout>
</widget>
......@@ -674,6 +645,9 @@
</widget>
</widget>
</item>
<item row="3" column="1">
<widget class="KoSliderCombo" name="itemrotate"/>
</item>
</layout>
</widget>
</widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment