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 ***************************************************************************/
26 #include "ui_titlewidget_ui.h"
27 #include "titledocument.h"
29 #include "graphicsscenerectmove.h"
40 double scalex, scaley;
44 class TitleWidget : public QDialog , public Ui::TitleWidget_UI {
48 /** \brief Constructor
49 * \param projectPath Path to use when user requests loading or saving of titles as .kdenlivetitle documents */
50 TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent = 0);
51 virtual ~TitleWidget();
53 void setXml(QDomDocument doc);
55 /** \brief Find first available filename of the form titleXXX.png in projectUrl + "/titles/" directory
56 * \param projectUrl Url to directory of project.
57 * \returns A list, with the name in the form of "/path/to/titles/titleXXX" as the first element, the extension
58 * ".png" as the second element.
60 * The path "/titles/" is appended to projectUrl to locate the actual directory that contains the title pngs. */
61 static QStringList getFreeTitleInfo(const KUrl &projectUrl);
63 /** \brief Build a filename from a projectUrl and a titleName
64 * \param projectUrl Url to directory of project.
65 * \param titleName Name of title, on the form "titleXXX"
67 * The path "/titles/" is appended to projectUrl to build the directoryname, then .pgn is appended to
68 * get the filename. It is not checked that the title png actually exists, only the name is build and
70 static QString getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName);
73 virtual void resizeEvent(QResizeEvent * event);
76 QGraphicsPolygonItem *startViewport, *endViewport;
77 GraphicsSceneRectMove *m_scene;
79 QMap<QGraphicsItem*, Transform > transformations;
80 TitleDocument m_titledocument;
81 QGraphicsRectItem *m_frameBorder;
82 QGraphicsPixmapItem *m_frameImage;
87 QAction *m_buttonRect;
88 QAction *m_buttonText;
89 QAction *m_buttonImage;
90 QAction *m_buttonCursor;
91 QAction *m_buttonSave;
92 QAction *m_buttonLoad;
93 /** project path for storing title clips */
94 QString m_projectPath;
95 /** \brief Store the current choices of font, background and rect values */
97 /** \brief Read the last stored choices into the dialog */
101 void slotNewText(QGraphicsTextItem *tt);
102 void slotNewRect(QGraphicsRectItem *rect);
103 void slotChangeBackground();
104 void selectionChanged();
108 void setupViewports();
109 void zIndexChanged(int);
110 void itemScaled(int);
111 void itemRotate(int);
114 void saveTitle(KUrl url = KUrl());
116 QImage renderedPixmap();
119 void slotAdjustSelectedItem();
120 void slotUpdateZoom(int pos);
121 void slotZoom(bool up);
122 void slotAdjustZoom();
123 void slotZoomOneToOne();
124 void slotUpdateText();
125 void displayBackgroundFrame();
126 void setCurrentItem(QGraphicsItem *item);
129 void slotSelectTool();
130 void slotImageTool();
131 /** \brief Called when accepted, stores the user selections for next time use */