kalarm

soundpicker.h
00001 /*
00002  *  soundpicker.h  -  widget to select a sound file or a beep
00003  *  Program:  kalarm
00004  *  Copyright © 2002,2004-2006 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef SOUNDPICKER_H
00022 #define SOUNDPICKER_H
00023 
00024 #include <tqframe.h>
00025 #include <tqstring.h>
00026 #include <kurl.h>
00027 
00028 class TQHBox;
00029 class ComboBox;
00030 class PushButton;
00031 
00032 
00033 class SoundPicker : public TQFrame
00034 {
00035         Q_OBJECT
00036   TQ_OBJECT
00037     public:
00044         enum Type { NONE = 0, BEEP, PLAY_FILE, SPEAK };
00049         explicit SoundPicker(TQWidget* parent, const char* name = 0);
00068         void           set(Type type, const TQString& filename, float volume, float fadeVolume, int fadeSeconds, bool repeat);
00070         bool           isReadOnly() const          { return mReadOnly; }
00074         void           setReadOnly(bool readOnly);
00078         void           showSpeak(bool show);
00080         Type           sound() const;
00084         TQString        file() const;
00090         float          volume(float& fadeVolume, int& fadeSeconds) const;
00094         bool           repeat() const;
00096         TQString        fileSetting() const   { return mFile; }
00098         bool           repeatSetting() const { return mRepeat; }
00107         static TQString browseFile(TQString& initialDir, const TQString& initialFile = TQString());
00108 
00109         static TQString i18n_Sound();       // plain text of Sound label
00110         static TQString i18n_None();        // plain text of None combo box item
00111         static TQString i18n_Beep();        // plain text of Beep combo box item
00112         static TQString i18n_Speak();       // plain text of Speak combo box item
00113         static TQString i18n_File();        // plain text of File combo box item
00114 
00115 
00116     private slots:
00117         void           slotTypeSelected(int id);
00118         void           slotPickFile();
00119 
00120     private:
00121 
00122         ComboBox*      mTypeCombo;
00123         TQHBox*         mTypeBox;
00124         PushButton*    mFilePicker;
00125         TQString        mDefaultDir;
00126         TQString        mFile;         // sound file to play when alarm is triggered
00127         float          mVolume;       // volume for file, or < 0 to not set volume
00128         float          mFadeVolume;   // initial volume for file, or < 0 for no fading
00129         int            mFadeSeconds;  // fade interval in seconds
00130         Type           mLastType;     // last selected sound option
00131         bool           mSpeakShowing; // Speak option is shown in combo box
00132         bool           mRepeat;       // repeat the sound file
00133         bool           mReadOnly;
00134 };
00135 
00136 #endif // SOUNDPICKER_H