]> git.sesse.net Git - kdenlive/commitdiff
Add "Favorites" category to rendering profiles for easier management
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 12 Dec 2009 19:24:42 +0000 (19:24 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 12 Dec 2009 19:24:42 +0000 (19:24 +0000)
svn path=/trunk/kdenlive/; revision=4179

src/renderwidget.cpp
src/renderwidget.h
src/widgets/renderwidget_ui.ui

index 100af3434a20a47f8c06655dd20f7543fcf7749c..84411b71ee8ae4558ddc63638ef841c1a86f336c 100644 (file)
@@ -81,6 +81,9 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     m_view.buttonInfo->setIcon(KIcon("help-about"));
     m_view.hide_log->setIcon(KIcon("go-down"));
 
+    m_view.buttonFavorite->setIcon(KIcon("favorites"));
+    m_view.buttonFavorite->setToolTip(i18n("Copy profile to favorites"));
+    
     if (KdenliveSettings::showrenderparams()) {
         m_view.buttonInfo->setDown(true);
     } else m_view.advanced_params->hide();
@@ -120,6 +123,8 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     connect(m_view.buttonSave, SIGNAL(clicked()), this, SLOT(slotSaveProfile()));
     connect(m_view.buttonEdit, SIGNAL(clicked()), this, SLOT(slotEditProfile()));
     connect(m_view.buttonDelete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile()));
+    connect(m_view.buttonFavorite, SIGNAL(clicked()), this, SLOT(slotCopyToFavorites()));
+
     connect(m_view.abort_job, SIGNAL(clicked()), this, SLOT(slotAbortCurrentJob()));
     connect(m_view.start_job, SIGNAL(clicked()), this, SLOT(slotStartCurrentJob()));
     connect(m_view.clean_up, SIGNAL(clicked()), this, SLOT(slotCLeanUpJobs()));
@@ -338,7 +343,30 @@ void RenderWidget::slotSaveProfile()
     ui.profile_name->setFocus();
 
     if (d->exec() == QDialog::Accepted && !ui.profile_name->text().simplified().isEmpty()) {
-        QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
+        QString newProfileName = ui.profile_name->text().simplified();
+        QString newGroupName = ui.group_name->text().simplified();
+        if (newGroupName.isEmpty()) newGroupName = i18n("Custom");
+        QString newMetaGroupId = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
+       
+       QDomDocument doc;
+        QDomElement profileElement = doc.createElement("profile");
+        profileElement.setAttribute("name", newProfileName);
+        profileElement.setAttribute("category", newGroupName);
+        profileElement.setAttribute("destinationid", newMetaGroupId);
+        profileElement.setAttribute("extension", ui.extension->text().simplified());
+        profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
+       doc.appendChild(profileElement);
+       saveProfile(doc.documentElement());
+        
+        parseProfiles(newMetaGroupId, newGroupName, newProfileName);
+    }
+    delete d;
+}
+
+
+void RenderWidget::saveProfile(QDomElement newprofile)
+{
+  QString exportFile = KStandardDirs::locateLocal("appdata", "export/customprofiles.xml");
         QDomDocument doc;
         QFile file(exportFile);
         doc.setContent(&file, false);
@@ -360,20 +388,17 @@ void RenderWidget::slotSaveProfile()
             doc.appendChild(profiles);
         }
 
