]> git.sesse.net Git - kdenlive/commitdiff
Update GUI for editing transcoding profiles
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 23 Dec 2011 12:39:22 +0000 (13:39 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 23 Dec 2011 12:39:22 +0000 (13:39 +0100)
src/kdenlivesettingsdialog.cpp
src/kdenlivesettingsdialog.h
src/kdenlivetranscodingrc
src/widgets/configcapture_ui.ui
src/widgets/configtranscode_ui.ui

index e2eaca7c509ef901718e79a5bb25ed1f95559377..7af5147c2edb4e7b09f7ad7263621ab0a18b53a9 100644 (file)
@@ -33,6 +33,7 @@
 #include <kde_file.h>
 #include <KIO/NetAccess>
 #include <kdeversion.h>
+#include <KMessageBox>
 
 #include <QDir>
 #include <QTimer>
@@ -187,7 +188,18 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
     m_page7 = addPage(p7, i18n("Transcode"), "edit-copy");
     connect(m_configTranscode.button_add, SIGNAL(clicked()), this, SLOT(slotAddTranscode()));
     connect(m_configTranscode.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteTranscode()));
-    connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDialogModified()));
+    connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(slotDialogModified()));
+    connect(m_configTranscode.profiles_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotSetTranscodeProfile()));
+    
+    connect(m_configTranscode.profile_name, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate()));
+    connect(m_configTranscode.profile_description, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate()));
+    connect(m_configTranscode.profile_extension, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate()));
+    connect(m_configTranscode.profile_parameters, SIGNAL(textChanged()), this, SLOT(slotEnableTranscodeUpdate()));
+    connect(m_configTranscode.profile_audioonly, SIGNAL(stateChanged(int)), this, SLOT(slotEnableTranscodeUpdate()));
+    
+    connect(m_configTranscode.button_update, SIGNAL(pressed()), this, SLOT(slotUpdateTranscodingProfile()));
+    
+    m_configTranscode.profile_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
 
     connect(m_configCapture.kcfg_rmd_capture_audio, SIGNAL(clicked(bool)), m_configCapture.audio_group, SLOT(setVisible(bool)));
 
@@ -748,14 +760,20 @@ void KdenliveSettingsDialog::loadTranscodeProfiles()
     KConfigGroup transConfig(config, "Transcoding");
     // read the entries
     m_configTranscode.profiles_list->blockSignals(true);
+    m_configTranscode.profiles_list->clear();
     QMap< QString, QString > profiles = transConfig.entryMap();
     QMapIterator<QString, QString> i(profiles);
     while (i.hasNext()) {
         i.next();
-        QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i.key() << i.value());
-        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+        QListWidgetItem *item = new QListWidgetItem(i.key());
+        QString data = i.value();
+        if (data.contains(';')) item->setToolTip(data.section(';', 1, 1));
+        item->setData(Qt::UserRole, data);
+        m_configTranscode.profiles_list->addItem(item);
+        //item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
     }
     m_configTranscode.profiles_list->blockSignals(false);
+    m_configTranscode.profiles_list->setCurrentRow(0);
 }
 
 void KdenliveSettingsDialog::saveTranscodeProfiles()
@@ -765,31 +783,90 @@ void KdenliveSettingsDialog::saveTranscodeProfiles()
     KConfigGroup transConfig(config, "Transcoding");
     // read the entries
     transConfig.deleteGroup();
-    int max = m_configTranscode.profiles_list->topLevelItemCount();
+    int max = m_configTranscode.profiles_list->count();
     for (int i = 0; i < max; i++) {
-        QTreeWidgetItem *item = m_configTranscode.profiles_list->topLevelItem(i);
-        transConfig.writeEntry(item->text(0), item->text(1));
+        QListWidgetItem *item = m_configTranscode.profiles_list->item(i);
+        transConfig.writeEntry(item->text(), item->data(Qt::UserRole).toString());
     }
     config->sync();
 }
 
 void KdenliveSettingsDialog::slotAddTranscode()
 {
-    QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i18n("Name") << i18n("Parameters"));
-    item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+    if (!m_configTranscode.profiles_list->findItems(m_configTranscode.profile_name->text(), Qt::MatchExactly).isEmpty()) {
+        KMessageBox::sorry(this, i18n("A profile with that name already exists"));
+        return;
+    }
+    QListWidgetItem *item = new QListWidgetItem(m_configTranscode.profile_name->text());
+    QString data = m_configTranscode.profile_parameters->toPlainText();
+    data.append(" %1." + m_configTranscode.profile_extension->text());
+    data.append(";");
+    if (!m_configTranscode.profile_description->text().isEmpty()) 
+        data.append(m_configTranscode.profile_description->text());
+    if (m_configTranscode.profile_audioonly->isChecked()) data.append(";audio");
+    item->setData(Qt::UserRole, data);
+    m_configTranscode.profiles_list->addItem(item);
     m_configTranscode.profiles_list->setCurrentItem(item);
-    m_configTranscode.profiles_list->editItem(item);
+    slotDialogModified();
+}
+
+void KdenliveSettingsDialog::slotUpdateTranscodingProfile()
+{
+    QListWidgetItem *item = m_configTranscode.profiles_list->currentItem();
+    if (!item) return;
+    m_configTranscode.button_update->setEnabled(false);
+    item->setText(m_configTranscode.profile_name->text());
+    QString data = m_configTranscode.profile_parameters->toPlainText();
+    data.append(" %1." + m_configTranscode.profile_extension->text());
+    data.append(";");
+    if (!m_configTranscode.profile_description->text().isEmpty())
+        data.append(m_configTranscode.profile_description->text());
+    if (m_configTranscode.profile_audioonly->isChecked()) data.append(";audio");
+    item->setData(Qt::UserRole, data);
     slotDialogModified();
 }
 
 void KdenliveSettingsDialog::slotDeleteTranscode()
 {
-    QTreeWidgetItem *item = m_configTranscode.profiles_list->currentItem();
+    QListWidgetItem *item = m_configTranscode.profiles_list->currentItem();
     if (item == NULL) return;
     delete item;
     slotDialogModified();
 }
 
+void KdenliveSettingsDialog::slotEnableTranscodeUpdate()
+{
+    if (!m_configTranscode.profile_box->isEnabled()) return;
+    bool allow = true;
+    if (m_configTranscode.profile_name->text().isEmpty() || m_configTranscode.profile_extension->text().isEmpty()) allow = false;
+    m_configTranscode.button_update->setEnabled(allow);
+}
+
+void KdenliveSettingsDialog::slotSetTranscodeProfile()
+{
+    m_configTranscode.profile_box->setEnabled(false);
+    m_configTranscode.button_update->setEnabled(false);
+    m_configTranscode.profile_name->clear();
+    m_configTranscode.profile_description->clear();
+    m_configTranscode.profile_extension->clear();
+    m_configTranscode.profile_parameters->clear();
+    m_configTranscode.profile_audioonly->setChecked(false);
+    QListWidgetItem *item = m_configTranscode.profiles_list->currentItem();
+    if (!item) {
+        return;
+    }
+    m_configTranscode.profile_name->setText(item->text());
+    QString data = item->data(Qt::UserRole).toString();
+    if (data.contains(';')) {
+        m_configTranscode.profile_description->setText(data.section(';', 1, 1));
+        if (data.section(';', 2, 2) == "audio") m_configTranscode.profile_audioonly->setChecked(true);
+        data = data.section(';', 0, 0).simplified();
+    }
+    m_configTranscode.profile_extension->setText(data.section('.', -1));
+    m_configTranscode.profile_parameters->setPlainText(data.section(' ', 0, -2));
+    m_configTranscode.profile_box->setEnabled(true);
+}
+
 void KdenliveSettingsDialog::slotShuttleModified()
 {
 #ifdef USE_JOGSHUTTLE
@@ -1018,6 +1095,7 @@ void KdenliveSettingsDialog::slotEditVideo4LinuxProfile()
     delete w;
 }
 
+
 #include "kdenlivesettingsdialog.moc"
 
 
index 8c01c3fbb915f710a29cef91e29d928bb753c9c1..d1e99ca70d8551ccb022a0f9d7fc1a71f669579d 100644 (file)
@@ -65,6 +65,12 @@ private slots:
     void slotCheckAlsaDriver();
     void slotAddTranscode();
     void slotDeleteTranscode();
+    /** @brief Update current transcoding profile. */
+    void slotUpdateTranscodingProfile();
+    /** @brief Enable / disable the update profile button. */
+    void slotEnableTranscodeUpdate();
+    /** @brief Update display of current transcoding profile parameters. */
+    void slotSetTranscodeProfile();
     void slotShuttleModified();
     void slotDialogModified();
     void slotEnableCaptureFolder();
index 06e2cb90d4e46ac33aee96f3815d85f0f18f2a71..018db4c6913068de9637a6e1854461fb217c2cdf 100644 (file)
@@ -13,9 +13,9 @@ DNxHD 720p 50 fps 175 Mb/s=-s 1280x720 -r 50 -vb 175000k -threads 2 -vcodec dnxh
 DNxHD 720p 50 fps 115 Mb/s=-s 1280x720 -r 50 -vb 175000k -threads 2 -vcodec dnxhd -acodec copy %1.mov;High quality encoding
 DNxHD 720p 59.94 fps 220 Mb/s=-s 1280x720 -r 60000/1001 -vb 220000k -threads 2 -vcodec dnxhd -acodec copy %1.mov;High quality encoding
 DNxHD 720p 59.94 fps 145 Mb/s=-s 1280x720 -r 60000/1001 -vb 145000k -threads 2 -vcodec dnxhd -acodec copy %1.mov;High quality encoding
