]> git.sesse.net Git - kdenlive/commitdiff
Changes on titler:
authorSimon A. Eugster <simon.eu@gmail.com>
Wed, 24 Jun 2009 15:12:27 +0000 (15:12 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Wed, 24 Jun 2009 15:12:27 +0000 (15:12 +0000)
* Added separator between the tools (select, text, etc) and the open/save buttons to avoid confusion
* Added empty toolbar which is shown when the selected item doesn't have special properties (like text size)
* Fixed toolbar not being active after adding a text item (only after selecting it with the mouse)
* Added methods to show/enable toolbars to avoid mistakes in the source code.

svn path=/trunk/kdenlive/; revision=3638

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

index 57970f39b51fbfd8322444711e4f826a497a1d89..cb2c07f86e87439675baf5df42df7afde1a9eeb6 100644 (file)
@@ -24,7 +24,7 @@
 #include <QGraphicsScene>
 
 enum resizeModes {NoResize, TopLeft, BottomLeft, TopRight, BottomRight, Left, Right, Up, Down};
-enum TITLETOOL { TITLE_SELECT = 0, TITLE_RECTANGLE = 1, TITLE_TEXT = 2, TITLE_IMAGE = 3 };
+enum TITLETOOL { TITLE_NONE = -1, TITLE_SELECT = 0, TITLE_RECTANGLE = 1, TITLE_TEXT = 2, TITLE_IMAGE = 3 };
 
 class GraphicsSceneRectMove: public QGraphicsScene
 {
index a2fd1d7c7e578c333a1e998a4667a559905a9e1c..392a1cfffaf087346ceb3085c2ecac1b9d227326 100644 (file)
@@ -167,6 +167,8 @@ TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWi
     m_buttonCursor->setCheckable(true);
     m_buttonCursor->setShortcut(Qt::ALT + Qt::Key_S);
     connect(m_buttonCursor, SIGNAL(triggered()), this, SLOT(slotSelectTool()));
+       
+       m_toolbar->addSeparator();
 
     m_buttonLoad = m_toolbar->addAction(KIcon("document-open"), i18n("Open Document"));
     m_buttonLoad->setCheckable(false);
@@ -179,7 +181,6 @@ TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWi
     connect(m_buttonSave, SIGNAL(triggered()), this, SLOT(saveTitle()));
 
     layout->addWidget(m_toolbar);
-    text_properties->setHidden(true);
 
     // initialize graphic scene
     m_scene = new GraphicsSceneRectMove(this);
@@ -237,6 +238,8 @@ TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWi
     } else {
         slotRectTool();
     }
+       
+       showToolbars(TITLE_NONE);
 }
 
 TitleWidget::~TitleWidget()
@@ -290,18 +293,16 @@ void TitleWidget::resizeEvent(QResizeEvent * /*event*/)
 
 void TitleWidget::slotTextTool()
 {
-    rect_properties->setHidden(true);
-    text_properties->setHidden(false);
     m_scene->setTool(TITLE_TEXT);
+       showToolbars(TITLE_TEXT);
     m_buttonRect->setChecked(false);
     m_buttonCursor->setChecked(false);
 }
 
 void TitleWidget::slotRectTool()
 {
-    text_properties->setHidden(true);
-    rect_properties->setHidden(false);
     m_scene->setTool(TITLE_RECTANGLE);
+       showToolbars(TITLE_RECTANGLE);
     m_buttonText->setChecked(false);
     m_buttonCursor->setChecked(false);
     m_buttonRect->setChecked(true);
@@ -310,6 +311,26 @@ void TitleWidget::slotRectTool()
 void TitleWidget::slotSelectTool()
 {
     m_scene->setTool(TITLE_SELECT);
+       
+       // Find out which toolbars need to be shown, depending on selected item
+       TITLETOOL t = TITLE_SELECT;
+       QList<QGraphicsItem *> l = graphicsView->scene()->selectedItems();
+       if (l.size() > 0) {
+               switch (l.at(0)->type()) {
+                       case TEXTITEM:
+                               t = TITLE_TEXT;
+                               break;
+                       case RECTITEM:
+                               t = TITLE_RECTANGLE;
+                               break;
+                       case IMAGEITEM:
+                               t = TITLE_IMAGE;
+                               break;
+               }
+       }
+       enableToolbars(t);
+       showToolbars(t);
+       
     m_buttonCursor->setChecked(true);
     m_buttonText->setChecked(false);
     m_buttonRect->setChecked(false);
@@ -336,11 +357,70 @@ void TitleWidget::slotImageTool()
         }
     }
     m_scene->setTool(TITLE_SELECT);
