]> git.sesse.net Git - kdenlive/commitdiff
slowly getting ready for downloading rendering profiles
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 Feb 2009 16:56:21 +0000 (16:56 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 Feb 2009 16:56:21 +0000 (16:56 +0000)
svn path=/branches/KDE4/; revision=3059

src/renderwidget.cpp
src/widgets/saveprofile_ui.ui

index c585b0f584ad9785069fa8afd62ba66d210a5cf6..c3cabdf27f5e825cd1a8e23646cd2632fb8a79fd 100644 (file)
@@ -21,6 +21,7 @@
 #include <QDomDocument>
 #include <QItemDelegate>
 #include <QTreeWidgetItem>
+#include <QListWidgetItem>
 #include <QHeaderView>
 #include <QMenu>
 #include <QProcess>
@@ -225,9 +226,16 @@ void RenderWidget::slotUpdateButtons() {
 }
 
 void RenderWidget::slotSaveProfile() {
+    //TODO: update to correctly use metagroups
     Ui::SaveProfile_UI ui;
     QDialog *d = new QDialog(this);
     ui.setupUi(d);
+
+    for (int i = 0; i < m_view.destination_list->count(); i++)
+        ui.destination_list->addItem(m_view.destination_list->itemIcon(i), m_view.destination_list->itemText(i), m_view.destination_list->itemData(i, MetaGroupRole));
+
+    ui.destination_list->setCurrentIndex(m_view.destination_list->currentIndex());
+
     QString customGroup = i18n("Custom");
     QStringList groupNames;
     for (int i = 0; i < m_view.format_list->count(); i++)
@@ -295,6 +303,7 @@ void RenderWidget::slotSaveProfile() {
 }
 
 void RenderWidget::slotEditProfile() {
+    //TODO: update to correctly use metagroups
     QListWidgetItem *item = m_view.size_list->currentItem();
     if (!item) return;
     QString currentGroup = m_view.format_list->currentItem()->text();
@@ -585,9 +594,12 @@ void RenderWidget::refreshView() {
     QListWidgetItem *sizeItem;
 
     QString destination;
+    KIcon brokenIcon("dialog-close");
     if (m_view.destination_list->currentIndex() > 0)
         destination = m_view.destination_list->itemData(m_view.destination_list->currentIndex()).toString();
 
+    kDebug() << "// SELECTED DESTINATION: " << destination;
+
     if (destination == "dvd") m_view.open_dvd->setVisible(true);
     else m_view.open_dvd->setVisible(false);
     if (destination == "websites") m_view.open_browser->setVisible(true);
@@ -598,9 +610,10 @@ void RenderWidget::refreshView() {
     // hide groups that are not in the correct destination
     for (int i = 0; i < m_view.format_list->count(); i++) {
         sizeItem = m_view.format_list->item(i);
-        if (sizeItem->data(MetaGroupRole).toString() == destination)
+        if (sizeItem->data(MetaGroupRole).toString() == destination) {
             sizeItem->setHidden(false);
-        else sizeItem->setHidden(true);
+            kDebug() << "// SET GRP:: " << sizeItem->text() << ", METY:" << sizeItem->data(MetaGroupRole).toString();
+        } else sizeItem->setHidden(true);
     }
 
     // activate first visible item
@@ -614,7 +627,7 @@ void RenderWidget::refreshView() {
         }
         item = m_view.format_list->currentItem();
     }
-    if (!item) return;
+    if (!item || item->isHidden()) return;
     int count = 0;
     for (int i = 0; i < m_view.format_list->count() && count < 2; i++) {
         if (!m_view.format_list->isRowHidden(i)) count++;
@@ -630,7 +643,7 @@ void RenderWidget::refreshView() {
 
     for (int i = 0; i < m_view.size_list->count(); i++) {
         sizeItem = m_view.size_list->item(i);
-        if (sizeItem->data(GroupRole) == group) {
+        if ((sizeItem->data(GroupRole) == group || sizeItem->data(GroupRole).toString().isEmpty()) && sizeItem->data(MetaGroupRole) == destination) {
             std = sizeItem->data(StandardRole).toString();
             if (!std.isEmpty()) {
                 if (std.contains("PAL", Qt::CaseInsensitive)) sizeItem->setHidden(m_view.format_selection->currentIndex() != 0);
@@ -653,7 +666,10 @@ void RenderWidget::refreshView() {
                         format = format.section(' ', 0, 0).toLower();
                         if (!formatsList.contains(format)) {
                             kDebug() << "*****  UNSUPPORTED F: " << format;
-                            sizeItem->setHidden(true);
+                            //sizeItem->setHidden(true);
+                            sizeItem->setFlags(Qt::NoItemFlags);
+                            sizeItem->setToolTip(i18n("Unsupported video format: %1", format));
+                            sizeItem->setIcon(brokenIcon);
                         }
                     }
                 }
@@ -665,7 +681,10 @@ void RenderWidget::refreshView() {
                         format = format.section(' ', 0, 0).toLower();
                         if (!acodecsList.contains(format)) {
                             kDebug() << "*****  UNSUPPORTED ACODEC: " << format;
-                            sizeItem->setHidden(true);
+                            //sizeItem->setHidden(true);
+                            sizeItem->setFlags(Qt::NoItemFlags);
+                            sizeItem->setToolTip(i18n("Unsupported audio codec: %1", format));
+                            sizeItem->setIcon(brokenIcon);
                         }
                     }
                 }
@@ -677,7 +696,10 @@ void RenderWidget::refreshView() {
                         format = format.section(' ', 0, 0).toLower();
                         if (!vcodecsList.contains(format)) {
                             kDebug() << "*****  UNSUPPORTED VCODEC: " << format;
-                            sizeItem->setHidden(true);
+                            //sizeItem->setHidden(true);
+                            sizeItem->setFlags(Qt::NoItemFlags);
+                            sizeItem->setToolTip(i18n("Unsupported video codec: %1", format));
+                            sizeItem->setIcon(brokenIcon);
                         }
                     }
                 }
@@ -755,6 +777,13 @@ void RenderWidget::parseProfiles(QString group, QString profile) {
     m_view.format_list->clear();
     m_view.destination_list->clear();
     m_view.destination_list->addItem(KIcon("video-x-generic"), i18n("File rendering"));
+    m_view.destination_list->addItem(KIcon("media-optical"), i18n("DVD"), "dvd");
+    m_view.destination_list->addItem(KIcon("audio-x-generic"), i18n("Audio only"), "audioonly");
+    m_view.destination_list->addItem(KIcon("applications-internet"), i18n("Web sites"), "websites");
+    m_view.destination_list->addItem(KIcon("applications-multimedia"), i18n("Media players"), "mediaplayers");
+    m_view.destination_list->addItem(KIcon("drive-harddisk"), i18n("Lossless / HQ"), "lossless");
+    m_view.destination_list->addItem(KIcon("pda"), i18n("Mobile devices"), "mobile");
+
     QString exportFile = KStandardDirs::locate("appdata", "export/profiles.xml");
     parseFile(exportFile, false);
 
@@ -777,29 +806,69 @@ void RenderWidget::parseProfiles(QString group, QString profile) {
 }
 
 void RenderWidget::parseFile(QString exportFile, bool editable) {
+    kDebug() << "// Parsing file: " << exportFile;
+    kDebug() << "------------------------------";
     QDomDocument doc;
     QFile file(exportFile);
     doc.setContent(&file, false);
     file.close();
     QDomElement documentElement;
     QDomElement profileElement;
+    QString extension;
+    QListWidgetItem *item;
     QDomNodeList groups = doc.elementsByTagName("group");
 
     if (groups.count() == 0) {
-        kDebug() << "// Export file: " << exportFile << " IS BROKEN";
+        QDomNode node = doc.elementsByTagName("profile").at(0);
+        if (node.isNull()) {
+            kDebug() << "// Export file: " << exportFile << " IS BROKEN";
+            return;
+        }
+        QDomElement profile = node.toElement();
+        QString profileName = profile.attribute("name");
+        QString standard = profile.attribute("standard");
+        QString params = profile.attribute("args");
+        QString category = profile.attribute("category", i18n("Custom"));
+        QString dest = profile.attribute("destinationid");
+        QString prof_extension = profile.attribute("extension");
+        if (!prof_extension.isEmpty()) extension = prof_extension;
+
+        QList <QListWidgetItem *> list = m_view.format_list->findItems(category, Qt::MatchExactly);
+        bool exists = false;
+        for (int j = 0; j < list.count(); j++) {
+            if (list.at(j)->data(MetaGroupRole) == dest) {
+                exists = true;
+                break;
+            }
+        }
+        if (!exists) {
+            item = new QListWidgetItem(category, m_view.format_list);
+            item->setData(MetaGroupRole, dest);
+        }
+
+        item = new QListWidgetItem(profileName, m_view.size_list);
+        kDebug() << "// ADDINg item with name: " << profileName << ", GRP" << category << ", DEST:" << dest ;
+        item->setData(GroupRole, category);
+        item->setData(MetaGroupRole, dest);
+        item->setData(ExtensionRole, extension);
+        item->setData(RenderRole, "avformat");
+        item->setData(StandardRole, standard);
+        item->setData(ParamsRole, params);
+        if (profile.hasAttribute("url")) item->setData(ExtraRole, profile.attribute("url"));
+        if (editable) item->setData(EditableRole, "true");
         return;
     }
 
     int i = 0;
     QString groupName;
     QString profileName;
-    QString extension;
+
     QString prof_extension;
     QString renderer;
     QString params;
     QString standard;
     KIcon icon;
-    QListWidgetItem *item;
+
     while (!groups.item(i).isNull()) {
         documentElement = groups.item(i).toElement();
         QDomNode gname = documentElement.elementsByTagName("groupname").at(0);
@@ -818,10 +887,18 @@ void RenderWidget::parseFile(QString exportFile, bool editable) {
                 m_view.destination_list->addItem(icon, i18n(metagroupName.toUtf8().data()), metagroupId);
             }
         }
-        groupName = documentElement.attribute("name", QString::null);
+        groupName = documentElement.attribute("name", i18n("Custom"));
         extension = documentElement.attribute("extension", QString::null);
         renderer = documentElement.attribute("renderer", QString::null);
-        if (m_view.format_list->findItems(groupName, Qt::MatchExactly).isEmpty()) {
+        QList <QListWidgetItem *> list = m_view.format_list->findItems(groupName, Qt::MatchExactly);
+        bool exists = false;
+        for (int j = 0; j < list.count(); j++) {
+            if (list.at(j)->data(MetaGroupRole) == metagroupId) {
+                exists = true;
+                break;
+            }
+        }
+        if (!exists) {
             item = new QListWidgetItem(groupName, m_view.format_list);
             item->setData(MetaGroupRole, metagroupId);
         }
index bbf8ef4297961c5f7810b16ebb11c3e85c0c87ad..669573709b1ec47c654e550e59bfa7e69da3dab7 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>346</width>
-    <height>237</height>
+    <width>384</width>
+    <height>245</height>
    </rect>
   </property>
   <property name="windowTitle" >
   </property>
   <layout class="QGridLayout" name="gridLayout" >
    <item row="0" column="0" >
+    <widget class="QLabel" name="label_5" >
+     <property name="text" >
+      <string>Destination</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1" colspan="2" >
+    <widget class="KComboBox" name="destination_list" />
+   </item>
+   <item row="1" column="0" >
     <widget class="QLabel" name="label_2" >
      <property name="text" >
       <string>Group</string>
      </property>
     </widget>
    </item>
-   <item row="0" column="1" colspan="2" >
+   <item row="1" column="1" colspan="2" >
     <widget class="KComboBox" name="group_name" />
    </item>
-   <item row="1" column="0" >
+   <item row="2" column="0" >
     <widget class="QLabel" name="label_3" >
      <property name="text" >
       <string>Profile name</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="1" colspan="2" >
+   <item row="2" column="1" colspan="2" >
     <widget class="KLineEdit" name="profile_name" />
    </item>
-   <item row="2" column="0" >
+   <item row="3" column="0" >
     <widget class="QLabel" name="label_4" >
      <property name="text" >
       <string>Extension</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="1" colspan="2" >
+   <item row="3" column="1" colspan="2" >
     <widget class="KLineEdit" name="extension" >
      <property name="maxLength" >
       <number>4</number>
      </property>
     </widget>
    </item>
-   <item row="3" column="0" colspan="2" >
+   <item row="4" column="0" colspan="2" >
     <widget class="QLabel" name="label" >
      <property name="text" >
       <string>Parameters</string>
      </property>
     </widget>
    </item>
-   <item row="4" column="0" colspan="3" >
+   <item row="5" column="0" colspan="3" >
     <widget class="KTextEdit" name="parameters" >
      <property name="readOnly" >
       <bool>false</bool>
@@ -64,7 +74,7 @@
      </property>
     </widget>
    </item>
-   <item row="5" column="2" >
+   <item row="6" column="2" >
     <spacer name="verticalSpacer" >
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
@@ -77,7 +87,7 @@
      </property>
     </spacer>
    </item>
-   <item row="6" column="0" colspan="3" >
+   <item row="7" column="0" colspan="3" >
     <widget class="QDialogButtonBox" name="buttonBox" >
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>