-        QString newProfileName = ui.profile_name->text().simplified();
-        QString newGroupName = ui.group_name->text().simplified();
-        if (newGroupName.isEmpty()) newGroupName = i18n("Custom");
-        QString newMetaGroupId = ui.destination_list->itemData(ui.destination_list->currentIndex(), Qt::UserRole).toString();
+
         QDomNodeList profilelist = doc.elementsByTagName("profile");
         int i = 0;
         while (!profilelist.item(i).isNull()) {
             // make sure a profile with same name doesn't exist
             documentElement = profilelist.item(i).toElement();
             QString profileName = documentElement.attribute("name");
-            if (profileName == newProfileName) {
+            if (profileName == newprofile.attribute("name")) {
                 // a profile with that same name already exists
                 bool ok;
-                newProfileName = QInputDialog::getText(this, i18n("Profile already exists"), i18n("This profile name already exists. Change the name if you don't want to overwrite it."), QLineEdit::Normal, newProfileName, &ok);
+                QString newProfileName = QInputDialog::getText(this, i18n("Profile already exists"), i18n("This profile name already exists. Change the name if you don't want to overwrite it."), QLineEdit::Normal, profileName, &ok);
                 if (!ok) return;
                 if (profileName == newProfileName) {
                     profiles.removeChild(profilelist.item(i));
@@ -383,19 +408,12 @@ void RenderWidget::slotSaveProfile()
             i++;
         }
 
-        QDomElement profileElement = doc.createElement("profile");
-        profileElement.setAttribute("name", newProfileName);
-        profileElement.setAttribute("category", newGroupName);
-        profileElement.setAttribute("destinationid", newMetaGroupId);
-        profileElement.setAttribute("extension", ui.extension->text().simplified());
-        profileElement.setAttribute("args", ui.parameters->toPlainText().simplified());
-        profiles.appendChild(profileElement);
+        profiles.appendChild(newprofile);
 
         //QCString save = doc.toString().utf8();
 
         if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
             KMessageBox::sorry(this, i18n("Unable to write to file %1", exportFile));
-            delete d;
             return;
         }
         QTextStream out(&file);
@@ -403,13 +421,30 @@ void RenderWidget::slotSaveProfile()
         if (file.error() != QFile::NoError) {
             KMessageBox::error(this, i18n("Cannot write to file %1", exportFile));
             file.close();
-            delete d;
             return;
         }
         file.close();
-        parseProfiles(newMetaGroupId, newGroupName, newProfileName);
-    }
-    delete d;
+}
+
+void RenderWidget::slotCopyToFavorites()
+{
+    QListWidgetItem *item = m_view.size_list->currentItem();
+    if (!item) return;
+    QString currentGroup = m_view.format_list->currentItem()->text();
+
+    QString params = item->data(ParamsRole).toString();
+    QString extension = item->data(ExtensionRole).toString();
+    QString currentProfile = item->text();
+    QDomDocument doc;
+    QDomElement profileElement = doc.createElement("profile");
+    profileElement.setAttribute("name", currentProfile);
+    profileElement.setAttribute("category", i18n("Custom"));
+    profileElement.setAttribute("destinationid", "favorites");
+    profileElement.setAttribute("extension", extension);
+    profileElement.setAttribute("args", params);
+    doc.appendChild(profileElement);
+    saveProfile(doc.documentElement());
+    parseProfiles(m_view.destination_list->itemData(m_view.destination_list->currentIndex(), Qt::UserRole).toString(), currentGroup, currentProfile);
 }
 
 void RenderWidget::slotEditProfile()
@@ -1114,6 +1149,7 @@ void RenderWidget::parseProfiles(QString meta, 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("favorites"), i18n("Favorites"), "favorites");
     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");
index 3c5f9775f0d4d5b812a1aa87f8202263ceab90c6..b2f5f01aaf8aec446e72aa34fd780f2434bdfe2c 100644 (file)
@@ -141,7 +141,8 @@ private slots:
     void slotPrepareExport(bool scriptExport = false);
     void slotPlayRendering(QTreeWidgetItem *item, int);
     void slotStartCurrentJob();
-
+    void slotCopyToFavorites();
+    
 private:
     Ui::RenderWidget_UI m_view;
     MltVideoProfile m_profile;
@@ -156,6 +157,7 @@ private:
     KUrl filenameWithExtension(KUrl url, QString extension);
     void checkRenderStatus();
     void startRendering(QTreeWidgetItem *item);
+    void saveProfile(QDomElement newprofile);
 
 signals:
     void abortProcess(const QString &url);
index d0bb1443bba40aa390f3d963d1e945b5a8970e3f..859178c43d88a15a1094c2dc4288ba17b1925a9c 100644 (file)
@@ -34,7 +34,7 @@
          </property>
         </widget>
        </item>
-       <item row="0" column="2" colspan="7">
+       <item row="0" column="2" colspan="9">
         <widget class="KComboBox" name="destination_list"/>
        </item>
        <item row="1" column="0" colspan="2">
@@ -44,7 +44,7 @@
          </property>
         </widget>
        </item>
-       <item row="1" column="2" colspan="7">
+       <item row="1" column="2" colspan="9">
         <widget class="KUrlRequester" name="out_file"/>
        </item>
        <item row="2" column="0">
          </property>
         </widget>
        </item>
-       <item row="2" column="2" colspan="2">
-        <spacer name="horizontalSpacer_2">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>124</width>
-           <height>23</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item row="2" column="4" colspan="2">
+       <item row="2" column="2" colspan="4">
         <widget class="KComboBox" name="format_selection">
          <item>
           <property name="text">
          </item>
         </widget>
        </item>
-       <item row="2" column="6">
+       <item row="2" column="8">
         <widget class="QToolButton" name="buttonEdit">
          <property name="text">
           <string>E</string>
          </property>
         </widget>
        </item>
-       <item row="2" column="7">
+       <item row="2" column="9">
         <widget class="QToolButton" name="buttonSave">
          <property name="text">
           <string>S</string>
          </property>
         </widget>
        </item>
-       <item row="2" column="8">
+       <item row="2" column="10">
         <widget class="QToolButton" name="buttonDelete">
          <property name="text">
           <string>D</string>
          </property>
         </widget>
        </item>
-       <item row="3" column="0" colspan="9">
+       <item row="3" column="0" colspan="11">
         <widget class="QSplitter" name="splitter_3">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </item>
         </widget>
        </item>
-       <item row="4" column="5" colspan="4">
+       <item row="4" column="5" colspan="6">
         <widget class="QCheckBox" name="export_audio">
          <property name="text">
           <string>Export audio</string>
          </property>
         </widget>
        </item>
-       <item row="5" column="5" colspan="4">
+       <item row="5" column="5" colspan="6">
         <widget class="QCheckBox" name="tc_overlay">
          <property name="text">
           <string>Timecode overlay</string>
          </property>
         </widget>
        </item>
-       <item row="9" column="0" colspan="9">
+       <item row="9" column="0" colspan="11">
         <widget class="QCheckBox" name="open_browser">
          <property name="text">
           <string>Open browser window after export</string>
          </property>
         </widget>
        </item>
-       <item row="10" column="0" colspan="9">
+       <item row="10" column="0" colspan="11">
         <widget class="QCheckBox" name="play_after">
          <property name="text">
           <string>Play after render</string>
          </property>
         </widget>
        </item>
-       <item row="11" column="0" colspan="9">
+       <item row="11" column="0" colspan="11">
         <layout class="QHBoxLayout" name="horizontalLayout">
          <item>
           <widget class="QRadioButton" name="render_full">
          </item>
         </layout>
        </item>
-       <item row="12" column="0" colspan="9">
+       <item row="12" column="0" colspan="11">
         <widget class="QGroupBox" name="guides_box">
          <property name="title">
           <string/>
          </property>
         </widget>
        </item>
-       <item row="13" column="3" colspan="4">
+       <item row="13" column="3" colspan="6">
         <spacer name="horizontalSpacer">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
         </spacer>
        </item>
-       <item row="13" column="7" colspan="2">
+       <item row="13" column="9" colspan="2">
         <widget class="KPushButton" name="buttonClose">
          <property name="text">
           <string>Close</string>
          </property>
         </widget>
        </item>
-       <item row="6" column="0" colspan="9">
+       <item row="6" column="0" colspan="11">
         <widget class="QCheckBox" name="open_dvd">
          <property name="text">
           <string>Open Dvd wizard after rendering</string>
          </property>
         </widget>
        </item>
-       <item row="7" column="0" colspan="9">
+       <item row="7" column="0" colspan="11">
         <widget class="QCheckBox" name="create_chapter">
          <property name="text">
           <string>Create chapter file based on guides</string>
          </property>
         </widget>
        </item>
+       <item row="2" column="7">
+        <widget class="QToolButton" name="buttonFavorite">
+         <property name="text">
+          <string>...</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="6">
+        <spacer name="horizontalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>124</width>
+           <height>23</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="tab_2">