1 /*
2     Copyright (C) 2011 Harald Sitter <sitter@kde.org>
3 
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) version 3, or any
8     later version accepted by the membership of KDE e.V. (or its
9     successor approved by the membership of KDE e.V.), Nokia Corporation
10     (or its successors, if any) and the KDE Free Qt Foundation, which shall
11     act as a proxy defined in Section 6 of version 3 of the license.
12 
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     Lesser General Public License for more details.
17 
18     You should have received a copy of the GNU Lesser General Public
19     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 /****************************************************************************
23 **
24 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
25 ** All rights reserved.
26 ** Contact: Nokia Corporation (qt-info@nokia.com)
27 **
28 ** This file is part of the Qt Designer of the Qt Toolkit.
29 **
30 ** $QT_BEGIN_LICENSE:LGPL$
31 ** Commercial Usage
32 ** Licensees holding valid Qt Commercial licenses may use this file in
33 ** accordance with the Qt Commercial License Agreement provided with the
34 ** Software or, alternatively, in accordance with the terms contained in
35 ** a written agreement between you and Nokia.
36 **
37 ** GNU Lesser General Public License Usage
38 ** Alternatively, this file may be used under the terms of the GNU Lesser
39 ** General Public License version 2.1 as published by the Free Software
40 ** Foundation and appearing in the file LICENSE.LGPL included in the
41 ** packaging of this file.  Please review the following information to
42 ** ensure the GNU Lesser General Public License version 2.1 requirements
43 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
44 **
45 ** In addition, as a special exception, Nokia gives you certain additional
46 ** rights.  These rights are described in the Nokia Qt LGPL Exception
47 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
48 **
49 ** GNU General Public License Usage
50 ** Alternatively, this file may be used under the terms of the GNU
51 ** General Public License version 3.0 as published by the Free Software
52 ** Foundation and appearing in the file LICENSE.GPL included in the
53 ** packaging of this file.  Please review the following information to
54 ** ensure the GNU General Public License version 3.0 requirements will be
55 ** met: http://www.gnu.org/copyleft/gpl.html.
56 **
57 ** If you have questions regarding the use of this file, please contact
58 ** Nokia at qt-info@nokia.com.
59 ** $QT_END_LICENSE$
60 **
61 ****************************************************************************/
62 
63 #include "videoplayerplugin.h"
64 #include "videoplayertaskmenu.h"
65 
66 #include <QtDesigner/QExtensionFactory>
67 #include <QtDesigner/QExtensionManager>
68 #include <QtDesigner/QDesignerFormEditorInterface>
69 
70 #include <QtCore/qplugin.h>
71 #include <phonon/videoplayer.h>
72 
73 static const char *toolTipC = "Phonon Video Player";
74 
VideoPlayerPlugin(const QString & group,QObject * parent)75 VideoPlayerPlugin::VideoPlayerPlugin(const QString &group, QObject *parent) :
76     QObject(parent),
77     m_group(group),
78     m_initialized(false)
79 {
80 }
81 
name() const82 QString VideoPlayerPlugin::name() const
83 {
84     return QLatin1String("Phonon::VideoPlayer");
85 }
86 
group() const87 QString VideoPlayerPlugin::group() const
88 {
89     return m_group;
90 }
91 
toolTip() const92 QString VideoPlayerPlugin::toolTip() const
93 {
94     return QString(QLatin1String(toolTipC));
95 }
96 
whatsThis() const97 QString VideoPlayerPlugin::whatsThis() const
98 {
99     return QString(QLatin1String(toolTipC));
100 }
101 
includeFile() const102 QString VideoPlayerPlugin::includeFile() const
103 {
104     return QLatin1String("<phonon/videoplayer.h>");
105 }
106 
icon() const107 QIcon VideoPlayerPlugin::icon() const
108 {
109     return QIcon(QLatin1String(":/trolltech/phononwidgets/images/videoplayer.png"));
110 }
111 
isContainer() const112 bool VideoPlayerPlugin::isContainer() const
113 {
114     return false;
115 }
116 
createWidget(QWidget * parent)117 QWidget *VideoPlayerPlugin::createWidget(QWidget *parent)
118 {
119     return new Phonon::VideoPlayer(Phonon::NoCategory, parent);
120 }
121 
isInitialized() const122 bool VideoPlayerPlugin::isInitialized() const
123 {
124     return m_initialized;
125 }
126 
initialize(QDesignerFormEditorInterface * formEditor)127 void VideoPlayerPlugin::initialize(QDesignerFormEditorInterface *formEditor)
128 {
129     if (m_initialized)
130         return;
131 
132     QExtensionManager *manager = formEditor->extensionManager();
133     Q_ASSERT(manager != 0);
134 
135     manager->registerExtensions(new VideoPlayerTaskMenuFactory(manager),
136                                 Q_TYPEID(QDesignerTaskMenuExtension));
137 
138     m_initialized = true;
139 }
140 
domXml() const141 QString VideoPlayerPlugin::domXml() const
142 {
143     return QLatin1String("\
144     <ui language=\"c++\">\
145         <widget class=\"Phonon::VideoPlayer\" name=\"videoPlayer\">\
146             <property name=\"geometry\">\
147                 <rect>\
148                     <x>0</x>\
149                     <y>0</y>\
150                     <width>300</width>\
151                     <height>200</height>\
152                 </rect>\
153             </property>\
154         </widget>\
155     </ui>");
156 }
157