kalarm

soundpicker.h
1 /*
2  * soundpicker.h - widget to select a sound file or a beep
3  * Program: kalarm
4  * Copyright © 2002,2004-2006 by David Jarvie <software@astrojar.org.uk>
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef SOUNDPICKER_H
22 #define SOUNDPICKER_H
23 
24 #include <tqframe.h>
25 #include <tqstring.h>
26 #include <kurl.h>
27 
28 class TQHBox;
29 class ComboBox;
30 class PushButton;
31 
32 
33 class SoundPicker : public TQFrame
34 {
35  TQ_OBJECT
36 
37  public:
44  enum Type { NONE = 0, BEEP, PLAY_FILE, SPEAK };
49  explicit SoundPicker(TQWidget* parent, const char* name = 0);
68  void set(Type type, const TQString& filename, float volume, float fadeVolume, int fadeSeconds, bool repeat);
70  bool isReadOnly() const { return mReadOnly; }
74  void setReadOnly(bool readOnly);
78  void showSpeak(bool show);
80  Type sound() const;
84  TQString file() const;
90  float volume(float& fadeVolume, int& fadeSeconds) const;
94  bool repeat() const;
96  TQString fileSetting() const { return mFile; }
98  bool repeatSetting() const { return mRepeat; }
107  static TQString browseFile(TQString& initialDir, const TQString& initialFile = TQString());
108 
109  static TQString i18n_Sound(); // plain text of Sound label
110  static TQString i18n_None(); // plain text of None combo box item
111  static TQString i18n_Beep(); // plain text of Beep combo box item
112  static TQString i18n_Speak(); // plain text of Speak combo box item
113  static TQString i18n_File(); // plain text of File combo box item
114 
115 
116  private slots:
117  void slotTypeSelected(int id);
118  void slotPickFile();
119 
120  private:
121 
122  ComboBox* mTypeCombo;
123  TQHBox* mTypeBox;
124  PushButton* mFilePicker;
125  TQString mDefaultDir;
126  TQString mFile; // sound file to play when alarm is triggered
127  float mVolume; // volume for file, or < 0 to not set volume
128  float mFadeVolume; // initial volume for file, or < 0 for no fading
129  int mFadeSeconds; // fade interval in seconds
130  Type mLastType; // last selected sound option
131  bool mSpeakShowing; // Speak option is shown in combo box
132  bool mRepeat; // repeat the sound file
133  bool mReadOnly;
134 };
135 
136 #endif // SOUNDPICKER_H