1 /***************************************************************************
2 titlewidget.h - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
22 #include "ui_titlewidget_ui.h"
23 #include "titledocument.h"
25 #include "graphicsscenerectmove.h"
37 double scalex, scaley;
41 class TitleWidget : public QDialog , public Ui::TitleWidget_UI {
45 /** \brief Constructor
46 * \param projectPath Path to use when user requests loading or saving of titles as .kdenlivetitle documents */
47 TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent = 0);
48 virtual ~TitleWidget();
50 void setXml(QDomDocument doc);
52 /** \brief Find first available filename of the form titleXXX.png in projectUrl + "/titles/" directory
53 * \param projectUrl Url to directory of project.
54 * \returns A list, with the name in the form of "/path/to/titles/titleXXX" as the first element, the extension
55 * ".png" as the second element.
57 * The path "/titles/" is appended to projectUrl to locate the actual directory that contains the title pngs. */
58 static QStringList getFreeTitleInfo(const KUrl &projectUrl);
60 /** \brief Build a filename from a projectUrl and a titleName
61 * \param projectUrl Url to directory of project.
62 * \param titleName Name of title, on the form "titleXXX"
64 * The path "/titles/" is appended to projectUrl to build the directoryname, then .pgn is appended to
65 * get the filename. It is not checked that the title png actually exists, only the name is build and
67 static QString getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName);
70 virtual void resizeEvent(QResizeEvent * event);
73 QGraphicsPolygonItem *startViewport, *endViewport;
74 GraphicsSceneRectMove *m_scene;
76 QMap<QGraphicsItem*, Transform > transformations;
77 TitleDocument m_titledocument;
78 QGraphicsRectItem *m_frameBorder;
79 QGraphicsPixmapItem *m_frameImage;
84 QAction *m_buttonRect;
85 QAction *m_buttonText;
86 QAction *m_buttonImage;
87 QAction *m_buttonCursor;
88 QAction *m_buttonSave;
89 QAction *m_buttonLoad;
90 /** project path for storing title clips */
91 QString m_projectPath;
92 /** \brief Store the current choices of font, background and rect values */
94 /** \brief Read the last stored choices into the dialog */
98 void slotNewText(QGraphicsTextItem *tt);
99 void slotNewRect(QGraphicsRectItem *rect);
100 void slotChangeBackground();
101 void selectionChanged();
105 void setupViewports();
106 void zIndexChanged(int);
107 void itemScaled(int);
108 void itemRotate(int);
111 void saveTitle(KUrl url = KUrl());
113 QImage renderedPixmap();
116 void slotAdjustSelectedItem();
117 void slotUpdateZoom(int pos);
118 void slotZoom(bool up);
119 void slotAdjustZoom();
120 void slotZoomOneToOne();
121 void slotUpdateText();
122 void displayBackgroundFrame();
123 void setCurrentItem(QGraphicsItem *item);
126 void slotSelectTool();
127 void slotImageTool();
128 /** \brief Called when accepted, stores the user selections for next time use */