source: trunk/demos/spectrum/app/mainwidget.h@ 769

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

File size: 4.6 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the examples of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:BSD$
10** You may use this file under the terms of the BSD license as follows:
11**
12** "Redistribution and use in source and binary forms, with or without
13** modification, are permitted provided that the following conditions are
14** met:
15** * Redistributions of source code must retain the above copyright
16** notice, this list of conditions and the following disclaimer.
17** * Redistributions in binary form must reproduce the above copyright
18** notice, this list of conditions and the following disclaimer in
19** the documentation and/or other materials provided with the
20** distribution.
21** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22** the names of its contributors may be used to endorse or promote
23** products derived from this software without specific prior written
24** permission.
25**
26** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef MAINWIDGET_H
42#define MAINWIDGET_H
43
44#include <QWidget>
45#include <QIcon>
46#include <QtMultimedia/qaudio.h>
47
48class Engine;
49class FrequencySpectrum;
50class ProgressBar;
51class Spectrograph;
52class Waveform;
53class LevelMeter;
54class SettingsDialog;
55class ToneGeneratorDialog;
56
57QT_FORWARD_DECLARE_CLASS(QAudioFormat)
58QT_FORWARD_DECLARE_CLASS(QLabel)
59QT_FORWARD_DECLARE_CLASS(QPushButton)
60QT_FORWARD_DECLARE_CLASS(QMenu)
61QT_FORWARD_DECLARE_CLASS(QAction)
62
63/**
64 * Main application widget, responsible for connecting the various UI
65 * elements to the Engine.
66 */
67class MainWidget : public QWidget {
68 Q_OBJECT
69public:
70 MainWidget(QWidget *parent = 0);
71 ~MainWidget();
72
73 // QObject
74 void timerEvent(QTimerEvent *event);
75
76public slots:
77 void stateChanged(QAudio::Mode mode, QAudio::State state);
78 void formatChanged(const QAudioFormat &format);
79 void spectrumChanged(qint64 position, qint64 length,
80 const FrequencySpectrum &spectrum);
81 void infoMessage(const QString &message, int timeoutMs);
82 void errorMessage(const QString &heading, const QString &detail);
83 void positionChanged(qint64 position);
84 void bufferDurationChanged(qint64 duration);
85
86private slots:
87 void showFileDialog();
88 void showSettingsDialog();
89 void showToneGeneratorDialog();
90 void initializeRecord();
91 void dataDurationChanged(qint64 duration);
92
93private:
94 void createUi();
95 void createMenus();
96 void connectUi();
97 void updateButtonStates();
98 void reset();
99
100 enum Mode {
101 NoMode,
102 RecordMode,
103 GenerateToneMode,
104 LoadFileMode
105 };
106
107 void setMode(Mode mode);
108
109private:
110 Mode m_mode;
111
112 Engine* m_engine;
113
114 Waveform* m_waveform;
115 ProgressBar* m_progressBar;
116 Spectrograph* m_spectrograph;
117 LevelMeter* m_levelMeter;
118
119 QPushButton* m_modeButton;
120 QPushButton* m_recordButton;
121 QIcon m_recordIcon;
122 QPushButton* m_pauseButton;
123 QIcon m_pauseIcon;
124 QPushButton* m_playButton;
125 QIcon m_playIcon;
126 QPushButton* m_settingsButton;
127 QIcon m_settingsIcon;
128
129 QLabel* m_infoMessage;
130 int m_infoMessageTimerId;
131
132 SettingsDialog* m_settingsDialog;
133 ToneGeneratorDialog* m_toneGeneratorDialog;
134
135 QMenu* m_modeMenu;
136 QAction* m_loadFileAction;
137 QAction* m_generateToneAction;
138 QAction* m_recordAction;
139
140};
141
142#endif // MAINWIDGET_H
Note: See TracBrowser for help on using the repository browser.