~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmid/kmid_part.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "kmid_part.h"
 
2
 
 
3
#include <kinstance.h>
 
4
#include <kiconloader.h>
 
5
#include <klocale.h>
 
6
#include <kaboutdata.h>
 
7
#include <kaction.h>
 
8
#include <qiconset.h>
 
9
 
 
10
#include <kparts/partmanager.h>
 
11
 
 
12
#include "kmidclient.h"
 
13
#include <qtimer.h>
 
14
 
 
15
extern "C"
 
16
{
 
17
  /**
 
18
   * This function is the 'main' function of this part.  It takes
 
19
   * the form 'void *init_lib<library name>()'.  It always returns a
 
20
   * new factory object
 
21
   */
 
22
  void *init_libkmidpart()
 
23
  {
 
24
    return new KMidFactory;
 
25
  }
 
26
};
 
27
 
 
28
/**
 
29
 * We need one static instance of the factory for our C 'main'
 
30
 * function
 
31
 */
 
32
KInstance *KMidFactory::s_instance = 0L;
 
33
 
 
34
KMidFactory::KMidFactory()
 
35
{
 
36
  s_instance=0L;
 
37
}
 
38
 
 
39
KMidFactory::~KMidFactory()
 
40
{
 
41
  if (s_instance)
 
42
  {
 
43
    delete s_instance->aboutData();
 
44
    delete s_instance;
 
45
  }
 
46
 
 
47
  s_instance = 0;
 
48
}
 
49
 
 
50
QObject *KMidFactory::create(QObject *parent, const char *name, const char*,
 
51
    const QStringList& )
 
52
{
 
53
  QObject *obj = new KMidPart((QWidget*)parent, name);
 
54
  emit objectCreated(obj);
 
55
  return obj;
 
56
}
 
57
 
 
58
KAboutData *KMidFactory::aboutData()
 
59
{
 
60
    KAboutData *aboutdata = new KAboutData("kmid", "KMid", "2.0",
 
61
        I18N_NOOP("MIDI/Karaoke file player"), KAboutData::License_GPL,
 
62
        I18N_NOOP("(C) 1997,98,99,2000, Antonio Larrosa Jimenez"),"",
 
63
        "http://perso.wanadoo.es/antlarr/kmid.html");
 
64
    aboutdata->addAuthor("Antonio Larrosa Jimenez",
 
65
        I18N_NOOP("Original Developer/Mantainer"),"larrosa@kde.org",
 
66
        "http://perso.wanadoo.es/antlarr/index.html");
 
67
    return aboutdata;
 
68
}
 
69
 
 
70
KInstance *KMidFactory::instance()
 
71
{
 
72
  if ( !s_instance )
 
73
    s_instance = new KInstance( aboutData() );
 
74
 
 
75
  return s_instance;
 
76
}
 
77
 
 
78
  KMidPart::KMidPart(QWidget *parent, const char *name)
 
79
: KParts::ReadOnlyPart(parent, name)
 
80
{
 
81
  setInstance(KMidFactory::instance());
 
82
 
 
83
  widget = new kmidClient(parent, actionCollection());
 
84
  widget->show();
 
85
  widget->setFocusPolicy(QWidget::ClickFocus);
 
86
  setWidget(widget);
 
87
 
 
88
  // create and connect our actions
 
89
   (void)new KAction(i18n("Play"), "1rightarrow", 0, this,
 
90
      SLOT(slotPlay()), actionCollection(),
 
91
      "play");
 
92
 
 
93
   (void)new KAction(i18n("Stop"), "player_stop", 0, this,
 
94
      SLOT(slotStop()), actionCollection(),
 
95
      "stop");
 
96
 
 
97
   (void)new KAction(i18n("Backward"),
 
98
      "2leftarrow", 0, this,
 
99
      SLOT(slotBackward()), actionCollection(),
 
100
      "backward");
 
101
 
 
102
   (void)new KAction(i18n("Forward"),
 
103
        "2rightarrow", 0, this,
 
104
      SLOT(slotForward()), actionCollection(),
 
105
      "forward");
 
106
 
 
107
  m_extension = new KMidBrowserExtension(this);
 
108
 
 
109
  setXMLFile("kmid_partui.rc");
 
110
 
 
111
 
 
112
}
 
113
 
 
114
KMidPart::~KMidPart()
 
115
{
 
116
}
 
117
 
 
118
bool KMidPart::openFile()
 
119
{
 
120
  widget->openURL(m_file);
 
121
  widget->stop();
 
122
  widget->show();
 
123
  QTimer::singleShot(2000, this, SLOT(slotPlay()));
 
124
 
 
125
  return true;
 
126
}
 
127
 
 
128
bool KMidPart::closeURL()
 
129
{
 
130
  slotStop();
 
131
  return true;
 
132
}
 
133
 
 
134
void KMidPart::slotPlay()
 
135
{
 
136
  widget->stop();
 
137
  widget->play();
 
138
}
 
139
 
 
140
 
 
141
void KMidPart::slotStop()
 
142
{
 
143
  widget->stop();
 
144
}
 
145
KMidBrowserExtension::KMidBrowserExtension(KMidPart *parent)
 
146
    : KParts::BrowserExtension(parent, "KMidBrowserExtension")
 
147
{
 
148
}
 
149
 
 
150
KMidBrowserExtension::~KMidBrowserExtension()
 
151
{
 
152
}
 
153
#include "kmid_part.moc"