kalarm

sounddlg.h
00001 /*
00002  *  sounddlg.h  -  sound file selection and configuration dialog
00003  *  Program:  kalarm
00004  *  Copyright © 2005,2007,2008 by David Jarvie <djarvie@kde.org>
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 SOUNDDLG_H
00022 #define SOUNDDLG_H
00023 
00024 #include <tqframe.h>
00025 #include <tqstring.h>
00026 #include <kdialogbase.h>
00027 
00028 class TQHBox;
00029 class TQPushButton;
00030 class KArtsDispatcher;
00031 namespace KDE { class PlayObject; }
00032 class LineEdit;
00033 class PushButton;
00034 class CheckBox;
00035 class SpinBox;
00036 class Slider;
00037 
00038 
00039 class SoundDlg : public KDialogBase
00040 {
00041         Q_OBJECT
00042   TQ_OBJECT
00043     public:
00044         SoundDlg(const TQString& file, float volume, float fadeVolume, int fadeSeconds, bool repeat,
00045                  const TQString& caption, TQWidget* parent, const char* name = 0);
00046         ~SoundDlg();
00047         void           setReadOnly(bool);
00048         bool           isReadOnly() const    { return mReadOnly; }
00049         TQString        getFile() const       { return mFileName; }
00050         bool           getSettings(float& volume, float& fadeVolume, int& fadeSeconds) const;
00051         TQString        defaultDir() const    { return mDefaultDir; }
00052 
00053         static TQString i18n_SetVolume();   // plain text of Set volume checkbox
00054         static TQString i18n_v_SetVolume(); // text of Set volume checkbox, with 'V' shortcut
00055         static TQString i18n_Repeat();      // plain text of Repeat checkbox
00056         static TQString i18n_p_Repeat();    // text of Repeat checkbox, with 'P' shortcut
00057 
00058     protected:
00059         virtual void   showEvent(TQShowEvent*);
00060         virtual void   resizeEvent(TQResizeEvent*);
00061 
00062     protected slots:
00063         virtual void   slotOk();
00064 
00065     private slots:
00066         void           slotPickFile();
00067         void           slotVolumeToggled(bool on);
00068         void           slotFadeToggled(bool on);
00069         void           playSound();
00070         void           checkAudioPlay();
00071 
00072     private:
00073         void           stopPlay();
00074         bool           checkFile();
00075 
00076         TQPushButton*   mFilePlay;
00077         LineEdit*      mFileEdit;
00078         PushButton*    mFileBrowseButton;
00079         CheckBox*      mRepeatCheckbox;
00080         CheckBox*      mVolumeCheckbox;
00081         Slider*        mVolumeSlider;
00082         CheckBox*      mFadeCheckbox;
00083         TQHBox*         mFadeBox;
00084         SpinBox*       mFadeTime;
00085         TQHBox*         mFadeVolumeBox;
00086         Slider*        mFadeSlider;
00087         TQString        mDefaultDir;     // current default directory for mFileEdit
00088         TQString        mFileName;
00089         bool           mReadOnly;
00090         // Sound file playing
00091         KArtsDispatcher* mArtsDispatcher;
00092         KDE::PlayObject* mPlayObject;
00093         TQTimer*          mPlayTimer;       // timer for playing the sound file
00094         TQString          mLocalAudioFile;  // local copy of audio file
00095         bool             mPlayStarted;      // the sound file has started playing
00096 };
00097 
00098 #endif