summaryrefslogtreecommitdiffstats
path: root/kaffeine/src/input/audiobrowser/playlist.h
blob: 021d60d5df20572871d0e2f4a627e66a55c4bc19 (plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/*
 * playlist.h
 *
 * Copyright (C) 2003-2005 Jürgen Kofler <kaffeine@gmx.net>
 * Copyright (C) 2005-2006 Christophe Thommeret <hftom@free.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */

#ifndef PLAYLIST_H
#define PLAYLIST_H

#include <kdialogbase.h>
#include <kdiroperator.h>
#include <tdefileiconview.h>
#include <kaction.h>
#include <kstdaction.h>

#include <tqwidget.h>
#include <tqptrlist.h>
#include <tqvbox.h>
#include <tqsplitter.h>
#include <tqpainter.h>
#include <tqtoolbutton.h>

#include "urllistview.h"
#include "kaffeineinput.h"

class UrlListView;
class MRL;
class KURL;
class TQListViewItem;
class TQString;
class TQLabel;
class TQColor;
class TQDropEvent;
class TQPixmap;
class KLineEdit;
class KComboBox;
class KURLComboBox;
class TDEConfig;
class KPushButton;
class GoogleFetcher;



class GalleryDialog : public KDialogBase
{
	Q_OBJECT
  
public:
	GalleryDialog( TQWidget *parent, GoogleFetcher *goog );
protected slots:
	void slotOk();
	void slotNext();
private:
	TQFrame *imageFrame;
	GoogleFetcher *google;
	TQTimer next;
	TQHBox *hbox;
};



class RollTitle : public TQLabel
{
	Q_OBJECT
  

public:
	RollTitle( TQWidget *parent );
	void setTitle( MRL mrl );

private:
	void setTitle( TQString t );
	TQTimer titleTimer;
	TQPixmap titlePix;
	TQColor back, fore;
	int titleOffset;
	TQString title;

protected:
	void paintEvent ( TQPaintEvent * );

private slots:
	void rollTitle();
};



class CoverFrame : public TQFrame
{
	Q_OBJECT
  

public:
	CoverFrame( TQWidget *parent );
	~CoverFrame();
	void setCoverPixmap( const TQString &path );

protected:
	void mousePressEvent( TQMouseEvent *e );

private:
	void popup( const TQPixmap &pix ) const;
	TQString imagePath;
	TQPixmap noCoverPix;

signals:
	void changeCurrentCover();
	void gallery();
};



class PlayList : public KaffeineInput
{
	Q_OBJECT
  

public:
	PlayList(TQWidget *parent, TQObject *objParent, const char *name=0);
	~PlayList();

	// Reimplemented from KaffeineInput
public:
	TQWidget *wantPlayerWindow();
	TQWidget *inputMainWidget();
	void mergeMeta(const MRL&);
	bool nextTrack( MRL& );
	bool previousTrack( MRL& );
	bool currentTrack( MRL& );
	bool trackNumber( int, MRL& );
	bool playbackFinished( MRL& );
	void getTargets( TQStringList &uiNames, TQStringList &iconNames, TQStringList &targetNames );
	void togglePanel();
	bool execTarget( const TQString& );
	void saveConfig();
	bool showPlayer() {return !m_showPlayer->isChecked();}
	//***************************************

public:
	MRL getCurrent();  /* get current playlist entry */
	MRL getNext();
	MRL getEntryWithNumber(int number);
	void setCurrentEntry(TQListViewItem*, bool playIcon = true);

	TQListViewItem* getLast();
	TQListViewItem* getFirst();
	TQListViewItem* findByURL(const TQString&);

	/* insert a KURL(list) after a specific item */
	void add(const TQString& url, TQListViewItem* after);
	void add(const TQStringList& urls, TQListViewItem* after);
	void add(const TQValueList<MRL>&, TQListViewItem* after);

	bool isQueueMode() { return m_queue.count(); }

	void setPlaylist(const TQString& name, bool clear = false);
	void nextPlaylist();
	void removeCurrentPlaylist();
	void saveCurrentPlaylist();
	TQString queryCurrentPlaylist();
	void loadConfig(TDEConfig*);
	void saveConfig(TDEConfig*);
	void clearList();

	void setEndless(bool);
	void setRandom(bool);

	void useAlternateEncoding(bool);
	void setAlternateEncoding(const TQString&);

	void setFileFilter(const TQString& filter);
	void savePlaylist(const TQString&);
	void loadPlaylist(const TQString&);

	void exportM3UPlaylist(const TQString&);
	void exportPLSPlaylist(const TQString&);

	const bool getReadMetaOnLoading() const { return m_metaOnLoading; }

	TQVBox *mainWidget;
	TQVBox *playerBox;

public slots:
	void slotToggleShuffle();

protected:
	void closeEvent(TQCloseEvent*);

private slots:
	void slotNewList();
	void slotSetReadMetaOnLoading(bool read) { m_metaOnLoading = read; }
	void slotSetAlternateColor(const TQColor&);
	void slotPlayDirect(TQListViewItem* item);  /* doubleclick */
	void slotDropEvent(TQDropEvent*, TQListViewItem*);
	void slotPreDropEvent();
	void slotCut();
	void slotPaste();
	void slotCopy();
	void slotSelectAll();
	void slotPlaylistFromSelected();
	void slotAddToQueue(MRL);
	void slotRemoveSelected();
	void slotFindText(const TQString&);
	void slotSort(int);
	void slotPlaylistActivated(int);
	void slotNewPlaylistName(const TQString&);
	void slotRepeat();
	void slotShuffle();
	void slotAutoCover();
	void slotShowPlayer();
	void slotPlaylistLoad();
	void slotPlaylistSaveAs();
	void slotPlaylistRemove();
	void setCover( TQString s1, TQString s2, bool forceFetch=false );
	void chooseCurrentCover();
	void showGallery();
	void startPlaylist();
	void fileSelected( const KFileItem* );
	void setBrowserURL( const TQString& );
	void setBrowserURL( const KURL& );
	void browserURLChanged( const KURL& );
	void slotClearList();
	void resetSearch();

private:
	TQListViewItem* insertItem(TQListViewItem* after, const MRL&);
	void updateStatus();
	void createRandomList();
	void getMetaInfo(MRL& mrl, const TQString& mimeName);
	void setupActions();
	/* helpers */
	static TQString msToTimeString(int);
	static int timeStringToMs(const TQString&);
	static bool endsWith(TQString, TQString, bool);
	static bool startsWith(TQString, TQString, bool);

private:
	TQColor m_altCol;
	KComboBox* m_playlistSelector;
	TQToolButton *searchBtn;
	KLineEdit* m_playlistFilter;
	int m_nextPlaylistNumber;
	TQString m_playlistDirectory;
	int m_currentPlaylist;
	KURLComboBox *browserComb;

	TQSplitter *hSplit, *vSplit;
	TQVBox *panel;
	TQWidget *playlist;
	KDirOperator *fileBrowser;
	KFileIconView *view;
	CoverFrame *coverFrame;
	GoogleFetcher *google;
	TQString coverImageFormat;
	RollTitle *roller;

	KToggleAction *m_repeat, *m_shuffle, *m_autoCover, *m_showPlayer;

	TQValueList<MRL> m_queue;

	uint m_playTime;
	uint m_playTimeVisible;
	uint m_countVisible;

	bool m_searchSelection;
	bool m_metaOnLoading;
	bool m_sortAscending;

	UrlListView* m_list;
	TQListViewItem* m_currentEntry;
	MRL m_currentEntryMRL;

	TQString m_fileFilter;
	TQString m_metaInfoString;
	TQString m_lastPlaylist;

	TQPtrList<TQListViewItem> m_randomList;
	int m_currentRandomListEntry;

	TQPixmap m_isCurrentEntry;
	TQPixmap m_cdPixmap;

	bool m_endless;
	bool m_random;
	bool m_cover;

	bool m_useAlternateEncoding;
	TQString m_alternateEncoding;

signals:
	void signalRequestForAudioCD(const TQString&);
	void signalRequestForDVD(const TQString&);
	void signalRequestForVCD(const TQString&);
};

class TQListBox;
class TQStringList;

class SubtitleChooser : public KDialogBase
{
	Q_OBJECT
  
public:
	SubtitleChooser(TQStringList, TQString, TQWidget *parent=0, const char *name = 0);
	virtual ~SubtitleChooser();

	TQString getSelection();

private:
	TQListBox *table;
};

class MovieChooser : public KDialogBase
{
	Q_OBJECT
  
public:
	MovieChooser(TQStringList, TQString, TQWidget *parent=0, const char *name = 0);
	virtual ~MovieChooser();

	TQString getSelection();

private:
	TQListBox *table;
};

#endif /* PLAYLIST_H */