kalarm

sounddlg.h
1 /*
2  * sounddlg.h - sound file selection and configuration dialog
3  * Program: kalarm
4  * Copyright © 2005,2007,2008 by David Jarvie <djarvie@kde.org>
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 SOUNDDLG_H
22 #define SOUNDDLG_H
23 
24 #include <tqframe.h>
25 #include <tqstring.h>
26 #include <kdialogbase.h>
27 
28 class TQHBox;
29 class TQPushButton;
30 class KArtsDispatcher;
31 namespace KDE { class PlayObject; }
32 class LineEdit;
33 class PushButton;
34 class CheckBox;
35 class SpinBox;
36 class Slider;
37 
38 
39 class SoundDlg : public KDialogBase
40 {
41  TQ_OBJECT
42 
43  public:
44  SoundDlg(const TQString& file, float volume, float fadeVolume, int fadeSeconds, bool repeat,
45  const TQString& caption, TQWidget* parent, const char* name = 0);
46  ~SoundDlg();
47  void setReadOnly(bool);
48  bool isReadOnly() const { return mReadOnly; }
49  TQString getFile() const { return mFileName; }
50  bool getSettings(float& volume, float& fadeVolume, int& fadeSeconds) const;
51  TQString defaultDir() const { return mDefaultDir; }
52 
53  static TQString i18n_SetVolume(); // plain text of Set volume checkbox
54  static TQString i18n_v_SetVolume(); // text of Set volume checkbox, with 'V' shortcut
55  static TQString i18n_Repeat(); // plain text of Repeat checkbox
56  static TQString i18n_p_Repeat(); // text of Repeat checkbox, with 'P' shortcut
57 
58  protected:
59  virtual void showEvent(TQShowEvent*);
60  virtual void resizeEvent(TQResizeEvent*);
61 
62  protected slots:
63  virtual void slotOk();
64 
65  private slots:
66  void slotPickFile();
67  void slotVolumeToggled(bool on);
68  void slotFadeToggled(bool on);
69  void playSound();
70  void checkAudioPlay();
71 
72  private:
73  void stopPlay();
74  bool checkFile();
75 
76  TQPushButton* mFilePlay;
77  LineEdit* mFileEdit;
78  PushButton* mFileBrowseButton;
79  CheckBox* mRepeatCheckbox;
80  CheckBox* mVolumeCheckbox;
81  Slider* mVolumeSlider;
82  CheckBox* mFadeCheckbox;
83  TQHBox* mFadeBox;
84  SpinBox* mFadeTime;
85  TQHBox* mFadeVolumeBox;
86  Slider* mFadeSlider;
87  TQString mDefaultDir; // current default directory for mFileEdit
88  TQString mFileName;
89  bool mReadOnly;
90  // Sound file playing
91  KArtsDispatcher* mArtsDispatcher;
92  KDE::PlayObject* mPlayObject;
93  TQTimer* mPlayTimer; // timer for playing the sound file
94  TQString mLocalAudioFile; // local copy of audio file
95  bool mPlayStarted; // the sound file has started playing
96 };
97 
98 #endif