Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
[kdemultimedia.git] / kmid / kmidclient.h
blobd474ef8832aa92fd944827a3e3190654374ffd33
1 /**************************************************************************
3 kmidclient.h - The main client widget of KMid
4 Copyright (C) 1997,98 Antonio Larrosa Jimenez
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 Send comments and bug fixes to larrosa@kde.org
21 or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
23 ***************************************************************************/
24 #ifndef _KMIDCLIENT_H
25 #define _KMIDCLIENT_H
27 #include "qslidertime.h"
28 //Added by qt3to4:
29 #include <QLabel>
30 #include <libkmid/player.h>
31 #include <libkmid/track.h>
32 #include <libkmid/notearray.h>
33 #include <libkmid/libkmid.h>
34 #include <QTimer>
35 #include <unistd.h>
36 #include <sys/time.h>
37 #include <sys/types.h>
38 #include "kdisptext.h"
39 #include "slman.h"
40 #include "version.h"
42 #include <kio/job.h>
44 class DeviceManager;
47 class KApplication;
48 class KConfig;
49 class KLCDNumber;
50 class QLabel;
51 class QComboBox;
52 class RhythmView;
53 class ChannelView;
54 class QString;
56 class kmidClient : public QWidget
58 Q_OBJECT
59 private:
60 #ifdef KMidDEBUG
61 long passcount;
62 #endif
64 DeviceManager *midi;
65 MidiPlayer *player;
67 struct kMidData m_kMid;
69 QTimer *timer4timebar;
70 QTimer *timer4events;
72 ulong beginmillisec;
73 ulong pausedatmillisec;
74 double currentTempo;
75 SpecialEvent *spev;
76 NoteArray *noteArray;
78 bool downloaded;
80 int itsme;
81 bool shuttingdown;
82 int visiblevolumebar;
84 char *midifile_opened;
85 int hasbeenopened;
87 int typeoftextevents;
89 SLManager *slman;
90 int activecollection;
91 QString collectionsfile;
92 SongList *currentsl;
93 int initializing_songs;
94 int loopsong;
95 int collectionplaymode;
96 int *collectionplaylist; // the list of songs ordered in the
97 // user selected mode
99 class KActionCollection *actionCollection;
101 void generateCPL(void);
102 int searchInCPL(int song); // Returns the index of song
104 void fillInComboSongs(void);
106 int openFile(const char *filename);
107 void allNotesOff(void);
108 ulong timeOfNextEvent(int *type);
109 public:
110 kmidClient(QWidget *parent, KActionCollection *ac);
111 ~kmidClient();
113 char *midiFileName(void) {return midifile_opened;}
114 // If it returns NULL then there isn't any file opened
116 int isPlaying(void) {return m_kMid.pctl->playing;}
117 int isPaused(void) {return (m_kMid.pctl->playing)&&(m_kMid.pctl->paused);}
119 int openUrl(const QString s);
121 void repaintText(int typeoftextevents);
122 static void kmidOutput(void);
124 int ChooseTypeOfTextEvents(void);
126 QFont *getFont(void);
127 void fontChanged(void); // The new font is already in KConfig
129 SLManager *getSLManager(void) {return slman;}
130 void setSLManager(SLManager *slm);
131 // setSLManager only change the pointer, so DO NOT DELETE
132 // the objectr you pass to it
133 int getActiveCollection(void) {return activecollection;}
134 void setActiveCollection(int i);
135 int getSelectedSong(void);
136 void saveCollections(void);
138 void setSongType(int i);
139 void setSongLoop(int i);
140 void setCollectionPlayMode(int i);
142 void visibleVolumeBar(int i); // 1 shows it, and 0 hides it
143 // int isVisibleVolumeBar(void) {return visiblevolumebar;};
144 void visibleChannelView(int i);
146 void shuttingDown(void);
148 void rethinkNextEvent(void);
149 // Recalculates time of next event and updates the timer4events according to it
152 void moveEventPointersTo(ulong ms);
154 protected:
155 // void resizeEvent(QResizeEvent *qre);
158 public slots:
159 // void help_Help();
160 // void help_About();
161 void slotPlay();
162 void slotPause();
163 void slotStop();
164 void slotRewind();
165 void slotForward();
166 void slotPrevSong();
167 void slotNextSong();
169 void timebarUpdate();
170 void slotSeek(int i);
171 void slotSetVolume(int i);
172 void slotSelectSong(int i);
173 void slotSelectEncoding(int i);
175 void downloadFinished( KJob * );
177 void processSpecialEvent();
179 void channelViewDestroyed();
181 void communicationFromChannelView(int *);
183 void slotSetTempo(double value);
185 signals:
186 void mustRechooseTextEvent();
187 void stopPause();
188 // void channelView_Destroyed();
190 public:
191 void saveLyrics(FILE *fh);
193 DeviceManager *devman(void) {return midi;}
194 void setMidiDevice(int i);
195 void setMidiMapFilename(const char *mapfilename);
197 ChannelView *getChannelView(void) { return channelView; }
198 KDisplayText *getKDisplayText(void) { return kdispt; }
200 QSizePolicy sizePolicy();
202 QComboBox *getComboSongs() { return comboSongs; }
205 void play();
206 void pause();
207 void stop();
208 void rewind();
209 void forward();
210 void seek(int ms);
211 void prevSong();
212 void nextSong();
213 void setVolume(int i);
214 void setTempo(int i);
215 void setSongEncoding( int i );
216 void setLyricEvents( int i );
217 void setCurrentSong(int i);
218 void setPlayListMode(int i);
220 QSize sizeHint() const;
221 private:
222 QSlider *timebar;
223 QSliderTime *timetags;
224 QSlider *volumebar;
226 KLCDNumber *tempoLCD;
227 KDisplayText *kdispt;
228 QLabel *qlabelTempo;
229 QComboBox *comboSongs;
230 QComboBox *comboEncodings;
231 RhythmView *rhythmview;
234 ChannelView *channelView;
238 char *extractFilename(const char *in,char *out); // returns a pointer to out
240 #endif