Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

profilesdialog.h 4.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/***************************************************************************
 *   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


25
#include "definitions.h"
26
#include "ui_profiledialog_ui.h"
27
#include <mlt++/Mlt.h>
28

29 30
class KMessageWidget;

31 32
class ProfilesDialog : public QDialog
{
33 34 35
    Q_OBJECT

public:
Vincent Pinon's avatar
Vincent Pinon committed
36
    explicit ProfilesDialog(QWidget * parent = 0);
37
    /** @brief Using this constructor, the dialog only allows editing one profile. */
38
    explicit ProfilesDialog(QString profilePath, QWidget * parent = 0);
39

Laurent Montel's avatar
Laurent Montel committed
40 41
    void fillList(const QString &selectedProfile = QString());
    static QMap< QString, QString > getSettingsFromFile(const QString& path);
42 43
    /** @brief Create profile from xml in MLT project file */
    static MltVideoProfile getVideoProfileFromXml(const QDomElement &element);
Laurent Montel's avatar
Laurent Montel committed
44
    static MltVideoProfile getVideoProfile(const QString &name);
45
    static MltVideoProfile getVideoProfile(Mlt::Profile &profile);
46
    static QMap <QString, QString> getProfilesInfo();
47
    static void saveProfile(MltVideoProfile &profile, QString profilePath = QString());
48
    /** @brief Check if a given profile has a profile file describing it */
Laurent Montel's avatar
Laurent Montel committed
49
    static QString existingProfile(const MltVideoProfile &profile);
50
    static bool existingProfileDescription(const QString &desc);
51

52 53 54 55 56 57 58 59
    /** @brief Check if a given profile matches passed properties:
     *  @param width The profile frame width
     *  @param height The profile frame height
     *  @param fps The profile fps
     *  @param par The sample aspect ratio
     *  @param isImage If true, compare width with profile's display width ( = dar * height)
     *  @param profile The profile to match
     *  @return true if properties match profile */
Laurent Montel's avatar
Laurent Montel committed
60
    static bool matchProfile(int width, int height, double fps, double par, bool isImage, const MltVideoProfile &profile);
61

62
    /** @brief Find profiles that match parameter properties:
63 64 65
     *  @param width The profile frame width
     *  @param height The profile frame height
     *  @param fps The profile fps
66 67 68 69 70
     *  @param par The sample aspect ratio
     *  @param useDisplayWidth If true, compare width with profile's display width ( = dar * height)
     *  @return A string list of the matching profiles description */
    static QMap <QString, QString> getProfilesFromProperties(int width, int height, double fps, double par, bool useDisplayWidth = false);

71 72 73 74 75
    /** @brief Get the descriptive text for given colorspace code (defined by MLT)
     *  @param colorspace An int as defined in mlt_profile.h
     *  @return The string description */
    static QString getColorspaceDescription(int colorspace);

76 77 78 79 80
    /** @brief Get the colorspace code (defined by MLT) from a descriptive text
     *  @param desctiption A string description as defined in getColorspaceDescription(int colorspace)
     *  @return The int code */
    static int getColorspaceFromDescription(const QString &description);

81 82 83
protected:
    virtual void closeEvent(QCloseEvent *event);

84
private slots:
85
    void slotUpdateDisplay(QString currentProfile = QString());
86
    void slotCreateProfile();
87
    bool slotSaveProfile();
88
    void slotDeleteProfile();
89
    void slotSetDefaultProfile();
90
    void slotProfileEdited();
91
    void slotAdjustWidth();
92
    virtual void accept();
93
    virtual void reject();
94

95
private:
96
    Ui::ProfilesDialog_UI m_view;
97 98
    int m_selectedProfileIndex;
    bool m_profileIsModified;
99
    bool m_isCustomProfile;
100 101
    /** @brief If we are in single profile editing, should contain the path for this profile. */
    QString m_customProfilePath;
102
    KMessageWidget *m_infoMessage;
Laurent Montel's avatar
Laurent Montel committed
103
    void saveProfile(QString path);
104
    bool askForSave();
105 106 107 108 109
};


#endif