]> git.sesse.net Git - kdenlive/commitdiff
some more UI fixes (slider for rotation)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 7 Jan 2010 01:28:42 +0000 (01:28 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 7 Jan 2010 01:28:42 +0000 (01:28 +0000)
svn path=/trunk/kdenlive/; revision=4214

src/KoSliderCombo.cpp
src/titlewidget.cpp
src/titlewidget.h
src/widgets/titlewidget_ui.ui

index 5b8744f62c8b3874f3925c030ba0cd143284a1ef..47a74736448f1fef8e17e74a138027883f13b1a1 100644 (file)
@@ -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);
 }
index f14eb0055eb4943c2669105cd28b573b06abb9c8..dc071dbf5e3c366060b37f397adaad049288bba3 100644 (file)
@@ -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()
index c7708a3b556ddae575d1a2c62477f9f7e10a5095..700ead558bbdd362ba2d52a53cb99db942336f13 100644 (file)
@@ -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());
 
index ae97c9824793701393d9706719be381ec2c24304..02e7e521fd659c17504c2b9c5cb749bcc5bf4d05 100644 (file)
          </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">
            <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>
              </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>
          </widget>
         </widget>
        </item>
+       <item row="3" column="1">
+        <widget class="KoSliderCombo" name="itemrotate"/>
+       </item>
       </layout>
      </widget>
     </widget>