SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / kalarm / sounddlg.h
blobe5c240b5be7f2114825f90437ab1f413d2bbc99c
1 /*
2 * sounddlg.h - sound file selection and configuration dialog and widget
3 * Program: kalarm
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.
21 #ifndef SOUNDDLG_H
22 #define SOUNDDLG_H
24 #include <QUrl>
25 #include <QDialog>
26 #include <QString>
28 class QPushButton;
29 class QShowEvent;
30 class QResizeEvent;
31 namespace Phonon { class MediaObject; }
32 class GroupBox;
33 class PushButton;
34 class CheckBox;
35 class SpinBox;
36 class Slider;
37 class LineEdit;
38 class QDialogButtonBox;
39 class QAbstractButton;
42 class SoundWidget : public QWidget
44 Q_OBJECT
45 public:
46 SoundWidget(bool showPlay, bool showRepeat, QWidget* parent);
47 ~SoundWidget();
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
61 Q_SIGNALS:
62 void changed(); // emitted whenever any contents change
64 protected:
65 void showEvent(QShowEvent*) Q_DECL_OVERRIDE;
66 void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
68 private Q_SLOTS:
69 void slotPickFile();
70 void slotVolumeToggled(bool on);
71 void slotFadeToggled(bool on);
72 void playSound();
73 void playFinished();
75 private:
76 static QString mDefaultDir; // current default directory for mFileEdit
77 QPushButton* mFilePlay;
78 LineEdit* mFileEdit;
79 PushButton* mFileBrowseButton;
80 GroupBox* mRepeatGroupBox;
81 SpinBox* mRepeatPause;
82 CheckBox* mVolumeCheckbox;
83 Slider* mVolumeSlider;
84 CheckBox* mFadeCheckbox;
85 QWidget* mFadeBox;
86 SpinBox* mFadeTime;
87 QWidget* mFadeVolumeBox;
88 Slider* mFadeSlider;
89 mutable QUrl mUrl;
90 mutable QString mValidatedFile;
91 Phonon::MediaObject* mPlayer;
92 bool mReadOnly;
93 bool mEmptyFileAllowed;
97 class SoundDlg : public QDialog
99 Q_OBJECT
100 public:
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(); }
111 protected:
112 void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
114 protected Q_SLOTS:
115 void slotButtonClicked(QAbstractButton *button);
117 private:
118 SoundWidget* mSoundWidget;
119 QDialogButtonBox *mButtonBox;
120 bool mReadOnly;
123 #endif
125 // vim: et sw=4: