1
/* This file is part of the KDE project
2
Copyright (C) 1999,2000 Kurt Granroth <granroth@kde.org>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
#include "aktion_part.h"
23
#include <kiconloader.h>
24
#include <kinstance.h>
26
#include <kaboutdata.h>
28
#include <kparts/partmanager.h>
35
static const char *description = I18N_NOOP("KDE Video Player");
36
static const char *version = "1.99";
41
* This function is the 'main' function of this part. It takes
42
* the form 'void *init_lib<library name>()'. It always returns a
45
void *init_libaktion()
47
return new AktionFactory;
52
* We need one static instance of the factory for our C 'main'
55
KInstance *AktionFactory::s_instance = 0L;
57
AktionFactory::AktionFactory()
59
KGlobal::locale()->insertCatalogue( QString::fromLatin1("aktion") );
62
AktionFactory::~AktionFactory()
66
delete s_instance->aboutData();
73
QObject *AktionFactory::create(QObject *parent, const char *name, const char*,
76
QObject *obj = new AktionPart((QWidget*)parent, name);
77
emit objectCreated(obj);
81
KInstance *AktionFactory::instance()
84
s_instance = new KInstance( aboutData() );
88
KAboutData *AktionFactory::aboutData()
90
KAboutData *about = new KAboutData("aktion", I18N_NOOP("aKtion"), version,
91
description, KAboutData::License_GPL,
92
"(c) 2000 Guillermo P. Marotte");
93
about->addAuthor("Guillermo P. Marotte",0, "g-marotte@usa.net");
97
AktionPart::AktionPart(QWidget *parent, const char *name)
98
: KParts::ReadOnlyPart(parent, name)
100
setInstance(AktionFactory::instance());
102
// create a canvas to insert our widget
103
QWidget *canvas = new QWidget(parent);
104
canvas->setFocusPolicy(QWidget::ClickFocus);
105
canvas->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
108
// create our animation widget
109
widget = new KXAnim(canvas);
110
widget->setLoop(true);
113
// create and connect our actions
114
m_playAction = new KAction(i18n("Play"), "1rightarrow",
116
SLOT(slotPlay()), actionCollection(),
119
m_pauseAction = new KAction(i18n("Pause"), "player_pause",
121
SLOT(slotPause()), actionCollection(),
124
m_stopAction = new KAction(i18n("Stop"), "player_stop",
126
SLOT(slotStop()), actionCollection(),
129
m_backwardAction = new KAction(i18n("Backward"),
132
SLOT(slotBackward()), actionCollection(),
135
m_forwardAction = new KAction(i18n("Forward"), "2rightarrow",
137
SLOT(slotForward()), actionCollection(),
140
m_extension = new AktionBrowserExtension(this);
141
setXMLFile("aktion_part.rc");
144
AktionPart::~AktionPart()
149
bool AktionPart::openFile()
151
widget->setFile(m_file);
154
QTimer::singleShot(2000, this, SLOT(slotPlay()));
159
bool AktionPart::closeURL()
162
return ReadOnlyPart::closeURL();
165
void AktionPart::slotPlay()
168
m_playAction->setEnabled(false);
169
m_pauseAction->setEnabled(true);
170
m_stopAction->setEnabled(true);
171
m_forwardAction->setEnabled(true);
172
m_backwardAction->setEnabled(true);
175
void AktionPart::slotPause()
178
m_playAction->setEnabled(true);
179
m_pauseAction->setEnabled(false);
180
m_stopAction->setEnabled(false);
181
m_forwardAction->setEnabled(false);
182
m_backwardAction->setEnabled(false);
185
void AktionPart::slotStop()
188
m_playAction->setEnabled(true);
189
m_pauseAction->setEnabled(false);
190
m_stopAction->setEnabled(false);
191
m_forwardAction->setEnabled(false);
192
m_backwardAction->setEnabled(false);
195
void AktionPart::slotForward()
197
widget->stepForward();
200
void AktionPart::slotBackward()
205
AktionBrowserExtension::AktionBrowserExtension(AktionPart *parent)
206
: KParts::BrowserExtension(parent, "AktionBrowserExtension")
210
AktionBrowserExtension::~AktionBrowserExtension()
213
#include "aktion_part.moc"