]> git.sesse.net Git - kdenlive/blob - src/profilesdialog.h
31bae209986549cb2385548da9d9811aa3315ca6
[kdenlive] / src / profilesdialog.h
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef PROFILESDIALOG_H
22 #define PROFILESDIALOG_H
23
24
25 #include "definitions.h"
26 #include "ui_profiledialog_ui.h"
27
28 class ProfilesDialog : public QDialog
29 {
30     Q_OBJECT
31
32 public:
33     ProfilesDialog(QWidget * parent = 0);
34     /** @brief Using this constructor, the dialog only allows editing one profile. */
35     explicit ProfilesDialog(QString profilePath, QWidget * parent = 0);
36
37     void fillList(const QString &selectedProfile = QString());
38     static QMap< QString, QString > getSettingsForProfile(const QString &profileName);
39     static QMap< QString, QString > getSettingsFromFile(const QString& path);
40     static QString getPathFromDescription(const QString& profileDesc);
41     static MltVideoProfile getVideoProfile(const QString &name);
42     static QMap <QString, QString> getProfilesInfo();
43     static void saveProfile(MltVideoProfile &profile, QString profilePath = QString());
44     static QString existingProfile(MltVideoProfile profile);
45     static bool existingProfileDescription(const QString &desc);
46
47     /** @brief Check if a given profile matches passed properties:
48      *  @param width The profile frame width
49      *  @param height The profile frame height
50      *  @param fps The profile fps
51      *  @param par The sample aspect ratio
52      *  @param isImage If true, compare width with profile's display width ( = dar * height)
53      *  @param profile The profile to match
54      *  @return true if properties match profile */
55     static bool matchProfile(int width, int height, double fps, double par, bool isImage, const MltVideoProfile &profile);
56
57     /** @brief Find profiles that match parameter properties:
58      *  @param width The profile frame width
59      *  @param height The profile frame height
60      *  @param fps The profile fps
61      *  @param par The sample aspect ratio
62      *  @param useDisplayWidth If true, compare width with profile's display width ( = dar * height)
63      *  @return A string list of the matching profiles description */
64     static QMap <QString, QString> getProfilesFromProperties(int width, int height, double fps, double par, bool useDisplayWidth = false);
65
66     /** @brief Returns an value from a string by replacing "%width" and "%height" with given profile values:
67      *  @param profile The profile that gives width & height
68      *  @param eval The string to be evaluated, for example: "%width / 2"
69      *  @return the evaluated value */
70     static double getStringEval(const MltVideoProfile &profile, QString eval, const QPoint &frameSize = QPoint());
71
72     /** @brief Get the descriptive text for given colorspace code (defined by MLT)
73      *  @param colorspace An int as defined in mlt_profile.h
74      *  @return The string description */
75     static QString getColorspaceDescription(int colorspace);
76
77     /** @brief Get the colorspace code (defined by MLT) from a descriptive text
78      *  @param desctiption A string description as defined in getColorspaceDescription(int colorspace)
79      *  @return The int code */
80     static int getColorspaceFromDescription(const QString &description);
81
82 protected:
83     virtual void closeEvent(QCloseEvent *event);
84
85 private slots:
86     void slotUpdateDisplay(QString currentProfile = QString());
87     void slotCreateProfile();
88     bool slotSaveProfile();
89     void slotDeleteProfile();
90     void slotSetDefaultProfile();
91     void slotProfileEdited();
92     virtual void accept();
93
94 private:
95     Ui::ProfilesDialog_UI m_view;
96     int m_selectedProfileIndex;
97     bool m_profileIsModified;
98     bool m_isCustomProfile;
99     /** @brief If we are in single profile editing, should contain the path for this profile. */
100     QString m_customProfilePath;
101     void saveProfile(QString path);
102     bool askForSave();
103 };
104
105
106 #endif
107