+       showToolbars(TITLE_SELECT);
     m_buttonRect->setChecked(false);
     m_buttonCursor->setChecked(true);
     m_buttonText->setChecked(false);
 }
 
+void TitleWidget::showToolbars(TITLETOOL toolType)
+{
+       bool bText = false;
+       bool bRect = false;
+       bool bNone = false;
+       
+       switch (toolType) {
+               case TITLE_TEXT:
+                       bText = true;
+                       break;
+               case TITLE_RECTANGLE:
+                       bRect = true;
+                       break;
+               case TITLE_IMAGE: //fall through
+               default:
+                       bNone = true;
+                       break;
+       }
+       text_properties->setHidden(!bText);
+       rect_properties->setHidden(!bRect);
+       no_properties->setHidden(!bNone);
+}
+
+void TitleWidget::enableToolbars(TITLETOOL toolType)
+{
+       // TITLETOOL is defined in graphicsscenerectmove.h
+       bool bFrame = false;
+       bool bText = false;
+       bool bRect = false;
+       bool bValue_w = false;
+       bool bValue_h = false;
+       
+       switch (toolType) {
+               case TITLE_SELECT:
+                       break;
+               case TITLE_TEXT:
+                       bFrame = true;
+                       bText = true;
+                       break;
+               case TITLE_RECTANGLE:
+                       bFrame = true;
+                       bRect = true;
+                       bValue_w = true;
+                       bValue_h = true;
+                       break;
+               case TITLE_IMAGE:
+                       bFrame = true;
+                       break;
+               default:
+                       break;
+       }
+       frame_properties->setEnabled(bFrame);
+       text_properties->setEnabled(bText);
+       rect_properties->setEnabled(bRect);
+       value_w->setEnabled(bValue_w);
+       value_h->setEnabled(bValue_h);
+}
+
 void TitleWidget::displayBackgroundFrame()
 {
     if (!displayBg->isChecked()) {
@@ -487,15 +567,12 @@ void TitleWidget::selectionChanged()
         origin_y_top->setChecked(false);
         updateTextOriginX();
         updateTextOriginY();
-        frame_properties->setEnabled(false);
-        text_properties->setEnabled(false);
-        rect_properties->setEnabled(false);
+               enableToolbars(TITLE_NONE);
         if (blockX) origin_x_left->blockSignals(false);
         if (blockY) origin_y_top->blockSignals(false);
     } else if (l.size() == 1) {
         if (l.at(0)->type() == TEXTITEM) {
-            rect_properties->setHidden(true);
-            text_properties->setHidden(false);
+                       showToolbars(TITLE_TEXT);
             QGraphicsTextItem* i = static_cast <QGraphicsTextItem *>(l.at(0));
             //if (l[0]->hasFocus())
             toolBox->setCurrentIndex(0);
@@ -545,17 +622,10 @@ void TitleWidget::selectionChanged()
             updateAxisButtons(i);
             updateCoordinates(i);
             updateDimension(i);
-            //value_w->setValue((int) i->boundingRect().width());
-            //value_h->setValue((int) i->boundingRect().height());
-            frame_properties->setEnabled(true);
-            text_properties->setEnabled(true);
-            rect_properties->setEnabled(false);
-            value_w->setEnabled(false);
-            value_h->setEnabled(false);
+                       enableToolbars(TITLE_TEXT);
 
         } else if ((l.at(0))->type() == RECTITEM) {
-            rect_properties->setHidden(false);
-            text_properties->setHidden(true);
+                       showToolbars(TITLE_RECTANGLE);
             settingUp = true;
             QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(l.at(0));
             toolBox->setCurrentIndex(0);
@@ -575,30 +645,20 @@ void TitleWidget::selectionChanged()
             updateAxisButtons(l.at(0));
             updateCoordinates(rec);
             updateDimension(rec);
-            //value_w->setValue((int) rec->rect().width());
-            //value_h->setValue((int) rec->rect().height());
-            frame_properties->setEnabled(true);
-            text_properties->setEnabled(false);
-            rect_properties->setEnabled(true);
-            value_w->setEnabled(true);
-            value_h->setEnabled(true);
+                       enableToolbars(TITLE_RECTANGLE);
 
         } else if (l.at(0)->type() == IMAGEITEM) {
             updateCoordinates(l.at(0));
             updateDimension(l.at(0));
 
-            frame_properties->setEnabled(true);
-            text_properties->setEnabled(false);
-            rect_properties->setEnabled(false);
-            value_x->setEnabled(true);
-            value_w->setEnabled(false);
-            value_h->setEnabled(false);
+                       enableToolbars(TITLE_IMAGE);
 
         } else {
             //toolBox->setCurrentIndex(0);
-            frame_properties->setEnabled(false);
+                       enableToolbars(TITLE_NONE);
+            /*frame_properties->setEnabled(false);
             text_properties->setEnabled(false);
-            rect_properties->setEnabled(false);
+            rect_properties->setEnabled(false);*/
         }
         zValue->setValue((int)l.at(0)->zValue());
         itemzoom->setValue((int)(m_transformations.value(l.at(0)).scalex * 100.0 + 0.5));
index 1b51e2cf28c94be11d97b7a166614c9784766829..1126c9e3bf049f67d6cad24dd710ad1554743c18 100644 (file)
@@ -114,6 +114,11 @@ private:
 
     void updateTextOriginX();
     void updateTextOriginY();
+       
+       /** \brief Enables the toolbars suiting to toolType */
+       void enableToolbars(TITLETOOL toolType);
+       /** \brief Shows the toolbars suiting to toolType */
+       void showToolbars(TITLETOOL toolType);
 
 public slots:
     void slotNewText(QGraphicsTextItem *tt);
index 5e8ca00608b8ae55e4b58f32cc9a9611dc6f4b5d..b81224468cb864dca9bb999a4759686c34949b95 100644 (file)
      </property>
     </spacer>
    </item>
+   <item row="1" column="1" colspan="9">
+    <widget class="QFrame" name="no_properties">
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Sunken</enum>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <item>
+       <widget class="QLabel" name="label">
+        <property name="font">
+         <font>
+          <pointsize>9</pointsize>
+          <italic>true</italic>
+         </font>
+        </property>
+        <property name="locale">
+         <locale language="English" country="UnitedStates"/>
+        </property>
+        <property name="text">
+         <string>Item Properties</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <spacer name="horizontalSpacer_5">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
    <item row="2" column="1" colspan="9">
     <widget class="QFrame" name="rect_properties">
      <property name="frameShape">
       <property name="rightMargin">
        <number>2</number>
       </property>
-      <item row="0" column="0">
+      <item row="4" column="0">
        <layout class="QHBoxLayout" name="horizontalLayout_4">
         <item>
          <widget class="QFontComboBox" name="font_family"/>
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>443</width>
-         <height>143</height>
+         <width>431</width>
+         <height>140</height>
         </rect>
        </property>
        <attribute name="label">
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>96</width>
-         <height>73</height>
+         <width>431</width>
+         <height>144</height>
         </rect>
        </property>
        <attribute name="label">
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>272</width>
-         <height>224</height>
+         <width>416</width>
+         <height>198</height>
         </rect>
        </property>
        <attribute name="label">