The concept of local folders doesn't apply any more.
[kdepim.git] / kalarm / sounddlg.h
blobac8f4b11beee613acf915ad43bf6afaeab37bdcf
1 /*
2 * sounddlg.h - sound file selection and configuration dialog and widget
3 * Program: kalarm
4 * Copyright © 2005-2007,2009-2011 by David Jarvie <djarvie@kde.org>
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.
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.
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.
21 #ifndef SOUNDDLG_H
22 #define SOUNDDLG_H
24 #include <kurl.h>
25 #include <kdialog.h>
26 #include <QString>
28 class QPushButton;
29 class QShowEvent;
30 class QResizeEvent;
31 class KHBox;
32 namespace Phonon { class MediaObject; }
33 class GroupBox;
34 class PushButton;
35 class CheckBox;
36 class SpinBox;
37 class Slider;
38 class LineEdit;
41 class SoundWidget : public QWidget
43 Q_OBJECT
44 public:
45 SoundWidget(bool showPlay, bool showRepeat, QWidget* parent);
46 ~SoundWidget();
47 void set(const QString& file, float volume, float fadeVolume = -1, int fadeSeconds = 0, int repeatPause = -1);
48 void setReadOnly(bool);
49 bool isReadOnly() const { return mReadOnly; }
50 void setAllowEmptyFile() { mEmptyFileAllowed = true; }
51 QString fileName() const;
52 bool file(KUrl&, bool showErrorMessage = true) const;
53 void getVolume(float& volume, float& fadeVolume, int& fadeSeconds) const;
54 int repeatPause() const; // -1 if none, else seconds between repeats
55 QString defaultDir() const { return mDefaultDir; }
56 bool validate(bool showErrorMessage) const;
58 static QString i18n_chk_Repeat(); // text of Repeat checkbox
60 signals:
61 void changed(); // emitted whenever any contents change
63 protected:
64 virtual void showEvent(QShowEvent*);
65 virtual void resizeEvent(QResizeEvent*);
67 private slots:
68 void slotPickFile();
69 void slotVolumeToggled(bool on);
70 void slotFadeToggled(bool on);
71 void playSound();
72 void playFinished();
74 private:
75 QPushButton* mFilePlay;
76 LineEdit* mFileEdit;
77 PushButton* mFileBrowseButton;
78 GroupBox* mRepeatGroupBox;
79 SpinBox* mRepeatPause;
80 CheckBox* mVolumeCheckbox;
81 Slider* mVolumeSlider;
82 CheckBox* mFadeCheckbox;
83 KHBox* mFadeBox;
84 SpinBox* mFadeTime;
85 KHBox* mFadeVolumeBox;
86 Slider* mFadeSlider;
87 QString mDefaultDir; // current default directory for mFileEdit
88 mutable KUrl mUrl;
89 mutable QString mValidatedFile;
90 Phonon::MediaObject* mPlayer;
91 bool mReadOnly;
92 bool mEmptyFileAllowed;
96 class SoundDlg : public KDialog
98 Q_OBJECT
99 public:
100 SoundDlg(const QString& file, float volume, float fadeVolume, int fadeSeconds, int repeatPause,
101 const QString& caption, QWidget* parent);
102 void setReadOnly(bool);
103 bool isReadOnly() const { return mReadOnly; }
104 KUrl getFile() const;
105 void getVolume(float& volume, float& fadeVolume, int& fadeSeconds) const
106 { mSoundWidget->getVolume(volume, fadeVolume, fadeSeconds); }
107 int repeatPause() const { return mSoundWidget->repeatPause(); }
108 QString defaultDir() const { return mSoundWidget->defaultDir(); }
110 protected:
111 virtual void resizeEvent(QResizeEvent*);
113 protected slots:
114 virtual void slotButtonClicked(int button);
116 private:
117 SoundWidget* mSoundWidget;
118 bool mReadOnly;
121 #endif
123 // vim: et sw=4: