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 <qframe.h>
00025 #include <qstring.h>
00026 #include <kdialogbase.h>
00027 
00028 class QHBox;
00029 class QPushButton;
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     public:
00043         SoundDlg(const QString& file, float volume, float fadeVolume, int fadeSeconds, bool repeat,
00044                  const QString& caption, QWidget* parent, const char* name = 0);
00045         ~SoundDlg();
00046         void           setReadOnly(bool);
00047         bool           isReadOnly() const    { return mReadOnly; }
00048         QString        getFile() const       { return mFileName; }
00049         bool           getSettings(float& volume, float& fadeVolume, int& fadeSeconds) const;
00050         QString        defaultDir() const    { return mDefaultDir; }
00051 
00052         static QString i18n_SetVolume();   // plain text of Set volume checkbox
00053         static QString i18n_v_SetVolume(); // text of Set volume checkbox, with 'V' shortcut
00054         static QString i18n_Repeat();      // plain text of Repeat checkbox
00055         static QString i18n_p_Repeat();    // text of Repeat checkbox, with 'P' shortcut
00056 
00057     protected:
00058         virtual void   showEvent(QShowEvent*);
00059         virtual void   resizeEvent(QResizeEvent*);
00060 
00061     protected slots:
00062         virtual void   slotOk();
00063 
00064     private slots:
00065         void           slotPickFile();
00066         void           slotVolumeToggled(bool on);
00067         void           slotFadeToggled(bool on);
00068         void           playSound();
00069         void           checkAudioPlay();
00070 
00071     private:
00072         void           stopPlay();
00073         bool           checkFile();
00074 
00075         QPushButton*   mFilePlay;
00076         LineEdit*      mFileEdit;
00077         PushButton*    mFileBrowseButton;
00078         CheckBox*      mRepeatCheckbox;
00079         CheckBox*      mVolumeCheckbox;
00080         Slider*        mVolumeSlider;
00081         CheckBox*      mFadeCheckbox;
00082         QHBox*         mFadeBox;
00083         SpinBox*       mFadeTime;
00084         QHBox*         mFadeVolumeBox;
00085         Slider*        mFadeSlider;
00086         QString        mDefaultDir;     // current default directory for mFileEdit
00087         QString        mFileName;
00088         bool           mReadOnly;
00089         // Sound file playing
00090         KArtsDispatcher* mArtsDispatcher;
00091         KDE::PlayObject* mPlayObject;
00092         QTimer*          mPlayTimer;       // timer for playing the sound file
00093         QString          mLocalAudioFile;  // local copy of audio file
00094         bool             mPlayStarted;      // the sound file has started playing
00095 };
00096 
00097 #endif