193 lines
4.6 KiB
C++
193 lines
4.6 KiB
C++
#ifndef MAINWINDOW_H
|
||
#define MAINWINDOW_H
|
||
|
||
#include <QMainWindow>
|
||
#include "SerialConfig.h"
|
||
#include "serialportmanager.h"
|
||
#include <QSerialPort>
|
||
#include <QtCharts> // 引入所有QtCharts绘制的头文件,也可以单独引入某一个头文件
|
||
#include <QTimer>
|
||
#include <QMediaPlayer>
|
||
#include <QMouseEvent>
|
||
#include <QMessageBox>
|
||
#include <QResizeEvent>
|
||
|
||
QT_BEGIN_NAMESPACE
|
||
namespace Ui
|
||
{
|
||
class MainWindow;
|
||
}
|
||
QT_END_NAMESPACE
|
||
|
||
class MainWindow : public QMainWindow
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
MainWindow(QWidget *parent = nullptr);
|
||
~MainWindow();
|
||
void keyPressEvent(QKeyEvent *event)
|
||
{
|
||
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
|
||
{
|
||
|
||
QString barcode = barStr;
|
||
barStr.clear();
|
||
|
||
dispscan(barcode);
|
||
qDebug() << "Barcode scanned:" << barcode;
|
||
}
|
||
else
|
||
{
|
||
barStr += event->text();
|
||
qDebug() << " scanned:" << barStr;
|
||
}
|
||
}
|
||
void mousePressEvent(QMouseEvent *event)
|
||
{
|
||
// 关闭扫码提示标签
|
||
if (scanTipLabel != nullptr)
|
||
{
|
||
scanTipLabel->close();
|
||
scanTipLabel->deleteLater();
|
||
scanTipLabel = nullptr;
|
||
}
|
||
// 点击空白区域时,让主窗口获得焦点,确保扫码输入正常工作
|
||
this->setFocus();
|
||
QMainWindow::mousePressEvent(event);
|
||
}
|
||
void resizeEvent(QResizeEvent *event) override;
|
||
void dispscan(const QString barcode);
|
||
|
||
private slots:
|
||
void on_link_button_clicked();
|
||
|
||
void onLinkButtonClicked();
|
||
|
||
void on_manual_button_clicked();
|
||
|
||
void on_auto_button_clicked();
|
||
|
||
void on_excel_b_clicked();
|
||
|
||
void on_user_data_button_clicked_func();
|
||
|
||
void on_res_max_button_clicked_func();
|
||
|
||
void on_auto_value_button_clicked_func();
|
||
|
||
// void on_set_tx_button_clicked();
|
||
|
||
void on_nextPageButton_clicked();
|
||
|
||
void on_prevPageButton_clicked();
|
||
|
||
void auto_query();
|
||
|
||
void updateCharts();
|
||
|
||
void on_name_button_clicked_func();
|
||
|
||
void onExportSucceeded();
|
||
|
||
void onExportFailed(const QString &error);
|
||
|
||
void get_device_bj_info();
|
||
|
||
void on_pushButton_2_clicked();
|
||
|
||
void on_xc_button_clicked_func();
|
||
|
||
void playQualified();
|
||
|
||
void playUnqualified();
|
||
|
||
void playConnState_ok();
|
||
|
||
void playConnState_no();
|
||
|
||
void play_get_err();
|
||
|
||
void play_no_conn_res();
|
||
|
||
void handleDataRead(const QByteArray &data);
|
||
|
||
void on_delete_1_button_clicked_func();
|
||
|
||
void on_delete_2_button_clicked_func();
|
||
|
||
void on_pwd_button_clicked_func();
|
||
|
||
void onShowPasswordDialog();
|
||
|
||
void onPasswordAccepted();
|
||
|
||
private:
|
||
Ui::MainWindow *ui;
|
||
SerialPortManager *serialPortManager;
|
||
SerialConfig *serialConfigDialog;
|
||
QSerialPort *serialPort;
|
||
QTimer *timer;
|
||
QTimer *timer2;
|
||
QLabel *scanTipLabel = nullptr; // 扫码提示标签
|
||
QSize initialSize; // 初始窗口大小
|
||
QSize designSize; // UI设计基准尺寸
|
||
QPieSeries *pieSeries;
|
||
QMediaPlayer *player;
|
||
QString barStr;
|
||
QPushButton *senderButton;
|
||
|
||
QBarSet *set20;
|
||
QBarSet *set21;
|
||
QBarSet *set22;
|
||
QValueAxis *axisX2;
|
||
|
||
void disp_IIOT();
|
||
void disp_canshu();
|
||
|
||
int null_cnt = 0;
|
||
int serial_error = 0;
|
||
bool auto_mode = false; // 自动模式开关
|
||
QString auto_mode_flag;
|
||
|
||
int all_count; // 总检验次数
|
||
int auto_cnt; // 自动检验次数
|
||
int manual_cnt; // 手动检验次数
|
||
int qualified_cnt; // 合格次数
|
||
int up_cnt; // 超过范围次数
|
||
int down_cnt; // 小于范围次数
|
||
double res_value; // 电阻标准值
|
||
double res_sd; // 电阻误差范围
|
||
double max_res; // 最大电阻范围
|
||
double min_res; // 最小电阻范围
|
||
double xc_sd; // 线材阻值
|
||
int auto_time; // 自动获取时间
|
||
QString name; // 检验员
|
||
QString chexing; // 车型
|
||
QString sm_num; // 护面扫码编号
|
||
QString hot_num; // 加热垫扫码编号
|
||
QString pwd; // 密码
|
||
|
||
QString daily_date;
|
||
bool daily_one = true;
|
||
int daily_cnt = 0;
|
||
int daily_cnt_manual = 0;
|
||
int daily_qualified_cnt = 0;
|
||
int daily_cnt_over = 0;
|
||
int daily_cnt_down = 0;
|
||
double daily_cnt_max = 0;
|
||
double daily_cnt_min = 0;
|
||
double daily_qualified_l = 0;
|
||
|
||
QString detect;
|
||
int currentPage = 0;
|
||
int rowsPerPage = 21;
|
||
int totalRows = 0;
|
||
int old_totalRows = 0;
|
||
bool uppage = true;
|
||
int uppage_cnt = 0;
|
||
void updateTableWidget(const QVector<QVariantList> &data);
|
||
void get_one_data();
|
||
};
|
||
#endif // MAINWINDOW_H
|