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
|
/*
* soundpicker.h - widget to select a sound file or a beep
* Program: kalarm
* Copyright © 2002,2004-2006 by David Jarvie <[email protected]>
*
* 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 SOUNDPICKER_H
#define SOUNDPICKER_H
#include <tqframe.h>
#include <tqstring.h>
#include <kurl.h>
class TQHBox;
class ComboBox;
class PushButton;
class SoundPicker : public QFrame
{
Q_OBJECT
public:
/** Sound options which can be selected for when the alarm is displayed.
* @li NONE - silence.
* @li BEEP - a beep will be sounded.
* @li PLAY_FILE - a sound file will be played.
* @li SPEAK - the message text will be spoken.
*/
enum Type { NONE = 0, BEEP, PLAY_FILE, SPEAK };
/** Constructor.
* @param parent The parent object of this widget.
* @param name The name of this widget.
*/
explicit SoundPicker(TQWidget* parent, const char* name = 0);
/** Initialises the widget's state.
* @param type The option to select.
* @param filename The full path or URL of the sound file to select. If the 'file' option is
* not initially selected, @p filename provides the default should 'file'
* later be selected by the user.
* @param volume The volume to play a sound file, or < 0 for no volume setting. If the
* 'file' option is not initially selected, @p volume provides the default
* should 'file' later be selected by the user.
* @param fadeVolume The initial volume to play a sound file if fading is to be used, or < 0
* for no fading. If the 'file' option is not initially selected, @p fadeVolume
* provides the default should 'file' later be selected by the user.
* @param fadeSeconds The number of seconds over which the sound file volume should be faded,
* or 0 for no fading. If the 'file' option is not initially selected,
* @p fadeSeconds provides the default should 'file' later be selected by the user.
* @param repeat True to play the sound file repeatedly. If the 'file' option is not initially
* selected, @p repeat provides the default should 'file' later be selected by
* the user.
*/
void set(Type type, const TQString& filename, float volume, float fadeVolume, int fadeSeconds, bool repeat);
/** Returns true if the widget is read only for the user. */
bool isReadOnly() const { return mReadOnly; }
/** Sets whether the widget can be changed the user.
* @param readOnly True to set the widget read-only, false to set it read-write.
*/
void setReadOnly(bool readOnly);
/** Show or hide the 'speak' option.
* If it is to be hidden and it is currently selected, sound is turned off.
*/
void showSpeak(bool show);
/** Returns the selected option. */
Type sound() const;
/** If the 'file' option is selected, returns the URL of the chosen file.
* Otherwise returns a null string.
*/
TQString file() const;
/** Returns the volume and fade characteristics for playing a sound file.
* @param fadeVolume Receives the initial volume if the volume is to be faded, else -1.
* @param fadeSeconds Receives the number of seconds over which the volume is to be faded, else 0.
* @return Volume to play the sound file, or < 0 if the 'file' option is not selected.
*/
float volume(float& fadeVolume, int& fadeSeconds) const;
/** Returns true if a sound file is to be played repeatedly.
* If the 'file' option is not selected, returns false.
*/
bool repeat() const;
/** Returns the current file URL regardless of whether the 'file' option is selected. */
TQString fileSetting() const { return mFile; }
/** Returns the current file repetition setting regardless of whether the 'file' option is selected. */
bool repeatSetting() const { return mRepeat; }
/** Display a dialogue to choose a sound file, initially highlighting
* @p initialFile if non-null.
* @param initialDir Initial directory to display if @p initialFile is null. If a file is
* chosen, this is updated to the directory containing the chosen file.
* @param initialFile Full path name or URL of file to be highlighted initially.
* If null, no file will be highlighted.
* @return URL selected, in human readable format. If none is selected, URL.isEmpty() is true.
*/
static TQString browseFile(TQString& initialDir, const TQString& initialFile = TQString::null);
static TQString i18n_Sound(); // plain text of Sound label
static TQString i18n_None(); // plain text of None combo box item
static TQString i18n_Beep(); // plain text of Beep combo box item
static TQString i18n_Speak(); // plain text of Speak combo box item
static TQString i18n_File(); // plain text of File combo box item
private slots:
void slotTypeSelected(int id);
void slotPickFile();
private:
ComboBox* mTypeCombo;
TQHBox* mTypeBox;
PushButton* mFilePicker;
TQString mDefaultDir;
TQString mFile; // sound file to play when alarm is triggered
float mVolume; // volume for file, or < 0 to not set volume
float mFadeVolume; // initial volume for file, or < 0 for no fading
int mFadeSeconds; // fade interval in seconds
Type mLastType; // last selected sound option
bool mSpeakShowing; // Speak option is shown in combo box
bool mRepeat; // repeat the sound file
bool mReadOnly;
};
#endif // SOUNDPICKER_H
|