From: Jean-Baptiste Mardelle Date: Tue, 19 Feb 2008 22:53:36 +0000 (+0000) Subject: Start of project settings dialog X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c0a6a37636a9573eb894da2e977f5d9be965640e;p=kdenlive Start of project settings dialog svn path=/branches/KDE4/; revision=1877 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7674f6d0..cf662357 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,7 @@ kde4_add_ui_files(kdenlive_UI widgets/effectlist_ui.ui widgets/effectstack_ui.ui widgets/profiledialog_ui.ui + widgets/projectsettings_ui.ui ) set(kdenlive_SRCS @@ -68,7 +69,8 @@ set(kdenlive_SRCS addeffectcommand.cpp effectstackview.cpp parameterplotter.cpp - + profilesdialog.cpp + projectsettings.cpp ) kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc ) diff --git a/src/kdenliveui.rc b/src/kdenliveui.rc index 0d54dddb..6e16288d 100644 --- a/src/kdenliveui.rc +++ b/src/kdenliveui.rc @@ -1,6 +1,6 @@ - + Extra Toolbar @@ -12,7 +12,7 @@ Project - + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4449df7f..663b952b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -49,7 +49,8 @@ #include "ui_configmisc_ui.h" #include "ui_configenv_ui.h" #include "initeffects.h" -#include "ui_profiledialog_ui.h" +#include "profilesdialog.h" +#include "projectsettings.h" #define ID_STATUS_MSG 1 #define ID_EDITMODE_MSG 2 @@ -225,6 +226,14 @@ void MainWindow::setupActions() profilesAction->setIcon(KIcon("document-new")); actionCollection()->addAction("manage_profiles", profilesAction); connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles())); + + KAction* projectAction = new KAction(this); + projectAction->setText(i18n("Project Settings")); + projectAction->setIcon(KIcon("document-new")); + actionCollection()->addAction("project_settings", projectAction); + connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings())); + + KStandardAction::quit(kapp, SLOT(quit()), actionCollection()); @@ -387,31 +396,21 @@ void MainWindow::parseProfiles() // Parse MLT profiles to build a list of available video formats if (profilesList.isEmpty()) parseProfiles(); -/* - uint i = 0; - for (; i < profilesList.count(); i++) { - KConfig confFile(profilePath + *profilesList.at(i), true); - QString name = confFile.readEntry("description"); - int width = confFile.readNumEntry("width"); - int height = confFile.readNumEntry("height"); - int aspect_num = confFile.readNumEntry("sample_aspect_num"); - int aspect_den = confFile.readNumEntry("sample_aspect_den"); - int display_num = confFile.readNumEntry("display_aspect_num"); - int display_den = confFile.readNumEntry("display_aspect_den"); - int fps_num = confFile.readNumEntry("frame_rate_num"); - int fps_den = confFile.readNumEntry("frame_rate_den"); - int progressive = confFile.readNumEntry("progressive"); - if (!name.isEmpty()) m_projectTemplates[name] = formatTemplate(width, height, fps_num, fps_den, aspect_num, aspect_den, display_num, display_den, progressive, *profilesList.at(i)); - }*/ } void MainWindow::slotEditProfiles() { - QDialog *w = new QDialog; - Ui::ProfilesDialog_UI profilesDialog; - profilesDialog.setupUi(w); + ProfilesDialog *w = new ProfilesDialog; + w->exec(); + delete w; +} + +void MainWindow::slotEditProjectSettings() +{ + ProjectSettings *w = new ProjectSettings; w->exec(); + delete w; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 04255cb1..5166acb6 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -118,6 +118,7 @@ class MainWindow : public KXmlGuiWindow void slotUpdateMousePosition(int pos); void slotAddEffect(int effectType, const QString &effectName); void slotEditProfiles(); + void slotEditProjectSettings(); }; #endif diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp new file mode 100644 index 00000000..a6dc3959 --- /dev/null +++ b/src/profilesdialog.cpp @@ -0,0 +1,154 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include + +#include +#include + +#include "kdenlivesettings.h" +#include "profilesdialog.h" + +ProfilesDialog::ProfilesDialog(QWidget * parent): QDialog(parent), m_isCustomProfile(false) +{ + m_view.setupUi(this); + + QStringList profilesFilter; + profilesFilter<<"*"; + + // List the Mlt profiles + m_mltProfilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); + m_view.profiles_list->addItems(m_mltProfilesList); + + // List custom profiles + QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles"); + for (int i = 0; i < customProfiles.size(); ++i) + m_customProfilesList << QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files); + m_view.profiles_list->addItems(m_customProfilesList); + + if (!KdenliveSettings::default_profile().isEmpty()) { + int ix = m_view.profiles_list->findText(KdenliveSettings::default_profile()); + m_view.profiles_list->setCurrentIndex(ix); + } + slotUpdateDisplay(); + connect(m_view.profiles_list, SIGNAL(currentIndexChanged( int )), this, SLOT(slotUpdateDisplay())); +} + + +// static +QStringList ProfilesDialog::getProfileNames() +{ + 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) { + KConfig confFile(KdenliveSettings::mltpath() + "/" + profilesFiles.at(i)); + QString desc = confFile.entryMap().value("description"); + if (!desc.isEmpty()) profilesNames.append(desc); + } + + // List custom profiles + QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles"); + for (int i = 0; i < customProfiles.size(); ++i) { + profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files); + for (int i = 0; i < profilesFiles.size(); ++i) { + KConfig confFile(customProfiles.at(i) + "/" + profilesFiles.at(i)); + QString desc = confFile.entryMap().value("description"); + if (!desc.isEmpty()) profilesNames.append(desc); + } + } + + return profilesNames; +} + +// static +QMap< QString, QString > ProfilesDialog::getSettingsForProfile(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) { + KConfig confFile(KdenliveSettings::mltpath() + "/" + profilesFiles.at(i)); + QMap< QString, QString > values = confFile.entryMap(); + if (values.value("description") == path) return values; + } + + // 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) { + KConfig confFile(customProfiles.at(i) + "/" + profiles.at(i)); + QMap< QString, QString > values = confFile.entryMap(); + if (values.value("description") == path) return values; + } + } + return QMap< QString, QString >(); +} + +void ProfilesDialog::slotUpdateDisplay() +{ + QString currentProfile = m_view.profiles_list->currentText(); + QString currentProfilePath; + if (m_mltProfilesList.indexOf(currentProfile) != -1) { + currentProfilePath = KdenliveSettings::mltpath() + "/" + currentProfile; + m_isCustomProfile = false; + } + else { + m_isCustomProfile = true; + QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "mltprofiles"); + QStringList profilesFilter; + profilesFilter<<"*"; + int i; + for (i = 0; i < customProfiles.size(); ++i) { + QStringList profs = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files); + if (profs.indexOf(currentProfile) != -1) break; + } + currentProfilePath = customProfiles.at(i) + "/" + currentProfile; + } + m_view.button_delete->setEnabled(m_isCustomProfile); + m_view.properties->setEnabled(m_isCustomProfile); + + KConfig confFile(currentProfilePath); + QMap< QString, QString > values = confFile.entryMap(); + m_view.description->setText(values.value("description")); + m_view.size_w->setValue(values.value("width").toInt()); + m_view.size_h->setValue(values.value("height").toInt()); + m_view.aspect_num->setValue(values.value("sample_aspect_num").toInt()); + m_view.aspect_den->setValue(values.value("sample_aspect_den").toInt()); + m_view.display_num->setValue(values.value("display_aspect_num").toInt()); + m_view.display_den->setValue(values.value("display_aspect_den").toInt()); + m_view.frame_num->setValue(values.value("frame_rate_num").toInt()); + m_view.frame_den->setValue(values.value("frame_rate_den").toInt()); + m_view.progressive->setChecked(values.value("progressive").toInt()); + +} + + +#include "profilesdialog.moc" + + diff --git a/src/profilesdialog.h b/src/profilesdialog.h new file mode 100644 index 00000000..2466cd51 --- /dev/null +++ b/src/profilesdialog.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef PROFILESDIALOG_H +#define PROFILESDIALOG_H + +#include + +#include "ui_profiledialog_ui.h" + +class ProfilesDialog : public QDialog +{ + Q_OBJECT + + public: + ProfilesDialog(QWidget * parent = 0); + + static QStringList getProfileNames(); + static QMap< QString, QString > getSettingsForProfile(const QString path); + + private slots: + void slotUpdateDisplay(); + + private: + Ui::ProfilesDialog_UI m_view; + QStringList m_mltProfilesList; + QStringList m_customProfilesList; + bool m_isCustomProfile; +}; + + +#endif + diff --git a/src/projectsettings.cpp b/src/projectsettings.cpp new file mode 100644 index 00000000..0015ded6 --- /dev/null +++ b/src/projectsettings.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include + +#include +#include + + +#include "profilesdialog.h" +#include "projectsettings.h" + +ProjectSettings::ProjectSettings(QWidget * parent): QDialog(parent), m_isCustomProfile(false) +{ + m_view.setupUi(this); + + QStringList profilesNames = ProfilesDialog::getProfileNames(); + m_view.profiles_list->addItems(profilesNames); + + slotUpdateDisplay(); + connect(m_view.profiles_list, SIGNAL(currentIndexChanged( int )), this, SLOT(slotUpdateDisplay())); +} + + +void ProjectSettings::slotUpdateDisplay() +{ + QString currentProfile = m_view.profiles_list->currentText(); + QMap< QString, QString > values = ProfilesDialog::getSettingsForProfile(currentProfile); + m_view.p_size->setText(values.value("width") + "x" + values.value("height")); + m_view.p_fps->setText(values.value("frame_rate_num") + "/" + values.value("frame_rate_den")); + m_view.p_aspect->setText(values.value("sample_aspect_num") + "/" + values.value("sample_aspect_den")); + m_view.p_display->setText(values.value("display_aspect_num") + "/" + values.value("display_aspect_den")); + if (values.value("progressive").toInt() == 0) m_view.p_progressive->setText(i18n("Interlaced")); + else m_view.p_progressive->setText(i18n("Progressive")); +} + + +#include "projectsettings.moc" + + diff --git a/src/projectsettings.h b/src/projectsettings.h new file mode 100644 index 00000000..756915df --- /dev/null +++ b/src/projectsettings.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef PROJECTSETTINGS_H +#define PROJECTSETTINGS_H + +#include + +#include "ui_projectsettings_ui.h" + +class ProjectSettings : public QDialog +{ + Q_OBJECT + + public: + ProjectSettings(QWidget * parent = 0); + + private slots: + void slotUpdateDisplay(); + + private: + Ui::ProjectSettings_UI m_view; + QStringList m_mltProfilesList; + QStringList m_customProfilesList; + bool m_isCustomProfile; +}; + + +#endif + diff --git a/src/widgets/profiledialog_ui.ui b/src/widgets/profiledialog_ui.ui index 1db8ba5b..a7a29651 100644 --- a/src/widgets/profiledialog_ui.ui +++ b/src/widgets/profiledialog_ui.ui @@ -10,11 +10,11 @@ - Dialog + Profiles - + @@ -24,21 +24,21 @@ - + Create - + Delete - + Use as default @@ -68,7 +68,7 @@ - + Properties @@ -81,7 +81,7 @@ - + @@ -91,7 +91,11 @@ - + + + 10000 + + @@ -107,7 +111,11 @@ - + + + 10000 + + @@ -117,7 +125,11 @@ - + + + 10000 + + @@ -133,7 +145,11 @@ - + + + 10000 + + @@ -143,7 +159,7 @@ - + @@ -159,7 +175,7 @@ - + @@ -169,7 +185,7 @@ - + @@ -185,7 +201,7 @@ - + @@ -201,7 +217,7 @@ - + Progressive @@ -211,14 +227,14 @@ - kcombobox + profiles_list label - kpushbutton - kpushbutton_2 - kpushbutton_3 + button_create + button_delete + button_default buttonBox horizontalSpacer - groupBox + properties diff --git a/src/widgets/projectsettings_ui.ui b/src/widgets/projectsettings_ui.ui new file mode 100644 index 00000000..d7fa4d8f --- /dev/null +++ b/src/widgets/projectsettings_ui.ui @@ -0,0 +1,184 @@ + + ProjectSettings_UI + + + + 0 + 0 + 308 + 250 + + + + Project Settings + + + + + + Project folder + + + + + + + + + + Video Profile + + + + + + Profile + + + + + + + + + + + + Size: + + + + + + + 720x576 + + + + + + + Frame rate: + + + + + + + 25/1 + + + + + + + Aspect ratio: + + + + + + + 59/54 + + + + + + + Display ratio: + + + + + + + 4/3 + + + + + + + + + Interlaced + + + + + + + + + + Qt::Vertical + + + + 105 + 17 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + KComboBox + QComboBox +
kcombobox.h
+
+ + KUrlRequester + QFrame +
kurlrequester.h
+
+
+ + + + buttonBox + accepted() + ProjectSettings_UI + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ProjectSettings_UI + reject() + + + 316 + 260 + + + 286 + 274 + + + + +