#pragma execution_character_set("utf-8") #include "TmsKey.h" #include "ui_TmsKey.h" #include #include #include #include // 自适应分辨率 #include #include // 设备管理 #include "device/DeviceManager.h" // 日志 #include "logger/Logger.h" #include "logger/LogManager.h" // 特性 - 取字节序 #include "Utils.h" // 基础设置和高级设置tab页及设置服务 #include "BaseSetupWidget.h" #include "AdvanceSetupWidget.h" #include "SetupService.h" #include #include "auth/Auth.h" #include // 系统屏幕分辨率 -- 可用窗口大小,去除了任务栏高度 int gAvailableScreenWidth = 0; int gAvailableScreenHeight = 0; // 实际屏幕分辨率 int gScreenWidth = 0; int gScreenHeight = 0; // 屏幕个数 int gScreenCount = 0; // dpi // 100% - 96 // 125% - 120 // 150% - 144 // 175% - 168 qreal gDotsPerInch = 0; qreal gDotsPerInchX = 0; qreal gDotsPerInchY = 0; double gZoomValue = 0.0; unsigned char m_currType; // 当前类型 void GetScreenInfo5() { QScreen *screen=QGuiApplication::primaryScreen(); QRect mm = screen->availableGeometry(); gAvailableScreenWidth = mm.width(); gAvailableScreenHeight = mm.height(); gDotsPerInch = screen->logicalDotsPerInch(); gDotsPerInchX = screen->logicalDotsPerInchX(); gDotsPerInchY = screen->logicalDotsPerInchY(); } void GetScreenInfo4() { QDesktopWidget* desktopWidget = QApplication::desktop(); //获取设备屏幕大小 QRect screenRect = desktopWidget->screenGeometry(); gScreenWidth = screenRect.width(); gScreenHeight = screenRect.height(); //获取可用桌面大小 //QRect deskRect = desktopWidget->availableGeometry(); //g_nActScreenX = deskRect.width(); //g_nActScreenY = deskRect.height(); //获取系统设置的屏幕个数(屏幕拷贝方式该值为1) gScreenCount = desktopWidget->screenCount(); } // 获取放大倍数 double GetZoomValue() { QScreen *screen=QGuiApplication::primaryScreen(); qreal dotsPerInch = screen->logicalDotsPerInch(); double zoonValue = dotsPerInch / 96; if(zoonValue < 1.1999999999) { zoonValue = 1.0; } else if(zoonValue < 1.4999999999) { zoonValue = 1.2; } else if(zoonValue < 1.9999999999) { zoonValue = 1.5; } else if(zoonValue < 2.4999999999) { zoonValue = 2.0; } else if(zoonValue < 2.9999999999) { zoonValue = 2.5; } else if(zoonValue < 3.4999999999) { zoonValue = 3.0; } else if(zoonValue < 3.9999999999) { zoonValue = 3.5; } else { zoonValue = 4.0; } return zoonValue; } /* **************************************** * * 构造/析构函数 * * ***************************************** */ // // 构造函数 // Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) // , m_bOpen(false) , m_bAuthority(false) // , m_sysStatus(SYS_STATUS_IDLE) // , m_recordFlag(false) // , m_recordAllCount(0) // , m_recordCurrCount(0) , m_cfgFileName("tmskey.cfg") { ui->setupUi(this); #ifdef USE_AUTH // 读取配置文件 if(!Auth::GetInstance()->readFile()) { QMessageBox::warning(this, "错误", "程序授权异常!\nAuthorization Exception!", QMessageBox::Ok, QMessageBox::Ok); exit(-1); } //QMessageBox::warning(this, "Warning", QString::fromStdString(Auth::GetInstance()->toMessage()), QMessageBox::Ok, QMessageBox::Ok); if(!Auth::GetInstance()->bIsValidate()) { QMessageBox::warning(this, "错误", "程序授权异常!\nAuthorization Exception!", QMessageBox::Ok, QMessageBox::Ok); exit(-1); } m_bElectric = (Utils::charBit(Auth::GetInstance()->getProductType(), 0) == 1); m_bCharged = (Utils::charBit(Auth::GetInstance()->getProductType(), 1) == 1); m_bHydraulic = (Utils::charBit(Auth::GetInstance()->getProductType(), 2) == 1); m_bPneumatic = (Utils::charBit(Auth::GetInstance()->getProductType(), 3) == 1); #else m_bElectric = true; m_bCharged = true; m_bHydraulic = true; m_bPneumatic = true; #endif // 屏幕分辨率 GetScreenInfo5(); GetScreenInfo4(); gZoomValue = GetZoomValue(); // QMessageBox::warning(this, "Screen Size", // tr("available : 5: %1 * %2\nrealize : 4: %3 * %4 : %5\ndpi : %6 * %7 : %8\nZoom : %9") // .arg(gAvailableScreenWidth).arg(gAvailableScreenHeight) // .arg(gScreenWidth).arg(gScreenHeight).arg(gScreenCount) // .arg(gDotsPerInchX).arg(gDotsPerInchY).arg(gDotsPerInch) // .arg(gZoomValue)); // 设置系统标题 setWindowTitle(tr("TMS-KEY V1.1")); // 设置基础字体 this->setStyleSheet(gstrStyleSheetStatic.arg(gnFontSizeStatic * gZoomValue)); // 初始化串口区域 initSerialPortArea(); // 初始化业务区域 initServiceArea(); // 初始化日志区域 initLogArea(); // 显示版本信息 logInfo(tr("Welcome to TMS-KEY %1.%2").arg(MAIN_VERSION).arg(SUB_VERSION)); // 显示字节序 #ifdef _DEBUG logDebug(tr("系统字节序: %1").arg(Utils::byteOrder() == LITTLE_ENDIA ? "LITTLE" : "BIG")); #endif } // // 析构函数 // Widget::~Widget() { ui->tabWidgetServiceSetup->removeTab(1); ui->tabWidgetServiceSetup->removeTab(0); if(m_baseSetupWidget != nullptr) { delete m_baseSetupWidget; m_baseSetupWidget = nullptr; } if(m_advanceSetupWidget != nullptr) { delete m_advanceSetupWidget; m_advanceSetupWidget = nullptr; } delete ui; } void Widget::slot_logAdded(QString log) { //QMessageBox::warning(this, "Warning!", log, QMessageBox::Ok, QMessageBox::Ok); ui->textEdit->append(log); // 自动滚动 // QTextCursor cursor = ui->textEdit->textCursor(); // cursor.movePosition(QTextCursor::End); // ui->textEdit->setTextCursor(cursor); LOG_INFO("%s", log.toStdString().c_str()); } /* **************************************** * * 界面设置 * * ***************************************** */ // // 初始化串口区域 // void Widget::initSerialPortArea() { // 串口区域宽度初始化 ui->tabWidgetSerialPortSetup->setFixedWidth(256 * gZoomValue); // 控件大小 //ui->widget_4->layout()->setSpacing(12 * gZoomValue); ui->tabWidgetSerialPortSetup->setStyleSheet(tr("QTabBar:tab{height:%1;}").arg(gnDefaultTabBarHeight * gZoomValue)); int nLabelHeight = gnDefaultLabelHeight * gZoomValue; ui->labelPortName->setFixedHeight(nLabelHeight); ui->labelBaudRate->setFixedHeight(nLabelHeight); ui->labelDataBits->setFixedHeight(nLabelHeight); ui->labelParity->setFixedHeight(nLabelHeight); ui->labelStopBits->setFixedHeight(nLabelHeight); int nComboBoxHeight = gnDefaultComboBoxHeight * gZoomValue; ui->comboBoxPortName->setFixedHeight(nComboBoxHeight); ui->comboBoxBaudRate->setFixedHeight(nComboBoxHeight); ui->comboBoxDataBits->setFixedHeight(nComboBoxHeight); ui->comboBoxParity->setFixedHeight(nComboBoxHeight); ui->comboBoxStopBits->setFixedHeight(nComboBoxHeight); int nPushButtonHeight = gnDefaultPushButtonHeight * gZoomValue; ui->pushButtonSearchSerial->setFixedHeight(nPushButtonHeight); ui->pushButtonOpenSerial->setFixedHeight(nPushButtonHeight); // 控件字体属性 QString strStyleSheet = gstrStyleSheet.arg(gnFontSize * gZoomValue); ui->comboBoxPortName->setStyleSheet(strStyleSheet);// background-color: green; color: rgb(241, 70, 62);红色 ui->comboBoxBaudRate->setStyleSheet(strStyleSheet); ui->comboBoxDataBits->setStyleSheet(strStyleSheet); ui->comboBoxStopBits->setStyleSheet(strStyleSheet); ui->comboBoxParity->setStyleSheet(strStyleSheet); // 初始化串口设置信息 initComboBoxBaudRate(); initComboBoxDataBits(); initComboBoxStopBits(); initComboBoxParity(); updateComboBoxPortName(); connect(ui->comboBoxPortName, SIGNAL(currentIndexChanged(QString)), this, SLOT(slot_comboBoxPortName_currentIndexChanged(QString))); connect(ui->comboBoxBaudRate, SIGNAL(currentIndexChanged(QString)), this, SLOT(slot_comboBoxBaudRate_currentIndexChanged(QString))); connect(ui->comboBoxDataBits, SIGNAL(currentIndexChanged(QString)), this, SLOT(slot_comboBoxDataBits_currentIndexChanged(QString))); connect(ui->comboBoxStopBits, SIGNAL(currentIndexChanged(QString)), this, SLOT(slot_comboBoxStopBits_currentIndexChanged(QString))); connect(ui->comboBoxParity, SIGNAL(currentIndexChanged(QString)), this, SLOT(slot_comboBoxParity_currentIndexChanged(QString))); // portName的设置在updateComboBoxPortName中 DeviceManager::GetInstance()->setCurrBaudRate(ui->comboBoxBaudRate->currentText().toStdString()); DeviceManager::GetInstance()->setCurrDataBits(ui->comboBoxDataBits->currentText().toStdString()); DeviceManager::GetInstance()->setCurrStopBits(ui->comboBoxStopBits->currentText().toStdString()); DeviceManager::GetInstance()->setCurrParity(ui->comboBoxParity->currentText().toStdString()); // 设置搜索串口按钮和打开串口按钮 ui->pushButtonOpenSerial->setText(gstrOpenSerialPort); ui->pushButtonSearchSerial->setText(gstrSearchSerialPort); connect(ui->pushButtonSearchSerial, SIGNAL(clicked()), this, SLOT(slot_SearchSerial())); connect(ui->pushButtonOpenSerial, SIGNAL(clicked()), this, SLOT(slot_OpenSerial())); } // // 初始化业务区域,业务区域包括基础设置和高级设置 // void Widget::initServiceArea() { // 控件大小 //ui->widget_5->layout()->setSpacing(12 * gZoomValue); ui->tabWidgetServiceSetup->setStyleSheet(tr("QTabBar:tab{height:%1;}").arg(gnDefaultTabBarHeight * gZoomValue)); // 右上角扳手类型选择 m_typeComboBox.setObjectName(tr("typeComboBox")); if(m_bElectric) m_typeComboBox.addItem("电动扳手", 1); if(m_bCharged) m_typeComboBox.addItem("充电扳手", 2); if(m_bHydraulic) m_typeComboBox.addItem("液压扳手", 4); if(m_bPneumatic) m_typeComboBox.addItem("气动扳手", 8); QString styleSheet; styleSheet.append(tr("QComboBox { width:%1px; height:%2px; }").arg(60 * gZoomValue).arg(24 * gZoomValue)); styleSheet.append(tr("QComboBox QAbstractItemView::item { min-height:%1px; } ").arg(24 * gZoomValue)); m_typeComboBox.setStyleSheet(styleSheet); m_typeComboBox.setView(new QListView()); ui->tabWidgetServiceSetup->setCornerWidget(&m_typeComboBox, Qt::TopRightCorner); // 获取当前扳手类型 m_typeComboBox.setCurrentIndex(0); m_currType = m_typeComboBox.itemData(m_typeComboBox.currentIndex()).toChar().toLatin1(); // 获取当前扳手类型 connect(&m_typeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_tabComboBox_currentIndexChanged(int))); // 加入基础设置和高级设置tab页 m_baseSetupWidget = new BaseSetupWidget(); ui->tabWidgetServiceSetup->insertTab(0, m_baseSetupWidget, "基础设置(base setup)"); m_advanceSetupWidget = new AdvanceSetupWidget(); ui->tabWidgetServiceSetup->insertTab(1, m_advanceSetupWidget, "高级设置(advance setup)"); m_advanceSetupWidget->setType(getCurrentType()); // 高级功能切换,授权定时器 initAuthorityTimer(); // 选定当前为基数功能设置 ui->tabWidgetServiceSetup->setCurrentIndex(0); // 功能tab切换事件 connect(ui->tabWidgetServiceSetup, SIGNAL(currentChanged(int)), this, SLOT(slot_changeTab(int))); // tab bar点击事件 connect(ui->tabWidgetServiceSetup, SIGNAL(tabBarClicked(int)), this, SLOT(slot_clickTabBar(int))); } void Widget::slot_tabComboBox_currentIndexChanged(int index) { //m_currType = m_typeComboBox.itemData(m_typeComboBox.currentIndex()).toChar().toLatin1(); m_currType = getCurrentType(); // 切换tab页 m_advanceSetupWidget->setType(m_currType); } unsigned char Widget::getCurrentType() { return m_typeComboBox.itemData(m_typeComboBox.currentIndex()).toChar().toLatin1(); } void Widget::initLogArea() { ui->pushButtonClearTextEdit->setFixedWidth(80 * gZoomValue); ui->pushButtonClearTextEdit->setFixedHeight(gnDefaultPushButtonHeight * gZoomValue); ui->textEdit->setReadOnly(true); ui->widgetClear->setStyleSheet("QWidget#widgetClear{background:#92D050;}"); // 清空按钮 connect(ui->pushButtonClearTextEdit, SIGNAL(clicked()), this, SLOT(slot_clearTextEdit())); connect(LogManager::GetInstance(), &LogManager::logAdded, this, &Widget::slot_logAdded); } /* **************************************** * * 授权定时器模块 * * 暂时未使用,考虑点击高级功能后,超过一定时间,使授权失效 * ***************************************** */ // // 初始化授权定时器 // void Widget::initAuthorityTimer(int msec) { QDEBUGMSG("initAuthorityTimer"); m_authorityTimer.stop(); m_authorityTimer.setInterval(msec); connect(&m_authorityTimer, SIGNAL(timeout()), this, SLOT(slot_autorityTimer())); } // // 授权定时器 // void Widget::startAuthorityTimer() { QDEBUGMSG("startAuthorityTimer"); m_authorityTimer.start(); } // // 停止授权定时器 // void Widget::stopAuthorityTimer() { QDEBUGMSG("stopAuthorityTimer"); m_authorityTimer.stop(); } // // 授权定时器的功能: // void Widget::slot_autorityTimer() { QDEBUGMSG("slot_autorityTimer"); //ui->tabWidgetServiceSetup->setCurrentIndex(0); } /* **************************************** * * 串口设置模块 * * ***************************************** */ // // 初始化串口设置信息 // void Widget::updateComboBoxPortName() { //m_serialPortMonitor->StopMonitor(); ui->pushButtonOpenSerial->setDisabled(true); ui->pushButtonSearchSerial->setDisabled(true); initComboBoxPortName(); ui->pushButtonSearchSerial->setEnabled(true); if(ui->comboBoxPortName->count() > 0) { ui->pushButtonOpenSerial->setEnabled(true); ui->comboBoxPortName->setCurrentIndex(0); DeviceManager::GetInstance()->setCurrDeviceName(ui->comboBoxPortName->currentText().toStdString()); } else { ui->pushButtonOpenSerial->setDisabled(true); } //m_serialPortMonitor->StartMonitor(); } // // 初始化串口名 // void Widget::initComboBoxPortName() { const auto infos = QSerialPortInfo::availablePorts(); ui->comboBoxPortName->clear(); for(const QSerialPortInfo &info : infos) { //QSerialPort serial; //serial.setPort(info); //if(serial.open(QIODevice::ReadWrite)) { ui->comboBoxPortName->addItem(info.portName()); //serial.close(); } } } void Widget::slot_comboBoxPortName_currentIndexChanged(QString text) { DeviceManager::GetInstance()->setCurrDeviceName(text.toStdString()); //QMessageBox::warning(this, "Warning!", QString::fromStdString(DeviceManager::GetInstance()->getCurrDeviceName()), QMessageBox::Ok, QMessageBox::Ok); } void Widget::slot_comboBoxBaudRate_currentIndexChanged(QString text) { DeviceManager::GetInstance()->setCurrBaudRate(text.toStdString()); //QMessageBox::warning(this, "Warning!", QString::fromStdString(DeviceManager::GetInstance()->getCurrBaudRate()), QMessageBox::Ok, QMessageBox::Ok); } void Widget::slot_comboBoxDataBits_currentIndexChanged(QString text) { DeviceManager::GetInstance()->setCurrDataBits(text.toStdString()); //QMessageBox::warning(this, "Warning!", QString::fromStdString(DeviceManager::GetInstance()->getCurrDataBits()), QMessageBox::Ok, QMessageBox::Ok); } void Widget::slot_comboBoxStopBits_currentIndexChanged(QString text) { DeviceManager::GetInstance()->setCurrStopBits(text.toStdString()); //QMessageBox::warning(this, "Warning!", QString::fromStdString(DeviceManager::GetInstance()->getCurrStopBits()), QMessageBox::Ok, QMessageBox::Ok); } void Widget::slot_comboBoxParity_currentIndexChanged(QString text) { DeviceManager::GetInstance()->setCurrParity(text.toStdString()); //QMessageBox::warning(this, "Warning!", QString::fromStdString(DeviceManager::GetInstance()->getCurrParity()), QMessageBox::Ok, QMessageBox::Ok); } // // 初始化波特率 // void Widget::initComboBoxBaudRate() { ui->comboBoxBaudRate->addItem("115200"); ui->comboBoxBaudRate->addItem("57600"); ui->comboBoxBaudRate->addItem("38400"); ui->comboBoxBaudRate->addItem("19200"); ui->comboBoxBaudRate->addItem("9600"); ui->comboBoxBaudRate->addItem("4800"); ui->comboBoxBaudRate->addItem("2400"); ui->comboBoxBaudRate->addItem("1200"); //ui->comboBoxBaudRate->setCurrentIndex(0); } // // 初始化数据位 // void Widget::initComboBoxDataBits() { ui->comboBoxDataBits->addItem("8"); ui->comboBoxDataBits->addItem("7"); ui->comboBoxDataBits->addItem("6"); ui->comboBoxDataBits->addItem("5"); //ui->comboBoxDataBits->setCurrentIndex(0); } // // 初始化停止位 // void Widget::initComboBoxStopBits() { ui->comboBoxStopBits->addItem("1"); ui->comboBoxStopBits->addItem("1.5"); ui->comboBoxStopBits->addItem("2"); //ui->comboBoxStopBits->setCurrentIndex(0); } // // 初始化校验位 // void Widget::initComboBoxParity() { ui->comboBoxParity->addItem("None"); ui->comboBoxParity->addItem("Odd"); ui->comboBoxParity->addItem("Even"); //ui->comboBoxParity->setCurrentIndex(0); } /* **************************************** * * 信号槽 -- 串口操作 * * ***************************************** */ // // 打开或关闭串口按钮点击事件 // void Widget::slot_OpenSerial() { if(ui->pushButtonOpenSerial->text() == gstrOpenSerialPort) { ui->pushButtonOpenSerial->setDisabled(true); Device *device = new Device(ui->comboBoxPortName->currentText(), ui->comboBoxBaudRate->currentText(), ui->comboBoxDataBits->currentText(), ui->comboBoxStopBits->currentText(), ui->comboBoxParity->currentText()); // 在SetupService中处理接收数据 connect(device, SIGNAL(recv_data(QString, unsigned char, QByteArray)), (QObject *)SetupService::GetInstance(), SLOT(slot_recvData(QString, unsigned char, QByteArray))); // SetupService中将数据分发至BaseSetupService和AdvanceSetupService connect((QObject *)SetupService::GetInstance(), SIGNAL(recv_base_setup_rsp(QString, unsigned char, QByteArray)), m_baseSetupWidget, SLOT(slot_recvData(QString, unsigned char, QByteArray))); connect(m_baseSetupWidget, SIGNAL(get_record_finish(int)), (QObject *)SetupService::GetInstance(), SLOT(slot_getRecordFinish(int))); connect((QObject *)SetupService::GetInstance(), SIGNAL(recv_advance_setup_rsp(QString, unsigned char, QByteArray)), m_advanceSetupWidget, SLOT(slot_recvData(QString, unsigned char, QByteArray))); // 设备接收消息超时事件 connect(device, SIGNAL(recv_timeout(QString)), (QObject *)SetupService::GetInstance(), SLOT(slot_recvTimeout(QString))); if(device->Open()) { DeviceManager::GetInstance()->AddDevice(ui->comboBoxPortName->currentText(), device); device->startParseThread(); // 设置控件状态 ui->pushButtonOpenSerial->setText(gstrCloseSerialPort); ui->pushButtonOpenSerial->setEnabled(true); ui->comboBoxPortName->setDisabled(true); ui->comboBoxBaudRate->setDisabled(true); ui->comboBoxDataBits->setDisabled(true); ui->comboBoxStopBits->setDisabled(true); ui->comboBoxParity->setDisabled(true); ui->pushButtonSearchSerial->setDisabled(true); logInfo(tr("打开串口成功")); // // 串口打开成功,立即请求设备出厂编号、用户设备名称、 用户设备编号、操作人 // SendData(FRAME_CMD_GET_SERIAL_NUMBER); // waitForIdle(); // SendData(FRAME_CMD_GET_DEVICE_NAME); // waitForIdle(); // SendData(FRAME_CMD_GET_DEVICE_NUMBER); // waitForIdle(); // SendData(FRAME_CMD_GET_OPERATOR); } else { ui->pushButtonOpenSerial->setEnabled(true); logInfo(tr("打开串口失败")); } } else { ui->pushButtonOpenSerial->setDisabled(true); Device *device = DeviceManager::GetInstance()->GetDevice(ui->comboBoxPortName->currentText()); if(device == nullptr) { return; } device->stopParseThread(); // 在SetupService中处理接收数据 disconnect(device, SIGNAL(recv_data(QString, unsigned char, QByteArray)), (QObject *)SetupService::GetInstance(), SLOT(slot_recvData(QString, unsigned char, QByteArray))); // SetupService中将数据分发至BaseSetupService和AdvanceSetupService disconnect((QObject *)SetupService::GetInstance(), SIGNAL(recv_base_setup_rsp(QString, unsigned char, QByteArray)), m_baseSetupWidget, SLOT(slot_recvData(QString, unsigned char, QByteArray))); disconnect((QObject *)SetupService::GetInstance(), SIGNAL(recv_advance_setup_rsp(QString, unsigned char, QByteArray)), m_advanceSetupWidget, SLOT(slot_recvData(QString, unsigned char, QByteArray))); // 设备接收消息超时事件 disconnect(device, SIGNAL(recv_timeout(QString)), (QObject *)SetupService::GetInstance(), SLOT(slot_recvTimeout(QString))); device->Close(); DeviceManager::GetInstance()->RemoveDevice(ui->comboBoxPortName->currentText()); // 设置控件状态 ui->comboBoxPortName->setEnabled(true); ui->comboBoxBaudRate->setEnabled(true); ui->comboBoxDataBits->setEnabled(true); ui->comboBoxStopBits->setEnabled(true); ui->comboBoxParity->setEnabled(true); ui->pushButtonOpenSerial->setText(gstrOpenSerialPort); ui->pushButtonOpenSerial->setEnabled(true); ui->pushButtonSearchSerial->setEnabled(true); logInfo(tr("关闭串口")); } } // // 搜索串口按钮点击事件 // void Widget::slot_SearchSerial() { updateComboBoxPortName(); } /* **************************************** * * 信号槽 -- 切换高级Tab * * ***************************************** */ // // tab切换 // void Widget::slot_changeTab(int index) { if(index == 1) { if(!m_bAuthority) { ui->tabWidgetServiceSetup->setCurrentIndex(0); } } } // // 点击基础设置/高级设置 // void Widget::slot_clickTabBar(int index) { // 如果当前为基础设置,点击的是高级设置 // 弹出授权验证框,输入密码正确则通过验证 if(ui->tabWidgetServiceSetup->currentIndex() == 0 && index == 1 && m_bAuthority == false) { //m_authorityDialog.resize(180 * gZoomValue, 112 * gZoomValue); if(m_authorityDialog.exec() == QDialog::Accepted) { m_bAuthority = m_authorityDialog.isAuthorized(); } } } /* **************************************** * * 信号槽 -- 高级操作 * * ***************************************** */ /* **************************************** * * 版本信息 * * * **************************************** */ QString Widget::version() { //ui->textEdit->append(tr("makeVersion:%1:%2->%3").arg(MAIN_VERSION).arg(SUB_VERSION).arg(v)); return tr("%1").arg(VERSION); } /* **************************************** * * 日志区域 * * * **************************************** */ // 清空按钮 void Widget::slot_clearTextEdit() { ui->textEdit->clear(); } void Widget::showEvent(QShowEvent *event) { //QMessageBox::warning(this, "Warning!", "showEvent", QMessageBox::Ok, QMessageBox::Ok); QWidget::showEvent(event); } void Widget::closeEvent(QCloseEvent *event) { //QMessageBox::warning(this, "Warning!", "closeEvent", QMessageBox::Ok, QMessageBox::Ok); QWidget::closeEvent(event); }