settings dialog fixes

svn path=/branches/KDE4/; revision=1884
parent 03cb8772
......@@ -29,42 +29,47 @@
KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog(parent, "settings", KdenliveSettings::self())
{
QWidget *page1 = new QWidget;
m_configMisc = new Ui::ConfigMisc_UI( );
m_configMisc->setupUi(page1);
addPage( page1, i18n("Misc"), "misc" );
QWidget *p1 = new QWidget;
m_configMisc.setupUi(p1);
page1 = addPage( p1, i18n("Misc"), "misc" );
QWidget *page2 = new QWidget;
m_configEnv = new Ui::ConfigEnv_UI( );
m_configEnv->setupUi(page2);
m_configEnv->kcfg_mltpath->setMode(KFile::Directory);
//WARNING: the 2 lines below should not be necessary, but does not work without it...
m_configEnv->kcfg_mltpath->setPath(KdenliveSettings::mltpath());
m_configEnv->kcfg_rendererpath->setPath(KdenliveSettings::rendererpath());
addPage( page2, i18n("Environnement"), "env" );
QWidget *p2 = new QWidget;
m_configEnv.setupUi(p2);
m_configEnv.mltpathurl->setMode(KFile::Directory);
m_configEnv.mltpathurl->lineEdit()->setObjectName("kcfg_mltpath");
m_configEnv.rendererpathurl->lineEdit()->setObjectName("kcfg_rendererpath");
page2 = addPage( p2, i18n("Environnement"), "env" );
QStringList profilesNames = ProfilesDialog::getProfileNames();
m_configMisc->profiles_list->addItems(profilesNames);
//User edited the configuration - update your local copies of the
//configuration data
m_configMisc.profiles_list->addItems(profilesNames);
m_defaulfProfile = ProfilesDialog::getSettingsFromFile(KdenliveSettings::default_profile()).value("description");
if (profilesNames.contains(m_defaulfProfile)) m_configMisc.profiles_list->setCurrentItem(m_defaulfProfile);
slotUpdateDisplay();
connect(m_configMisc->profiles_list, SIGNAL(currentIndexChanged( int )), this, SLOT(slotUpdateDisplay()));
connect(m_configMisc.profiles_list, SIGNAL(currentIndexChanged( int )), this, SLOT(slotUpdateDisplay()));
}
KdenliveSettingsDialog::~KdenliveSettingsDialog()
{}
bool KdenliveSettingsDialog::hasChanged()
{
kDebug()<<"// // // KCONFIG hasChanged called";
if (m_configMisc.profiles_list->currentText() != m_defaulfProfile) return true;
return KConfigDialog::hasChanged();
}
void KdenliveSettingsDialog::slotUpdateDisplay()
{
QString currentProfile = m_configMisc->profiles_list->currentText();
QString currentProfile = m_configMisc.profiles_list->currentText();
QMap< QString, QString > values = ProfilesDialog::getSettingsForProfile(currentProfile);
m_configMisc->p_size->setText(values.value("width") + "x" + values.value("height"));
m_configMisc->p_fps->setText(values.value("frame_rate_num") + "/" + values.value("frame_rate_den"));
m_configMisc->p_aspect->setText(values.value("sample_aspect_num") + "/" + values.value("sample_aspect_den"));
m_configMisc->p_display->setText(values.value("display_aspect_num") + "/" + values.value("display_aspect_den"));
if (values.value("progressive").toInt() == 0) m_configMisc->p_progressive->setText(i18n("Interlaced"));
else m_configMisc->p_progressive->setText(i18n("Progressive"));
m_configMisc.p_size->setText(values.value("width") + "x" + values.value("height"));
m_configMisc.p_fps->setText(values.value("frame_rate_num") + "/" + values.value("frame_rate_den"));
m_configMisc.p_aspect->setText(values.value("sample_aspect_num") + "/" + values.value("sample_aspect_den"));
m_configMisc.p_display->setText(values.value("display_aspect_num") + "/" + values.value("display_aspect_den"));
if (values.value("progressive").toInt() == 0) m_configMisc.p_progressive->setText(i18n("Interlaced"));
else m_configMisc.p_progressive->setText(i18n("Progressive"));
}
......
......@@ -34,16 +34,27 @@ class KdenliveSettingsDialog : public KConfigDialog
public:
KdenliveSettingsDialog(QWidget * parent = 0);
~KdenliveSettingsDialog();
protected:
virtual bool hasChanged();
private slots:
void slotUpdateDisplay();
private:
Ui::ConfigEnv_UI* m_configEnv;
Ui::ConfigMisc_UI* m_configMisc;
KPageWidgetItem *page1;
KPageWidgetItem *page2;
Ui::ConfigEnv_UI m_configEnv;
Ui::ConfigMisc_UI m_configMisc;
QStringList m_mltProfilesList;
QStringList m_customProfilesList;
bool m_isCustomProfile;
QString m_defaulfProfile;
signals:
void customChanged();
};
......
......@@ -481,8 +481,7 @@ void MainWindow::slotPreferences()
// KConfigDialog didn't find an instance of this dialog, so lets
// create it :
KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
//connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateConfiguration()) );
dialog->show();
}
......
......@@ -82,7 +82,38 @@ QStringList ProfilesDialog::getProfileNames()
}
// static
QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString path)
QMap< QString, QString > ProfilesDialog::getSettingsFromFile(const QString path)
{
QStringList profilesNames;
QStringList profilesFiles;
QStringList profilesFilter;
profilesFilter<<"*";
// List the Mlt profiles
profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
for (int i = 0; i < profilesFiles.size(); ++i) {
if (profilesFiles.at(i) == path) {
KConfig confFile(KdenliveSettings::mltpath() + "/" + profilesFiles.at(i));
return confFile.entryMap();
}
}
// List custom profiles
QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
for (int i = 0; i < customProfiles.size(); ++i) {
QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
for (int i = 0; i < profiles.size(); ++i) {
if (profiles.at(i) == path) {
KConfig confFile(customProfiles.at(i) + "/" + profiles.at(i));
return confFile.entryMap();
}
}
}
return QMap< QString, QString >();
}
// static
QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString profileName)
{
QStringList profilesNames;
QStringList profilesFiles;
......@@ -94,7 +125,7 @@ QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString pat
for (int i = 0; i < profilesFiles.size(); ++i) {
KConfig confFile(KdenliveSettings::mltpath() + "/" + profilesFiles.at(i));
QMap< QString, QString > values = confFile.entryMap();
if (values.value("description") == path) return values;
if (values.value("description") == profileName) return values;
}
// List custom profiles
......@@ -104,7 +135,7 @@ QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString pat
for (int i = 0; i < profiles.size(); ++i) {
KConfig confFile(customProfiles.at(i) + "/" + profiles.at(i));
QMap< QString, QString > values = confFile.entryMap();
if (values.value("description") == path) return values;
if (values.value("description") == profileName) return values;
}
}
return QMap< QString, QString >();
......
......@@ -33,7 +33,8 @@ class ProfilesDialog : public QDialog
ProfilesDialog(QWidget * parent = 0);
static QStringList getProfileNames();
static QMap< QString, QString > getSettingsForProfile(const QString path);
static QMap< QString, QString > getSettingsForProfile(const QString profileName);
static QMap< QString, QString > getSettingsFromFile(const QString path);
private slots:
void slotUpdateDisplay();
......
......@@ -22,7 +22,7 @@
#include <KStandardDirs>
#include <KDebug>
#include "kdenlivesettings.h"
#include "profilesdialog.h"
#include "projectsettings.h"
......@@ -32,6 +32,8 @@ ProjectSettings::ProjectSettings(QWidget * parent): QDialog(parent), m_isCustomP
QStringList profilesNames = ProfilesDialog::getProfileNames();
m_view.profiles_list->addItems(profilesNames);
QString defaulfProf = ProfilesDialog::getSettingsFromFile(KdenliveSettings::current_profile()).value("description");
if (profilesNames.contains(defaulfProf)) m_view.profiles_list->setCurrentItem(defaulfProf);
slotUpdateDisplay();
connect(m_view.profiles_list, SIGNAL(currentIndexChanged( int )), this, SLOT(slotUpdateDisplay()));
......
......@@ -24,7 +24,7 @@
</widget>
</item>
<item row="0" column="1" >
<widget class="KUrlRequester" name="kcfg_mltpath" />
<widget class="KUrlRequester" name="mltpathurl" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
......@@ -34,7 +34,7 @@
</widget>
</item>
<item row="1" column="1" >
<widget class="KUrlRequester" name="kcfg_rendererpath" />
<widget class="KUrlRequester" name="rendererpathurl" />
</item>
</layout>
</widget>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment