2 * sounddlg.h - sound file selection and configuration dialog and widget
4 * Copyright © 2005-2007,2009-2012 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.
31 namespace Phonon
{ class MediaObject
; }
38 class QDialogButtonBox
;
39 class QAbstractButton
;
42 class SoundWidget
: public QWidget
46 SoundWidget(bool showPlay
, bool showRepeat
, QWidget
* parent
);
48 void set(const QString
& file
, float volume
, float fadeVolume
= -1, int fadeSeconds
= 0, int repeatPause
= -1);
49 void setReadOnly(bool);
50 bool isReadOnly() const { return mReadOnly
; }
51 void setAllowEmptyFile() { mEmptyFileAllowed
= true; }
52 QString
fileName() const;
53 bool file(QUrl
&, bool showErrorMessage
= true) const;
54 void getVolume(float& volume
, float& fadeVolume
, int& fadeSeconds
) const;
55 int repeatPause() const; // -1 if none, else seconds between repeats
56 QString
defaultDir() const { return mDefaultDir
; }
57 bool validate(bool showErrorMessage
) const;
59 static QString
i18n_chk_Repeat(); // text of Repeat checkbox
62 void changed(); // emitted whenever any contents change
65 void showEvent(QShowEvent
*) Q_DECL_OVERRIDE
;
66 void resizeEvent(QResizeEvent
*) Q_DECL_OVERRIDE
;
70 void slotVolumeToggled(bool on
);
71 void slotFadeToggled(bool on
);
76 static QString mDefaultDir
; // current default directory for mFileEdit
77 QPushButton
* mFilePlay
;
79 PushButton
* mFileBrowseButton
;
80 GroupBox
* mRepeatGroupBox
;
81 SpinBox
* mRepeatPause
;
82 CheckBox
* mVolumeCheckbox
;
83 Slider
* mVolumeSlider
;
84 CheckBox
* mFadeCheckbox
;
87 QWidget
* mFadeVolumeBox
;
90 mutable QString mValidatedFile
;
91 Phonon::MediaObject
* mPlayer
;
93 bool mEmptyFileAllowed
;
97 class SoundDlg
: public QDialog
101 SoundDlg(const QString
& file
, float volume
, float fadeVolume
, int fadeSeconds
, int repeatPause
,
102 const QString
& caption
, QWidget
* parent
);
103 void setReadOnly(bool);
104 bool isReadOnly() const { return mReadOnly
; }
105 QUrl
getFile() const;
106 void getVolume(float& volume
, float& fadeVolume
, int& fadeSeconds
) const
107 { mSoundWidget
->getVolume(volume
, fadeVolume
, fadeSeconds
); }
108 int repeatPause() const { return mSoundWidget
->repeatPause(); }
109 QString
defaultDir() const { return mSoundWidget
->defaultDir(); }
112 void resizeEvent(QResizeEvent
*) Q_DECL_OVERRIDE
;
115 void slotButtonClicked(QAbstractButton
*button
);
118 SoundWidget
* mSoundWidget
;
119 QDialogButtonBox
*mButtonBox
;