]> git.sesse.net Git - kdenlive/commitdiff
Use the new profile selection combobox for project proxy settings
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 7 Jun 2011 08:30:32 +0000 (08:30 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 7 Jun 2011 08:30:32 +0000 (08:30 +0000)
svn path=/trunk/kdenlive/; revision=5675

src/projectsettings.cpp
src/projectsettings.h
src/widgets/projectsettings_ui.ui

index d6762537ec43cfa74e62754371eaf37b564927af..41deae0fc5c6976c2d68c703e42a3178a854d220 100644 (file)
@@ -65,32 +65,67 @@ ProjectSettings::ProjectSettings(ProjectList *projectlist, QStringList lumas, in
     video_thumbs->setChecked(KdenliveSettings::videothumbnails());
     audio_tracks->setValue(audiotracks);
     video_tracks->setValue(videotracks);
-    proxy_params->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
     connect(generate_proxy, SIGNAL(toggled(bool)), proxy_minsize, SLOT(setEnabled(bool)));
     connect(generate_imageproxy, SIGNAL(toggled(bool)), proxy_imageminsize, SLOT(setEnabled(bool)));
-    
+    QString proxyparameters;
+    QString proxyextension;
     if (projectlist) {
         enable_proxy->setChecked(projectlist->getDocumentProperty("enableproxy").toInt());
         generate_proxy->setChecked(projectlist->getDocumentProperty("generateproxy").toInt());
         proxy_minsize->setValue(projectlist->getDocumentProperty("proxyminsize").toInt());
-        proxy_params->setPlainText(projectlist->getDocumentProperty("proxyparams"));
+        proxyparameters = projectlist->getDocumentProperty("proxyparams");
         generate_imageproxy->setChecked(projectlist->getDocumentProperty("generateimageproxy").toInt());
         proxy_imageminsize->setValue(projectlist->getDocumentProperty("proxyimageminsize").toInt());
-        proxy_extension->setText(projectlist->getDocumentProperty("proxyextension"));
+        proxyextension = projectlist->getDocumentProperty("proxyextension");
     }
     else {
         enable_proxy->setChecked(KdenliveSettings::enableproxy());
         generate_proxy->setChecked(KdenliveSettings::generateproxy());
         proxy_minsize->setValue(KdenliveSettings::proxyminsize());
-        proxy_params->setPlainText(KdenliveSettings::proxyparams());
+        proxyparameters = KdenliveSettings::proxyparams();
         generate_imageproxy->setChecked(KdenliveSettings::generateimageproxy());
         proxy_imageminsize->setValue(KdenliveSettings::proxyimageminsize());
-        proxy_extension->setText(KdenliveSettings::proxyextension());
+        proxyextension = KdenliveSettings::proxyextension();
       
     }
 
     proxy_minsize->setEnabled(generate_proxy->isChecked());
     proxy_imageminsize->setEnabled(generate_imageproxy->isChecked());
+
+
+    // load proxy profiles
+    QString profileFile = KStandardDirs::locateLocal("appdata", "encodingprofiles.rc");
+    KConfig conf(profileFile, KConfig::SimpleConfig);
+    KConfigGroup group(&conf, "proxy");
+    QMap <QString, QString> values = group.entryMap();
+    QMapIterator<QString, QString> k(values);
+    int ix = -1;
+    while (k.hasNext()) {
+        k.next();
+        if (!k.key().isEmpty()) {
+            QString params = k.value().section(';', 0, 0);
+            QString extension = k.value().section(';', 1, 1);
+            if (params == proxyparameters && extension == proxyextension) {
+                // this is the current profile
+                ix = proxy_profile->count();
+            }
+            proxy_profile->addItem(k.key(), k.value());
+        }
+    }
+    if (ix == -1) {
+        // Current project proxy settings not found
+        ix = proxy_profile->count();
+        proxy_profile->addItem(i18n("Current Settings"), QString(proxyparameters + ';' + proxyextension));
+    }
+    proxy_profile->setCurrentIndex(ix);
+    slotUpdateProxyParams();
+
+    // Proxy GUI stuff
+    proxy_showprofileinfo->setIcon(KIcon("help-about"));
+    connect(proxy_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateProxyParams()));
+    proxyparams->setVisible(false);
+    proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
+    connect(proxy_showprofileinfo, SIGNAL(clicked(bool)), proxyparams, SLOT(setVisible(bool)));
     
     if (readOnlyTracks) {
         video_tracks->setEnabled(false);
@@ -372,12 +407,14 @@ int ProjectSettings::proxyImageMinSize() const
 
 QString ProjectSettings::proxyParams() const
 {
-    return proxy_params->toPlainText();
+    QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
+    return params.section(';', 0, 0);
 }
 
 QString ProjectSettings::proxyExtension() const
 {
-    return proxy_extension->text();
+    QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
+    return params.section(';', 1, 1);
 }
 
 //static
@@ -493,7 +530,11 @@ void ProjectSettings::slotExportToText()
     KIO::NetAccess::upload(tmpfile.fileName(), savePath, 0);
 }
 
-
+void ProjectSettings::slotUpdateProxyParams()
+{
+    QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
+    proxyparams->setPlainText(params.section(';', 0, 0));
+}
 
 #include "projectsettings.moc"
 
index 1209fb9cf496a2a295fb68b4103a4aaa772ce8f8..dec739bcfe8f8e34434543dab6fb64ab18693052 100644 (file)
@@ -47,6 +47,8 @@ public:
     QString proxyExtension() const;
     static QStringList extractPlaylistUrls(QString path);
     static QStringList extractSlideshowUrls(KUrl url);
+    /** @brief Update the displayed proxy parameters when user changes selection. */
+    void slotUpdateProxyParams();
 
 public slots:
     virtual void accept();
index 73d200a862ced1ff24ec200fd9885891adedd0a9..a565118c2700ce15c47c52b026a90778ee35d924 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>337</width>
-    <height>527</height>
+    <width>332</width>
+    <height>529</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -32,7 +32,7 @@
       <enum>QFrame::Raised</enum>
      </property>
      <layout class="QGridLayout" name="gridLayout_5">
-      <item row="0" column="0">
+      <item row="1" column="0">
        <widget class="QDialogButtonBox" name="buttonBox">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
         </property>
        </widget>
       </item>
+      <item row="0" column="0">
+       <spacer name="verticalSpacer">
+        <property name="orientation">
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>20</width>
+          <height>40</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
      </layout>
     </widget>
    </item>
           <bool>false</bool>
          </property>
          <layout class="QGridLayout" name="gridLayout_2">
-          <item row="0" column="0">
+          <item row="0" column="0" colspan="2">
            <widget class="QCheckBox" name="generate_proxy">
             <property name="text">
              <string>Generate for videos larger than</string>
             </property>
            </widget>
           </item>
-          <item row="0" column="1">
+          <item row="0" column="2" colspan="3">
            <widget class="KIntSpinBox" name="proxy_minsize">
             <property name="suffix">
              <string>pixels</string>
             </property>
            </widget>
           </item>
-          <item row="1" column="0">
+          <item row="1" column="0" colspan="2">
            <widget class="QCheckBox" name="generate_imageproxy">
             <property name="text">
              <string>Generate for images larger than</string>
             </property>
            </widget>
           </item>
-          <item row="1" column="1">
+          <item row="1" column="2" colspan="3">
            <widget class="KIntSpinBox" name="proxy_imageminsize">
             <property name="suffix">
              <string>pixels</string>
             </property>
            </widget>
           </item>
-          <item row="2" column="0" colspan="2">
-           <widget class="QLabel" name="label_16">
+          <item row="2" column="0">
+           <widget class="QLabel" name="label_24">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="text">
-             <string>FFmpeg video transcoding parameters</string>
+             <string>Encoding profile</string>
             </property>
            </widget>
           </item>
-          <item row="3" column="0" colspan="2">
-           <widget class="QPlainTextEdit" name="proxy_params"/>
+          <item row="2" column="1" colspan="3">
+           <widget class="KComboBox" name="proxy_profile">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+           </widget>
           </item>
-          <item row="4" column="0">
-           <widget class="QLabel" name="label_17">
-            <property name="text">
-             <string>File extension</string>
+          <item row="3" column="0" colspan="5">
+           <widget class="QPlainTextEdit" name="proxyparams">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="readOnly">
+             <bool>true</bool>
             </property>
            </widget>
           </item>
-          <item row="4" column="1">
-           <widget class="KLineEdit" name="proxy_extension">
+          <item row="2" column="4">
+           <widget class="QToolButton" name="proxy_showprofileinfo">
             <property name="text">
-             <string>avi</string>
+             <string>...</string>
+            </property>
+            <property name="checkable">
+             <bool>true</bool>
             </property>
            </widget>
           </item>