]> git.sesse.net Git - kdenlive/commitdiff
Remember default profile in config wizard:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Jun 2009 20:10:59 +0000 (20:10 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Jun 2009 20:10:59 +0000 (20:10 +0000)
http://www.kdenlive.org:80/mantis/view.php?id=876

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

src/widgets/wizardstandard_ui.ui
src/wizard.cpp
src/wizard.h

index 09999d04e3345af40baf4654b985422c70ceb75d..b38543c6c91d55d2a2687167b3125b5569982db6 100644 (file)
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>WizardStandard_UI</class>
  <class>WizardStandard_UI</class>
- <widget class="QWidget" name="WizardStandard_UI" >
-  <property name="geometry" >
+ <widget class="QWidget" name="WizardStandard_UI">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
    <rect>
     <x>0</x>
     <y>0</y>
     <height>188</height>
    </rect>
   </property>
     <height>188</height>
    </rect>
   </property>
-  <layout class="QGridLayout" name="gridLayout_2" >
-   <item row="0" column="0" colspan="6" >
-    <widget class="QLabel" name="label_3" >
-     <property name="text" >
+  <layout class="QGridLayout" name="gridLayout_2">
+   <item row="0" column="0" colspan="6">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
       <string>Please set your default video profile</string>
      </property>
     </widget>
    </item>
       <string>Please set your default video profile</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <widget class="QLabel" name="label_2" >
-     <property name="text" >
+   <item row="1" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
       <string>Video Resolution</string>
      </property>
     </widget>
    </item>
       <string>Video Resolution</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="1" >
-    <spacer name="horizontalSpacer_2" >
-     <property name="orientation" >
+   <item row="1" column="1">
+    <spacer name="horizontalSpacer_2">
+     <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>1</width>
        <height>20</height>
       <size>
        <width>1</width>
        <height>20</height>
      </property>
     </spacer>
    </item>
      </property>
     </spacer>
    </item>
-   <item row="1" column="2" colspan="2" >
-    <widget class="QRadioButton" name="button_dv" >
-     <property name="text" >
+   <item row="1" column="2" colspan="2">
+    <widget class="QRadioButton" name="button_dv">
+     <property name="text">
       <string>DV</string>
      </property>
       <string>DV</string>
      </property>
-     <property name="checked" >
+     <property name="checked">
       <bool>true</bool>
      </property>
     </widget>
    </item>
       <bool>true</bool>
      </property>
     </widget>
    </item>
-   <item row="1" column="4" >
-    <widget class="QRadioButton" name="button_hdv" >
-     <property name="text" >
+   <item row="1" column="4">
+    <widget class="QRadioButton" name="button_hdv">
+     <property name="text">
       <string>HDV</string>
      </property>
     </widget>
    </item>
       <string>HDV</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="5" >
-    <widget class="QRadioButton" name="button_all" >
-     <property name="text" >
+   <item row="1" column="5">
+    <widget class="QRadioButton" name="button_all">
+     <property name="text">
       <string>Show All</string>
      </property>
     </widget>
    </item>
       <string>Show All</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="0" colspan="6" >
-    <widget class="QListWidget" name="profiles_list" >
-     <property name="sizePolicy" >
-      <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
+   <item row="2" column="0" colspan="6">
+    <widget class="QListWidget" name="profiles_list">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
-     <property name="alternatingRowColors" >
+     <property name="alternatingRowColors">
+      <bool>true</bool>
+     </property>
+     <property name="sortingEnabled">
       <bool>true</bool>
      </property>
     </widget>
       <bool>true</bool>
      </property>
     </widget>
index 507c412df0cb1f3b08234ac233e980854a322928..9e10697350b999dbffbb5ecccbddf4ed948d363f 100644 (file)
@@ -67,25 +67,40 @@ Wizard::Wizard(bool upgrade, QWidget *parent) :
     m_badIcon = KIcon("dialog-close");
 
     // build profiles lists
     m_badIcon = KIcon("dialog-close");
 
     // build profiles lists
-    m_profilesInfo = ProfilesDialog::getProfilesInfo();
-    QMap<QString, QString>::const_iterator i = m_profilesInfo.constBegin();
-    while (i != m_profilesInfo.constEnd()) {
+    QMap<QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
+    QMap<QString, QString>::const_iterator i = profilesInfo.constBegin();
+    while (i != profilesInfo.constEnd()) {
         QMap< QString, QString > profileData = ProfilesDialog::getSettingsFromFile(i.value());
         QMap< QString, QString > profileData = ProfilesDialog::getSettingsFromFile(i.value());
-        if (profileData.value("width") == "720") m_dvProfiles.append(i.key());
-        else if (profileData.value("width").toInt() >= 1080) m_hdvProfiles.append(i.key());
-        else m_otherProfiles.append(i.key());
+        if (profileData.value("width") == "720") m_dvProfiles.insert(i.key(), i.value());
+        else if (profileData.value("width").toInt() >= 1080) m_hdvProfiles.insert(i.key(), i.value());
+        else m_otherProfiles.insert(i.key(), i.value());
         ++i;
     }
 
         ++i;
     }
 
+    m_standard.button_all->setChecked(true);
     connect(m_standard.button_all, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
     connect(m_standard.button_hdv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
     connect(m_standard.button_dv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
     connect(m_standard.button_all, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
     connect(m_standard.button_hdv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
     connect(m_standard.button_dv, SIGNAL(toggled(bool)), this, SLOT(slotCheckStandard()));
-    m_standard.button_all->setChecked(true);
+    slotCheckStandard();
     connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
 
     connect(m_standard.profiles_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckSelectedItem()));
 
+
+    if (!KdenliveSettings::default_profile().isEmpty()) {
+        for (int i = 0; i < m_standard.profiles_list->count(); i++) {
+            if (m_standard.profiles_list->item(i)->data(Qt::UserRole).toString() == KdenliveSettings::default_profile()) {
+                m_standard.profiles_list->setCurrentRow(i);
+                m_standard.profiles_list->scrollToItem(m_standard.profiles_list->currentItem());
+                break;
+            }
+        }
+    }
+
     // select default profile
     // select default profile
+    fprintf(stderr, "LOOKING FOR: %s", ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()).toUtf8().data());
     QList<QListWidgetItem *> profiles = m_standard.profiles_list->findItems(ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()), Qt::MatchExactly);
     if (profiles.count() > 0) m_standard.profiles_list->setCurrentItem(profiles.at(0));
     QList<QListWidgetItem *> profiles = m_standard.profiles_list->findItems(ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()), Qt::MatchExactly);
     if (profiles.count() > 0) m_standard.profiles_list->setCurrentItem(profiles.at(0));
+
+    fprintf(stderr, "LOOKING FOR: %s // %d", ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()).toUtf8().data(), profiles.count());
     addPage(page2);
 
     QWizardPage *page3 = new QWizardPage;
     addPage(page2);
 
     QWizardPage *page3 = new QWizardPage;
@@ -408,23 +423,39 @@ void Wizard::slotCheckStandard()
 {
     m_standard.profiles_list->clear();
     QStringList profiles;
 {
     m_standard.profiles_list->clear();
     QStringList profiles;
-    if (m_standard.button_dv->isChecked()) {
+    if (!m_standard.button_hdv->isChecked()) {
         // DV standard
         // DV standard
-        m_standard.profiles_list->addItems(m_dvProfiles);
-    } else if (m_standard.button_hdv->isChecked()) {
+        QMapIterator<QString, QString> i(m_dvProfiles);
+        while (i.hasNext()) {
+            i.next();
+            QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
+            item->setData(Qt::UserRole, i.value());
+        }
+    }
+    if (!m_standard.button_dv->isChecked()) {
         // HDV standard
         // HDV standard
-        m_standard.profiles_list->addItems(m_hdvProfiles);
-    } else {
-        m_standard.profiles_list->addItems(m_dvProfiles);
-        m_standard.profiles_list->addItems(m_hdvProfiles);
-        m_standard.profiles_list->addItems(m_otherProfiles);
+        QMapIterator<QString, QString> i(m_hdvProfiles);
+        while (i.hasNext()) {
+            i.next();
+            QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
+            item->setData(Qt::UserRole, i.value());
+        }
+    }
+    if (m_standard.button_all->isChecked()) {
+        QMapIterator<QString, QString> i(m_otherProfiles);
+        while (i.hasNext()) {
+            i.next();
+            QListWidgetItem *item = new QListWidgetItem(i.key(), m_standard.profiles_list);
+            item->setData(Qt::UserRole, i.value());
+        }
         //m_standard.profiles_list->sortItems();
     }
 
     for (int i = 0; i < m_standard.profiles_list->count(); i++) {
         QListWidgetItem *item = m_standard.profiles_list->item(i);
         //m_standard.profiles_list->sortItems();
     }
 
     for (int i = 0; i < m_standard.profiles_list->count(); i++) {
         QListWidgetItem *item = m_standard.profiles_list->item(i);
-        MltVideoProfile prof = ProfilesDialog::getVideoProfile(m_profilesInfo.value(item->text()));
-        const QString infoString = ("<strong>" + i18n("Frame size:") + " </strong>%1x%2<br /><strong>" + i18n("Frame rate:") + " </strong>%3/%4<br /><strong>" + i18n("Pixel aspect ratio:") + "</strong>%5/%6<br /><strong>" + i18n("Display aspect ratio:") + " </strong>%7/%8").arg(QString::number(prof.width), QString::number(prof.height), QString::number(prof.frame_rate_num), QString::number(prof.frame_rate_den), QString::number(prof.sample_aspect_num), QString::number(prof.sample_aspect_den), QString::number(prof.display_aspect_num), QString::number(prof.display_aspect_den));
+
+        QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(item->data(Qt::UserRole).toString());
+        const QString infoString = ("<strong>" + i18n("Frame size:") + " </strong>%1x%2<br /><strong>" + i18n("Frame rate:") + " </strong>%3/%4<br /><strong>" + i18n("Pixel aspect ratio:") + "</strong>%5/%6<br /><strong>" + i18n("Display aspect ratio:") + " </strong>%7/%8").arg(values.value("width"), values.value("height"), values.value("frame_rate_num"), values.value("frame_rate_den"), values.value("sample_aspect_num"), values.value("sample_aspect_den"), values.value("display_aspect_num"), values.value("display_aspect_den"));
         item->setToolTip(infoString);
     }
 
         item->setToolTip(infoString);
     }
 
@@ -454,7 +485,7 @@ void Wizard::adjustSettings()
     KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
     KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
     if (m_standard.profiles_list->currentItem()) {
     KdenliveSettings::setVideothumbnails(m_extra.videothumbs->isChecked());
     KdenliveSettings::setCrashrecovery(m_extra.autosave->isChecked());
     if (m_standard.profiles_list->currentItem()) {
-        QString selectedProfile = m_profilesInfo.value(m_standard.profiles_list->currentItem()->text());
+        QString selectedProfile = m_standard.profiles_list->currentItem()->data(Qt::UserRole).toString();
         if (selectedProfile.isEmpty()) selectedProfile = "dv_pal";
         KdenliveSettings::setDefault_profile(selectedProfile);
     }
         if (selectedProfile.isEmpty()) selectedProfile = "dv_pal";
         KdenliveSettings::setDefault_profile(selectedProfile);
     }
index 56c094a606a98246477890661788fb0f7bc8dc01..9a06f74aa12ec431bf36841c5535d3437c0c849f 100644 (file)
@@ -88,10 +88,9 @@ private:
     Ui::WizardCheck_UI m_check;
     QVBoxLayout *m_startLayout;
     bool m_systemCheckIsOk;
     Ui::WizardCheck_UI m_check;
     QVBoxLayout *m_startLayout;
     bool m_systemCheckIsOk;
-    QStringList m_dvProfiles;
-    QStringList m_hdvProfiles;
-    QStringList m_otherProfiles;
-    QMap <QString, QString> m_profilesInfo;
+    QMap <QString, QString> m_dvProfiles;
+    QMap <QString, QString> m_hdvProfiles;
+    QMap <QString, QString> m_otherProfiles;
     void slotCheckPrograms();
     void checkMltComponents();
     KIcon m_okIcon;
     void slotCheckPrograms();
     void checkMltComponents();
     KIcon m_okIcon;