]> git.sesse.net Git - kdenlive/blob - src/titlewidget.h
[PATCH by Ray Lehtiniemi] Fix up &&/& confusion
[kdenlive] / src / titlewidget.h
1 /***************************************************************************
2                           titlewidget.h  -  description
3                              -------------------
4     begin                : Feb 28 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef TITLEWIDGET_H
19 #define TITLEWIDGET_H
20
21
22 #include <QMap>
23
24 #include "ui_titlewidget_ui.h"
25 #include "titledocument.h"
26 #include "renderer.h"
27 #include "graphicsscenerectmove.h"
28
29
30
31 class Transform {
32 public:
33     Transform() {
34         scalex = 1.0;
35         scaley = 1.0;
36         rotate = 0.0;
37     }
38     double scalex, scaley;
39     double rotate;
40 };
41
42 class TitleWidget : public QDialog , public Ui::TitleWidget_UI {
43     Q_OBJECT
44
45 public:
46     /** \brief Constructor
47      * \param projectPath Path to use when user requests loading or saving of titles as .kdenlivetitle documents */
48     TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent = 0);
49     virtual ~TitleWidget();
50     QDomDocument xml();
51     void setXml(QDomDocument doc);
52
53     /** \brief Find first available filename of the form titleXXX.png in projectUrl + "/titles/" directory
54     * \param projectUrl Url to directory of project.
55      * \returns A list, with the name in the form of "/path/to/titles/titleXXX" as the first element, the extension
56      * ".png" as the second element.
57      *
58      * The path "/titles/" is appended to projectUrl to locate the actual directory that contains the title pngs. */
59     static QStringList getFreeTitleInfo(const KUrl &projectUrl);
60
61     /** \brief Build a filename from a projectUrl and a titleName
62      * \param projectUrl Url to directory of project.
63      * \param titleName Name of title, on the form "titleXXX"
64      *
65      * The path "/titles/" is appended to projectUrl to build the directoryname, then .pgn is appended to
66      * get the filename. It is not checked that the title png actually exists, only the name is build and
67      * returned. */
68     static QString getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName);
69
70 protected:
71     virtual void resizeEvent(QResizeEvent * event);
72
73 private:
74     QGraphicsPolygonItem *startViewport, *endViewport;
75     GraphicsSceneRectMove *m_scene;
76     void initViewports();
77     QMap<QGraphicsItem*, Transform > transformations;
78     TitleDocument m_titledocument;
79     QGraphicsRectItem *m_frameBorder;
80     QGraphicsPixmapItem *m_frameImage;
81     int m_frameWidth;
82     int m_frameHeight;
83     Render *m_render;
84     int m_count;
85     QAction *m_buttonRect;
86     QAction *m_buttonText;
87     QAction *m_buttonImage;
88     QAction *m_buttonCursor;
89     QAction *m_buttonSave;
90     QAction *m_buttonLoad;
91     /** project path for storing title clips */
92     QString m_projectPath;
93     /** \brief Store the current choices of font, background and rect values */
94     void writeChoices();
95     /** \brief Read the last stored choices into the dialog */
96     void readChoices();
97
98 public slots:
99     void slotNewText(QGraphicsTextItem *tt);
100     void slotNewRect(QGraphicsRectItem *rect);
101     void slotChangeBackground();
102     void selectionChanged();
103     void textChanged();
104     void rectChanged();
105     void fontBold();
106     void setupViewports();
107     void zIndexChanged(int);
108     void itemScaled(int);
109     void itemRotate(int);
110     void itemHCenter();
111     void itemVCenter();
112     void saveTitle(KUrl url = KUrl());
113     void loadTitle();
114     QImage renderedPixmap();
115
116 private slots:
117     void slotAdjustSelectedItem();
118     void slotUpdateZoom(int pos);
119     void slotZoom(bool up);
120     void slotAdjustZoom();
121     void slotZoomOneToOne();
122     void slotUpdateText();
123     void displayBackgroundFrame();
124     void setCurrentItem(QGraphicsItem *item);
125     void slotTextTool();
126     void slotRectTool();
127     void slotSelectTool();
128     void slotImageTool();
129     /** \brief Called when accepted, stores the user selections for next time use */
130     void slotAccepted();
131 };
132
133
134 #endif