mainwidget.h Example File
demos/spectrum/app/mainwidget.h
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
#include <QWidget>
#include <QIcon>
#include <QtMultimedia/qaudio.h>
class Engine;
class FrequencySpectrum;
class ProgressBar;
class Spectrograph;
class Waveform;
class LevelMeter;
class SettingsDialog;
class ToneGeneratorDialog;
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QPushButton)
QT_FORWARD_DECLARE_CLASS(QMenu)
QT_FORWARD_DECLARE_CLASS(QAction)
class MainWidget : public QWidget {
Q_OBJECT
public:
MainWidget(QWidget *parent = 0);
~MainWidget();
void timerEvent(QTimerEvent *event);
public slots:
void stateChanged(QAudio::Mode mode, QAudio::State state);
void formatChanged(const QAudioFormat &format);
void spectrumChanged(qint64 position, qint64 length,
const FrequencySpectrum &spectrum);
void infoMessage(const QString &message, int timeoutMs);
void errorMessage(const QString &heading, const QString &detail);
void audioPositionChanged(qint64 position);
void bufferLengthChanged(qint64 length);
private slots:
void showFileDialog();
void showSettingsDialog();
void showToneGeneratorDialog();
void initializeRecord();
void updateModeMenu();
void updateButtonStates();
private:
void createUi();
void createMenus();
void connectUi();
void reset();
enum Mode {
NoMode,
RecordMode,
GenerateToneMode,
LoadFileMode
};
void setMode(Mode mode);
private:
Mode m_mode;
Engine* m_engine;
#ifndef DISABLE_WAVEFORM
Waveform* m_waveform;
#endif
ProgressBar* m_progressBar;
Spectrograph* m_spectrograph;
LevelMeter* m_levelMeter;
QPushButton* m_modeButton;
QPushButton* m_recordButton;
QIcon m_recordIcon;
QPushButton* m_pauseButton;
QIcon m_pauseIcon;
QPushButton* m_playButton;
QIcon m_playIcon;
QPushButton* m_settingsButton;
QIcon m_settingsIcon;
QLabel* m_infoMessage;
int m_infoMessageTimerId;
SettingsDialog* m_settingsDialog;
ToneGeneratorDialog* m_toneGeneratorDialog;
QMenu* m_modeMenu;
QAction* m_loadFileAction;
QAction* m_generateToneAction;
QAction* m_recordAction;
};
#endif // MAINWIDGET_H