summaryrefslogtreecommitdiffstats
path: root/noatun/library/noatun/app.h
blob: e337ddd978e7000a7374a7c8079d5f4de48f697a (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
#ifndef NOATUN_H
#define NOATUN_H

#include <kuniqueapplication.h>
#include <kdemacros.h>
class Playlist;
class Player;
class LibraryLoader;
class KPopupMenu;
class NoatunPreferences;
class Downloader;
class Effects;
class EffectView;
class Equalizer;
class KDialogBase;
class VEqualizer;

namespace NoatunStdAction
{
	class PluginActionMenu;
}

/**
 * @class NoatunApp app.h noatun/app.h
 * Can be accessed from every plugin by using "napp"
 *
 * @short Noatun Application class
 * @author Charles Samuels
 * @version 2.3
 */
class KDE_EXPORT NoatunApp : public KUniqueApplication
{
Q_OBJECT
  
friend class Playlist;

public:
	NoatunApp();
	~NoatunApp();

	/**
	 * Provides access to the central playlist object.
	 * Any plugin can access the noatun playlist with
	 * <pre>napp->playlist();</pre>
	 **/
	Playlist *playlist() const;
	/**
	 * access to the central player object
	 * Any plugin can access the noatun player backend with
	 * <pre>napp->playlist();</pre>
	 **/
	Player *player() const { return mPlayer; }
	/**
	 * access to NoatunPreferences
	 **/
	NoatunPreferences *preferencesBox() const { return mPref; }

	/**
	 * @return a list of mimetypes aRts (and thus Noatun) can play
	 * KFileDialog accepts this TQString instead of the shell globs in
	 * its static functions, make use of it :)
	 **/
	TQString mimeTypes();

	LibraryLoader *libraryLoader() const { return mLibraryLoader; }
	Downloader *downloader() const { return mDownloader; }
	static TQImage readPNG(const TQString &filename);
	Effects *effects() const;
	::Equalizer *equalizer() const { return mEqualizer; }
	::VEqualizer *vequalizer();
	KDialogBase *equalizerView() const { return mEqualizerView; }

	TQCString version() const;

	virtual void commitData(TQSessionManager &);
	virtual void saveState(TQSessionManager &);

	/**
	 * The three startup modes how noatun should behave when it is
	 * restarted.
	 *
	 * Restore - it can restore the player's last state
	 *
	 * Play - it automatically starts playing the next file in the
	 * playlist
	 *
	 * DontPlay - it doesn't start playing
	 */
	enum StartupPlayMode { Restore = 0, Play, DontPlay };

signals:
	/**
	 * Tells you (a UI plugin) to hide
	 */
	void hideYourself();

	/**
	 * Tells you (a UI plugin) to show again
	 */
	void showYourself();

public slots:
	/**
	 * ask the UIs to hide or show
	 **/
	void toggleInterfaces();
	/**
	 * ask the UIs to show
	 **/
	void showInterfaces();
	/**
	 * ask the UIs to hide, then you have
	 * to look around for them, or you'll lose
	 **/
	void hideInterfaces();

public: //options
	/**
	 * @deprecated Use startupPlayMode() instead
	 */
	bool autoPlay() const;
	int startupPlayMode() const;
	bool loopList() const;
	bool oneInstance() const;
	TQString saveDirectory() const;
	/**
	 * @deprecated
	 * now merged with clearOnOpen()
	 **/
	bool clearOnStart() const;
	/**
	 * @return true if the playlist will be cleared when opening a
	 * new file via commandline or file open dialog, false otherwise
	 **/
	bool clearOnOpen() const;
	bool hackUpPlaylist() const;
	/**
	 * @return true if hardware-mixing is being used, false in case
	 * software mixing is active
	 **/
	bool fastMixer() const;
	TQString titleFormat() const;
	/**
	 * @return true if remaining time is displayed to the user, false if
	 * played time is displayed
	 **/
	bool displayRemaining() const;

	void setOneInstance(bool);
	void setLoopList(bool);
	/**
	 * @deprecated Use setStartupPlayMode() instead
	 */
	void setAutoPlay(bool);
	void setStartupPlayMode(int mode);
	void setSaveDirectory(const TQString &);
	void setRememberPositions(bool);
	/**
	 * @deprecated
	 * now merged with setClearOnOpen()
	 **/
	void setClearOnStart(bool);
	/**
	 * Set if the playlist will be cleared when opening a
	 * new file via commandline or file open dialog
	 **/
	void setClearOnOpen(bool);
	void setHackUpPlaylist(bool);

	/**
	 * Set if hardware-mixing ("fast") or software-mixing ("slow") should be used
	 **/
	void setFastMixer(bool);

	void setTitleFormat(const TQString &);

	/**
	 * Pass true if remaining time should be displayed to the user, false if
	 * played time should be displayed
	 **/
	void setDisplayRemaining(bool);

	/**
	 * To insert items use KActions and insert() them into pluginActionMenu().
	 * @return pointer to the actionmenu
	 */
	NoatunStdAction::PluginActionMenu *pluginActionMenu();

	/**
	 * @deprecated
	 * Adds an item to the plugin menu.
	 * You may use this value with pluginMenu() for greater control of your menu entry
	 *
	 * @return the ID associated with the menu item, for use in pluginMenuRemove()
	 **/
	int pluginMenuAdd(const TQString &text, const TQObject *receiver, const char *member);

	/**
	 * @deprecated
	 * Removes an item previously added to the plugin menu.
	 * @param id the ID of the "to be removed" menu item
	 **/
	void pluginMenuRemove(int id);

	/**
	 * @deprecated
	 * Use pluginActionMenu() instead
	 * @return pointer to the plugin menu
	 */
	KPopupMenu *pluginMenu();

protected:
	virtual int newInstance();

public slots:
	// slots for the contextMenu
	/**
	 * Opens the preferences dialog
	 * You can also use
	 * <pre>napp->preferencesBox()->show()</pre>
	 * @see NoatunPreferences
	 */
	void preferences();
	/**
	 * Exits Noatun
	 */
	void quit();
	/**
	 * Shows the standard file-open dialog
	 */
	void fileOpen();
	/**
	 * Shows the effects window
	 */
	void effectView();
	/**
	 * Shows the equalizer window
	 */
	void equalizerView();

private:
	void loadPlugins();
	void saveEngineState();
	void restoreEngineState();

private:
	Player *mPlayer;
	LibraryLoader *mLibraryLoader;
	KPopupMenu *mPluginMenu;
	NoatunStdAction::PluginActionMenu *mPluginActionMenu;
	Downloader *mDownloader;
	struct Private;
	Private *d;
	EffectView *mEffectView;
	NoatunPreferences *mPref;
	::Equalizer *mEqualizer;
	KDialogBase *mEqualizerView;
	bool showingInterfaces;
};

#define napp (static_cast<NoatunApp*>(kapp))

// version info for the plugins
// this is MAJOR.MINOR.PATCHLEVEL
// and you developers better ignore patchlevel :)
#define NOATUN_MAJOR 2
#define NOATUN_MINOR 10
#define NOATUN_PATCHLEVEL 0

#define NOATUN_VERSION "2.10.0"

#endif