profilesdialog.h 4.82 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 27
#include "ui_profiledialog_ui.h"

28 29
class ProfilesDialog : public QDialog
{
30 31 32
    Q_OBJECT

public:
Vincent Pinon's avatar
Vincent Pinon committed
33
    explicit 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

Laurent Montel's avatar
Laurent Montel committed
37 38 39
    void fillList(const QString &selectedProfile = QString());
    static QMap< QString, QString > getSettingsFromFile(const QString& path);
    static MltVideoProfile getVideoProfile(const QString &name);
40
    static QMap <QString, QString> getProfilesInfo();
41
    static void saveProfile(MltVideoProfile &profile, QString profilePath = QString());
Laurent Montel's avatar
Laurent Montel committed
42
    static QString existingProfile(const MltVideoProfile &profile);
43
    static bool existingProfileDescription(const QString &desc);
44

45 46 47 48 49 50 51 52
    /** @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
53
    static bool matchProfile(int width, int height, double fps, double par, bool isImage, const MltVideoProfile &profile);
54

55
    /** @brief Find profiles that match parameter properties:
56 57 58
     *  @param width The profile frame width
     *  @param height The profile frame height
     *  @param fps The profile fps
59 60 61 62 63 64 65 66 67
     *  @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);

    /** @brief Returns an value from a string by replacing "%width" and "%height" with given profile values:
     *  @param profile The profile that gives width & height
     *  @param eval The string to be evaluated, for example: "%width / 2"
     *  @return the evaluated value */
Laurent Montel's avatar
Laurent Montel committed
68
    static double getStringEval(const MltVideoProfile &profile, QString eval, const QPoint &frameSize = QPoint());
69

70 71 72 73 74
    /** @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);

75 76 77 78 79
    /** @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);

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

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

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


#endif