-Fix MPEG-1=-sameq -acodec copy -vcodec mpeg1video %1.mpg;Fix unplayable MPEG-1 files;vcodec=mpeg1video
-Fix Ogg Theora=-sameq -vcodec libtheora -acodec copy %1.ogv;Fix unplayable OGG Theora files;vcodec=theora
-Remux MPEG-2 PS/VOB=-vcodec copy -acodec copy %1.mpg;Fix audio sync in MPEG-2 vob files;vcodec=mpeg2video
+Fix MPEG-1=-sameq -acodec copy -vcodec mpeg1video %1.mpg;Fix unplayable MPEG-1 files
+Fix Ogg Theora=-sameq -vcodec libtheora -acodec copy %1.ogv;Fix unplayable OGG Theora files
+Remux MPEG-2 PS/VOB=-vcodec copy -acodec copy %1.mpg;Fix audio sync in MPEG-2 vob files
 Lossless Matroska=-sn -vcodec huffyuv -acodec flac %1.mkv;High quality lossless encoding
-Wav 48000Hz=-vn -ar 48000 %1.wav;Extract audio as WAV file
+Wav 48000Hz=-vn -ar 48000 %1.wav;Extract audio as WAV file;audio
 Remux with MKV=-vcodec copy -acodec copy -sn %1.mkv
index 4867d3ca5c038d467076cbf47c64e2bbb5c29cf3..08652d62d90d70a64798c8ec407b5d535c3a6eff 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>405</width>
-    <height>595</height>
+    <height>479</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout_8">
        </item>
        <item row="20" column="0" colspan="8">
         <widget class="QPlainTextEdit" name="v4l_parameters">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
          <property name="readOnly">
           <bool>true</bool>
          </property>
index 7b900cac1db4f0ffd71a8b8d7405b7f0f9fbd87d..35a06ac8b4ce55f4e15e249ad4bce924fd954e59 100644 (file)
@@ -6,55 +6,40 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>366</width>
-    <height>183</height>
+    <width>319</width>
+    <height>306</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <property name="leftMargin">
-    <number>0</number>
-   </property>
-   <property name="topMargin">
-    <number>0</number>
-   </property>
-   <item row="0" column="0" colspan="3">
-    <widget class="QTreeWidget" name="profiles_list">
+   <item row="0" column="0" colspan="4">
+    <widget class="QListWidget" name="profiles_list">
      <property name="alternatingRowColors">
       <bool>true</bool>
      </property>
-     <property name="rootIsDecorated">
-      <bool>false</bool>
-     </property>
-     <property name="allColumnsShowFocus">
-      <bool>true</bool>
-     </property>
-     <column>
-      <property name="text">
-       <string>Name</string>
-      </property>
-     </column>
-     <column>
-      <property name="text">
-       <string>FFmpeg parameters</string>
-      </property>
-     </column>
     </widget>
    </item>
-   <item row="1" column="0">
+   <item row="2" column="0">
     <widget class="QPushButton" name="button_add">
      <property name="text">
       <string>Add Profile</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="1">
+   <item row="2" column="1">
+    <widget class="QPushButton" name="button_update">
+     <property name="text">
+      <string>Update Profile</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="2">
     <widget class="QPushButton" name="button_delete">
      <property name="text">
       <string>Delete Profile</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="2">
+   <item row="2" column="3">
     <spacer name="horizontalSpacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </spacer>
    </item>
+   <item row="1" column="0" colspan="4">
+    <widget class="QGroupBox" name="profile_box">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title">
+      <string/>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_2">
+      <item row="0" column="0">
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>Name</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" colspan="2">
+       <widget class="QLineEdit" name="profile_name"/>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>Description</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" colspan="2">
+       <widget class="QLineEdit" name="profile_description"/>
+      </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>Extension</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QLineEdit" name="profile_extension"/>
+      </item>
+      <item row="2" column="2">
+       <widget class="QCheckBox" name="profile_audioonly">
+        <property name="text">
+         <string>Audio only</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0" colspan="3">
+       <widget class="QLabel" name="label_4">
+        <property name="text">
+         <string>Parameters</string>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="0" colspan="3">
+       <widget class="QPlainTextEdit" name="profile_parameters"/>
+      </item>
+     </layout>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>