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 ***************************************************************************/
24 #include "ui_titlewidget_ui.h"
25 #include "titledocument.h"
27 #include "graphicsscenerectmove.h"
38 double scalex, scaley;
42 class TitleWidget : public QDialog , public Ui::TitleWidget_UI {
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();
51 void setXml(QDomDocument doc);
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.
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);
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"
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
68 static QString getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName);
71 virtual void resizeEvent(QResizeEvent * event);
74 QGraphicsPolygonItem *startViewport, *endViewport;
75 GraphicsSceneRectMove *m_scene;
77 QMap<QGraphicsItem*, Transform > transformations;
78 TitleDocument m_titledocument;
79 QGraphicsRectItem *m_frameBorder;
80 QGraphicsPixmapItem *m_frameImage;
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 */
95 /** \brief Read the last stored choices into the dialog */
99 void slotNewText(QGraphicsTextItem *tt);
100 void slotNewRect(QGraphicsRectItem *rect);
101 void slotChangeBackground();
102 void selectionChanged();
106 void setupViewports();
107 void zIndexChanged(int);
108 void itemScaled(int);
109 void itemRotate(int);
112 void saveTitle(KUrl url = KUrl());
114 QImage renderedPixmap();
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);
127 void slotSelectTool();
128 void slotImageTool();
129 /** \brief Called when accepted, stores the user selections for next time use */