RecordControlApplication/Widget.h

92 lines
1.7 KiB
C++

#ifndef WIDG_H
#define WIDG_H
#include "Menu.h"
#include "ProgressBar.h"
#include <QDebug>
#include <QDir>
#include <QMap>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTimer>
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget {
Q_OBJECT
enum Command {
Playback,
Next,
Previous,
Forward,
Back,
Pause,
Return,
Enter
};
public:
explicit Widget(QWidget* parent = 0);
~Widget();
public slots:
void showPlayList();
private slots:
void onSerialError(QSerialPort::SerialPortError error);
void onTimeout();
void onReadyRead();
void onProgressTimeout();
void onPlayEnd();
void onSignalInputed(QString name, int width, int height);
private:
Ui::Widget* ui;
QStringList fileList;
QTimer* timer;
QSerialPort* serialPort;
QMap<QString, Command> commandMap;
QTimer* progressTimer;
bool isPlayback = false;
QString curPlayChannel;
QString curSelectChannel;
QString curFileName;
Menu* menu;
ProgressBar* progressBar;
private:
void initSerialPort();
void initCommandMap();
inline QStringList getFileList(QString dirPath);
};
/**
* @brief get all files of cur channel
* @param path
* @return
*/
inline QStringList Widget::getFileList(QString dirPath)
{
QStringList fileList;
QDir dir(dirPath);
if (!dir.exists()) {
qDebug() << dirPath << "do not exist";
return fileList;
}
dir.setFilter(QDir::Files);
dir.setSorting(QDir::Name);
QStringList nameFilters;
nameFilters << "*.mp4";
dir.setNameFilters(nameFilters);
fileList = dir.entryList();
return fileList;
}
#endif // WIDG_H