1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#include "tdemid_part.h"
#include <kinstance.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <tdeaboutdata.h>
#include <tdeaction.h>
#include <tqiconset.h>
#include <tdeparts/partmanager.h>
#include "tdemidclient.h"
#include <tqtimer.h>
#include <tdelibs_export.h>
K_EXPORT_COMPONENT_FACTORY( libtdemidpart, KMidFactory )
/**
* We need one static instance of the factory for our C 'main'
* function
*/
TDEInstance *KMidFactory::s_instance = 0L;
KMidFactory::KMidFactory()
{
s_instance=0L;
}
KMidFactory::~KMidFactory()
{
if (s_instance)
{
delete s_instance->aboutData();
delete s_instance;
}
s_instance = 0;
}
KParts::Part *KMidFactory::createPartObject(TQWidget *parentWidget, const char *widgetName,
TQObject *parent, const char *name, const char*,
const TQStringList& )
{
KParts::Part *obj = new KMidPart(parentWidget, widgetName, parent, name);
return obj;
}
TDEAboutData *KMidFactory::aboutData()
{
TDEAboutData *aboutdata = new TDEAboutData("tdemid", "TDEMid", "2.0",
I18N_NOOP("MIDI/Karaoke file player"), TDEAboutData::License_GPL,
I18N_NOOP("(c) 1997,98,99,2000, Antonio Larrosa Jimenez"),"",
"http://perso.wanadoo.es/antlarr/tdemid.html");
aboutdata->addAuthor("Antonio Larrosa Jimenez",
I18N_NOOP("Original Developer/Maintainer"),"larrosa@kde.org",
"http://perso.wanadoo.es/antlarr/index.html");
return aboutdata;
}
TDEInstance *KMidFactory::instance()
{
if ( !s_instance )
s_instance = new TDEInstance( aboutData() );
return s_instance;
}
KMidPart::KMidPart(TQWidget *parentWidget, const char *widgetName,
TQObject *parent, const char *name)
: KParts::ReadOnlyPart(parent, name)
{
setInstance(KMidFactory::instance());
widget = new tdemidClient(parentWidget, actionCollection());
widget->show();
widget->setFocusPolicy(TQ_ClickFocus);
setWidget(widget);
// create and connect our actions
(void)new TDEAction(i18n("Play"), "player_play", 0, this,
TQT_SLOT(slotPlay()), actionCollection(),
"play");
(void)new TDEAction(i18n("Stop"), "player_stop", 0, this,
TQT_SLOT(slotStop()), actionCollection(),
"stop");
(void)new TDEAction(i18n("Backward"),
"2leftarrow", 0, this,
TQT_SLOT(slotBackward()), actionCollection(),
"backward");
(void)new TDEAction(i18n("Forward"),
"2rightarrow", 0, this,
TQT_SLOT(slotForward()), actionCollection(),
"forward");
m_extension = new KMidBrowserExtension(this);
setXMLFile("tdemid_partui.rc");
}
KMidPart::~KMidPart()
{
}
bool KMidPart::openFile()
{
widget->openURL(m_file);
widget->stop();
widget->show();
TQTimer::singleShot(2000, this, TQT_SLOT(slotPlay()));
return true;
}
bool KMidPart::closeURL()
{
slotStop();
return true;
}
void KMidPart::slotPlay()
{
widget->stop();
widget->play();
}
void KMidPart::slotStop()
{
widget->stop();
}
KMidBrowserExtension::KMidBrowserExtension(KMidPart *parent)
: KParts::BrowserExtension(parent, "KMidBrowserExtension")
{
}
KMidBrowserExtension::~KMidBrowserExtension()
{
}
#include "tdemid_part.moc"
|