2 * sounddlg.h - sound file selection and configuration dialog and widget
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.
32 namespace Phonon
{ class MediaObject
; }
41 class SoundWidget
: public QWidget
45 SoundWidget(bool showPlay
, bool showRepeat
, QWidget
* parent
);
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
61 void changed(); // emitted whenever any contents change
64 virtual void showEvent(QShowEvent
*);
65 virtual void resizeEvent(QResizeEvent
*);
69 void slotVolumeToggled(bool on
);
70 void slotFadeToggled(bool on
);
75 QPushButton
* mFilePlay
;
77 PushButton
* mFileBrowseButton
;
78 GroupBox
* mRepeatGroupBox
;
79 SpinBox
* mRepeatPause
;
80 CheckBox
* mVolumeCheckbox
;
81 Slider
* mVolumeSlider
;
82 CheckBox
* mFadeCheckbox
;
85 KHBox
* mFadeVolumeBox
;
87 QString mDefaultDir
; // current default directory for mFileEdit
89 mutable QString mValidatedFile
;
90 Phonon::MediaObject
* mPlayer
;
92 bool mEmptyFileAllowed
;
96 class SoundDlg
: public KDialog
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(); }
111 virtual void resizeEvent(QResizeEvent
*);
114 virtual void slotButtonClicked(int button
);
117 SoundWidget
* mSoundWidget
;