diff --git a/applications/emsConfigurer/aboutdialog.ui b/applications/emsConfigurer/aboutdialog.ui index cb642e5..023c18d 100644 --- a/applications/emsConfigurer/aboutdialog.ui +++ b/applications/emsConfigurer/aboutdialog.ui @@ -54,16 +54,22 @@ - WWW.HJ-NET.COM + + + + :/images/hj-net.png + + + true 10 - 120 + 90 621 - 271 + 301 @@ -82,10 +88,10 @@ - 30 - 70 - 601 - 41 + 300 + 10 + 331 + 61 @@ -93,7 +99,9 @@ - + + + buttonBox diff --git a/applications/emsConfigurer/emsConfigurer.pro b/applications/emsConfigurer/emsConfigurer.pro index eb92c85..5e63bd2 100644 --- a/applications/emsConfigurer/emsConfigurer.pro +++ b/applications/emsConfigurer/emsConfigurer.pro @@ -1,4 +1,4 @@ -QT += core gui +QT += core gui sql #DEFINES += _USING_MYSQL_CONNECTOR_ #DEFINES += _USING_QT_MYSQL_CONNECTOR_ @@ -86,6 +86,7 @@ SOURCES += \ mainwindow.cpp \ mysqlutils.cpp \ mytablemodel.cpp \ + newdeviceformdialog.cpp \ ziputils.cpp HEADERS += \ @@ -100,6 +101,7 @@ HEADERS += \ mainwindow.h \ mysqlutils.h \ mytablemodel.h \ + newdeviceformdialog.h \ singleton.h \ ziputils.h \ hv_tcpclient.h \ @@ -110,7 +112,15 @@ FORMS += \ aboutdialog.ui \ formserialportsettingdialog.ui \ maindialog.ui \ - mainwindow.ui + mainwindow.ui \ + newdeviceformdialog.ui + +TRANSLATIONS += \ + emsConfigurer_en_US.ts \ + emsConfigurer_zh_CN.ts + +CONFIG += lrelease +CONFIG += embed_translations # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin diff --git a/applications/emsConfigurer/emsConfigurer_en_US.ts b/applications/emsConfigurer/emsConfigurer_en_US.ts new file mode 100644 index 0000000..74d93cd --- /dev/null +++ b/applications/emsConfigurer/emsConfigurer_en_US.ts @@ -0,0 +1,764 @@ + + + + + AboutDialog + + + About Configurer ... + About Configurer... + About Configurer + + + + TextLabel + + + + + About EMU Configurer Kit + About EMU Configurer Kit + About EMU Configurer Kit + + + + Configurer Kit for EMU Host + Configurer Kit for EMU Kit + Configurer Kit for EMU Kit + + + + Version %1.%2.%3 + Version %1.%2.%3 + Version %1.%2.%3 + + + + Compiled on %1 + Compiled on %1 + Compiled on %1 + + + + DevicePropertyPage + + + First + First + First + + + + Forward + Forward + Forward + + + + Next + Next + Next + + + + Last + Last + Last + + + + 1 + 1 + 11 + + + + Page + Page + Page + + + + Go + Go + Go + + + + Total %d Pages, Current No.%d Page + Total %d Pages, Current No.%d Page + Total %d Pages, Current No.%d Page + + + + Auto Refresh + Auto Refresh + Auto Refresh + + + + 0 + 0 + 0 + + + + Interval(Sec.) + Interval(Sec.) + Interval(Sec.) + + + + Page number should be large than 0 and less than %1 ! + Page number should be large than 0 and less than %1 ! + Page number should be large than 0 and less than %1 ! + + + + Critical Message + Critical Message + Critical Message + + + + FormSerialPortSettingDialog + + + 设备串口设置 + + + + + 设备名称 + + + + + 设备序号 + + + + + 串口类型 + + + + + 从机地址 + + + + + 串口号 + + + + + 波特率 + + + + + 数据位 + + + + + 校验位 + + + + + 停止位 + + + + + 模式 + + + + + 响应超时 + + + + + 轮询间隔 + + + + + + ms + + + + + DSR + + + + + CTS + + + + + DTR + + + + + 插件绑定 + + + + + ... + + + + + 制造商 + + + + + None + + + + + Odd + + + + + Even + + + + + 8 Data bits + + + + + 7 Data bits + + + + + 1 Stop bit + + + + + 2 Stop bits + + + + + RTU + + + + + ASCII + + + + + 2400 + + + + + 4800 + + + + + 9600 + + + + + 19200 + + + + + 38400 + + + + + 57600 + + + + + 115200 + + + + + 128000 + + + + + 153600 + + + + + 230400 + + + + + 460800 + + + + + 921600 + + + + + Serial Port + + + + + Failed to open file: %1 + + + + + Critical + + + + + Service responsed: Permission denyed +Contact Developement for supporting! + + + + + Upload file failed, Press Yes to upload again! + + + + + MainDialog + + + EMU Configurer Kit + + + + + Power + + + + + Battery + + + + + Switch + + + + + Air + + + + + Fan + + + + + Sensor + + + + + Add Device + + + + + Add a new device + + + + + Remove Device + + + + + Remove a device + + + + + + Refresh + + + + + About... + + + + + Show information about EMU Configurer toolkit + + + + + MainWindow + + + EMS Configurer + + + + + Host IP + Host IP + Host IP + + + + Configurer + Configurer + Configurer + + + + + for EMU Host + for EMU Host + for EMU Host + + + + Test + Test + Test + + + + Logon + Logon + Logon + + + + Close + Close + Close + + + + Login name + Login name + Login name + + + + Password + Password + Password + + + + Lang + Lang + Lang + + + + EMU Configurer Kit + EMU Configurer Kit + EMU Configurer Kit + + + + Configurer Kit + Configurer Kit + Configurer Kit + + + + + + Critical Message + Critical Message + Critical Message + + + + Failed to retrieve device data! + Failed to retrieve device data! + Failed to retrieve device data! + + + + + Successfully + Successfully + Successfully + + + + Connect to device database successfully! + Connect to device database successfully! + Connect to device database successfully! + + + + Failed to connect to device database! + Failed to connect to device database! + Failed to connect to device database! + + + + Connect to device data service successfully! + Connect to device data service successfully! + Connect to device data service successfully! + + + + Failed to connect to device data service! + Failed to connect to device data service! + Failed to connect to device data service! + + + + Language + Eng + Eng + + + + MyTableModel + + + Normal + + + + + INFO + + + + + WARN + + + + + ERROR + + + + + NewDeviceFormDialog + + + 设备串口设置 + + + + + OK + + + + + Cancel + + + + + 导入 + + + + + 预定义文件 + + + + + 设备类型 + + + + + 从机地址 + + + + + 波特率 + + + + + 串口号 + + + + + 校验位 + + + + + 停止位 + + + + + 串口类型 + + + + + 数据位 + + + + + 端口配置 + + + + + Select Configuration File + + + + + Database Files (*.db);;All Files (*.*) + + + + + None + + + + + Odd + + + + + Even + + + + + 8 Data bits + + + + + 7 Data bits + + + + + 1 Stop bit + + + + + 2 Stop bits + + + + + 2400 + + + + + 4800 + + + + + 9600 + + + + + 19200 + + + + + 38400 + + + + + 57600 + + + + + 115200 + + + + + 128000 + + + + + 153600 + + + + + 230400 + + + + + 460800 + + + + + 921600 + + + + + Serial Port + + + + diff --git a/applications/emsConfigurer/emsConfigurer_zh_CN.ts b/applications/emsConfigurer/emsConfigurer_zh_CN.ts new file mode 100644 index 0000000..f371799 --- /dev/null +++ b/applications/emsConfigurer/emsConfigurer_zh_CN.ts @@ -0,0 +1,764 @@ + + + + + AboutDialog + + + About Configurer ... + 关于配置器... + 关于配置器... + + + + TextLabel + + + + + About EMU Configurer Kit + 关于EMU配置器工具 + 关于EMU配置器工具 + + + + Configurer Kit for EMU Host + EMU配置工具 + EMU配置工具 + + + + Version %1.%2.%3 + 版本号 %1.%2.%3 + 版本号 %1.%2.%3 + + + + Compiled on %1 + 编译于 %1 + 编译于 %1 + + + + DevicePropertyPage + + + First + 首行 + 首行 + + + + Forward + 前翻 + 前翻 + + + + Next + 后翻 + 后翻 + + + + Last + 最后 + 最后 + + + + 1 + 1 + 1 + + + + Page + + + + + + Go + 前往 + 前往 + + + + Total %d Pages, Current No.%d Page + 共 %d 页, 当前第 %d 页 + 共 %d 页, 当前第 %d 页 + + + + Auto Refresh + 自动刷新 + 自动刷新 + + + + 0 + 0 + 0 + + + + Interval(Sec.) + 间隔(秒) + 间隔(秒) + + + + Page number should be large than 0 and less than %1 ! + 页数应该大于0且小于 %1 1 + 页数应该大于0且小于 %1 1 + + + + Critical Message + 严重错误 + 严重错误 + + + + FormSerialPortSettingDialog + + + 设备串口设置 + + + + + 设备名称 + + + + + 设备序号 + + + + + 串口类型 + + + + + 从机地址 + + + + + 串口号 + + + + + 波特率 + + + + + 数据位 + + + + + 校验位 + + + + + 停止位 + + + + + 模式 + + + + + 响应超时 + + + + + 轮询间隔 + + + + + + ms + + + + + DSR + + + + + CTS + + + + + DTR + + + + + 插件绑定 + + + + + ... + + + + + 制造商 + + + + + None + + + + + Odd + + + + + Even + + + + + 8 Data bits + + + + + 7 Data bits + + + + + 1 Stop bit + + + + + 2 Stop bits + + + + + RTU + + + + + ASCII + + + + + 2400 + + + + + 4800 + + + + + 9600 + + + + + 19200 + + + + + 38400 + + + + + 57600 + + + + + 115200 + + + + + 128000 + + + + + 153600 + + + + + 230400 + + + + + 460800 + + + + + 921600 + + + + + Serial Port + + + + + Failed to open file: %1 + + + + + Critical + + + + + Service responsed: Permission denyed +Contact Developement for supporting! + + + + + Upload file failed, Press Yes to upload again! + + + + + MainDialog + + + EMU Configurer Kit + + + + + Power + + + + + Battery + + + + + Switch + + + + + Air + + + + + Fan + + + + + Sensor + + + + + Add Device + + + + + Add a new device + + + + + Remove Device + + + + + Remove a device + + + + + + Refresh + + + + + About... + + + + + Show information about EMU Configurer toolkit + + + + + MainWindow + + + EMS Configurer + + + + + Host IP + 主机IP + 主机IP + + + + Configurer + 配置工具 + 配置工具 + + + + + for EMU Host + 支持EMU主机 + 支持EMU主机 + + + + Test + 测试 + 测试 + + + + Logon + 登录 + 登录 + + + + Close + 退出 + 退出 + + + + Login name + 登录账号 + 登录账号 + + + + Password + 登录密码 + 登录密码 + + + + Lang + 语言 + 语言 + + + + EMU Configurer Kit + EMU Configurer Kit + EMU Configurer Kit + + + + Configurer Kit + 配置工具 + 配置工具 + + + + + + Critical Message + 严重错误 + 严重错误 + + + + Failed to retrieve device data! + 检索设备数据失败! + 检索设备数据失败! + + + + + Successfully + 成功 + 成功 + + + + Connect to device database successfully! + 成功连接设备数据库! + 成功连接设备数据库! + + + + Failed to connect to device database! + 不能连接设备数据库! + 不能连接设备数据库! + + + + Connect to device data service successfully! + 成功连接到设备数据服务! + 成功连接到设备数据服务! + + + + Failed to connect to device data service! + 不能连接到设备数据服务! + 不能连接到设备数据服务! + + + + Language + 中文 + 中文 + + + + MyTableModel + + + Normal + + + + + INFO + + + + + WARN + + + + + ERROR + + + + + NewDeviceFormDialog + + + 设备串口设置 + + + + + OK + + + + + Cancel + + + + + 导入 + + + + + 预定义文件 + + + + + 设备类型 + + + + + 从机地址 + + + + + 波特率 + + + + + 串口号 + + + + + 校验位 + + + + + 停止位 + + + + + 串口类型 + + + + + 数据位 + + + + + 端口配置 + + + + + Select Configuration File + + + + + Database Files (*.db);;All Files (*.*) + + + + + None + + + + + Odd + + + + + Even + + + + + 8 Data bits + + + + + 7 Data bits + + + + + 1 Stop bit + + + + + 2 Stop bits + + + + + 2400 + + + + + 4800 + + + + + 9600 + + + + + 19200 + + + + + 38400 + + + + + 57600 + + + + + 115200 + + + + + 128000 + + + + + 153600 + + + + + 230400 + + + + + 460800 + + + + + 921600 + + + + + Serial Port + + + + diff --git a/applications/emsConfigurer/formserialportsettingdialog.cpp b/applications/emsConfigurer/formserialportsettingdialog.cpp index 76bc73f..358e7fa 100644 --- a/applications/emsConfigurer/formserialportsettingdialog.cpp +++ b/applications/emsConfigurer/formserialportsettingdialog.cpp @@ -9,7 +9,6 @@ #include #include #include - #include #include "frame_define.h" diff --git a/applications/emsConfigurer/globalparameters.h b/applications/emsConfigurer/globalparameters.h index e5cf64d..b4cc36e 100644 --- a/applications/emsConfigurer/globalparameters.h +++ b/applications/emsConfigurer/globalparameters.h @@ -159,4 +159,23 @@ public: int m_connfd; }; +//配置数据库的相关结构 +typedef struct _tagCfgTab_SmartDeviceTypeItem +{ + int TypeID; + std::string Description; + int ClassType; + int PortConfig; + int InterfaceType; + int StationType; + int EquipmentCode; + std::string EquipmentModel; + std::string Manufacturer; + std::string ProtocolVersion; + std::string SpecialOption; + std::string Notes; +} CfgTabSmartDeviceTypeItem; + +typedef std::vector vecCfgTab_SmartDeviceType; + #endif // GLOBALPARAMETERS_H diff --git a/applications/emsConfigurer/images/hj-net.png b/applications/emsConfigurer/images/hj-net.png index f4d1814..624f778 100644 Binary files a/applications/emsConfigurer/images/hj-net.png and b/applications/emsConfigurer/images/hj-net.png differ diff --git a/applications/emsConfigurer/maindialog.cpp b/applications/emsConfigurer/maindialog.cpp index 9276325..309e9b1 100644 --- a/applications/emsConfigurer/maindialog.cpp +++ b/applications/emsConfigurer/maindialog.cpp @@ -20,6 +20,7 @@ #include "devicepropertypage.h" #include "formserialportsettingdialog.h" #include "aboutdialog.h" +#include "newdeviceformdialog.h" MainDialog::MainDialog(QWidget *parent) : QMainWindow (parent), @@ -123,10 +124,6 @@ void MainDialog::CreateToolbar() QHBoxLayout *layout = new QHBoxLayout(toolBarWidget); layout->setContentsMargins(0, 0, 0, 0); // 去除内边距 - // 添加一个弹性空间以推送图标到右侧 - QSpacerItem *spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - layout->addItem(spacer); - // Create actions for the toolbar QAction *action1 = new QAction(QIcon(":/images/icons8-add-64.png"), tr("Add Device"), this); action1->setToolTip(tr("Add a new device")); @@ -145,6 +142,11 @@ void MainDialog::CreateToolbar() m_pMainToolBar->addAction(action2); m_pMainToolBar->addAction(action4); m_pMainToolBar->addSeparator(); + + QWidget *spacerWidget = new QWidget(); + spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + m_pMainToolBar->addWidget(spacerWidget); + m_pMainToolBar->addAction(action3); // 将工具栏的 widget 设置为包含图标和占位符的 widget @@ -220,7 +222,8 @@ void MainDialog::loadWindowState() //增加设备 void MainDialog::onToolButton1Clicked() { - FormSerialPortSettingDialog* dlg = new FormSerialPortSettingDialog(this); + //FormSerialPortSettingDialog* dlg = new FormSerialPortSettingDialog(this); + NewDeviceFormDialog* dlg = new NewDeviceFormDialog(this); dlg->setWindowFlags(dlg->windowFlags()&~(Qt::WindowMinMaxButtonsHint|Qt::WindowContextHelpButtonHint)); //dlg.setModal(true); dlg->show(); diff --git a/applications/emsConfigurer/mainwindow.cpp b/applications/emsConfigurer/mainwindow.cpp index 5dc286d..2147940 100644 --- a/applications/emsConfigurer/mainwindow.cpp +++ b/applications/emsConfigurer/mainwindow.cpp @@ -2,6 +2,8 @@ #include "ui_mainwindow.h" #include #include +#include +#include #include #include "MainDialog.h" @@ -39,6 +41,12 @@ MainWindow::MainWindow(QWidget *parent) QFont font2("Arial", 12, QFont::Bold); ui->productName2->setText(tr("for EMU Host")); ui->productName2->setFont(font2); + + QMenu *menu = new QMenu(ui->pb_Lang); + menu->addAction("中文", this, &MainWindow::setChinese); + menu->addAction("Eng", this, &MainWindow::setEnglish); + ui->pb_Lang->setMenu(menu); + retranslateUI(); } MainWindow::~MainWindow() @@ -141,3 +149,42 @@ void MainWindow::on_pb_Test_clicked() QMessageBox::critical(this, tr("Critical Message"),tr("Failed to connect to device data service!")); } +void MainWindow::setChinese() +{ + switchLanguage("emsConfigurer_zh_CN"); +} +void MainWindow::setEnglish() +{ + switchLanguage("emsConfigurer_en_US"); +} + +void MainWindow::switchLanguage(const QString &lang) +{ + loadLanguage(lang); + retranslateUI(); // 立即更新界面 +} + +void MainWindow::retranslateUI() +{ + ui->pb_Lang->setText(tr("Language")); + ui->retranslateUi(this); +} + +void MainWindow::loadLanguage(const QString &lang) +{ + qApp->removeTranslator(&translator); + QString l = ":/i18n/" + lang + ".qm"; + if (translator.load(l)) + { + qApp->installTranslator(&translator); + } +} + +void MainWindow::changeEvent(QEvent *event) +{ + // if (event->type() == QEvent::LanguageChange) + // { + // ui->retranslateUi(this); + // } + QWidget::changeEvent(event); +} diff --git a/applications/emsConfigurer/mainwindow.h b/applications/emsConfigurer/mainwindow.h index f066cc2..628514a 100644 --- a/applications/emsConfigurer/mainwindow.h +++ b/applications/emsConfigurer/mainwindow.h @@ -3,6 +3,8 @@ #pragma execution_character_set("utf-8") #include +#include + #include class MainDialog; @@ -29,14 +31,23 @@ protected: void setIp(const QString &ip); bool testDatabase(); bool testServerEcho(); //测试后端服务器响应 + void changeEvent(QEvent *event) override; private slots: void on_pb_Logon_clicked(); void on_pb_Test_clicked(); + void setChinese(); + void setEnglish(); + +private: + void switchLanguage(const QString &lang); + void retranslateUI(); + void loadLanguage(const QString &lang); private: Ui::MainWindow *ui; MainDialog* m_pMainDialog; + QTranslator translator; }; #endif // MAINWINDOW_H diff --git a/applications/emsConfigurer/mainwindow.ui b/applications/emsConfigurer/mainwindow.ui index b59f656..b9ebf92 100644 --- a/applications/emsConfigurer/mainwindow.ui +++ b/applications/emsConfigurer/mainwindow.ui @@ -103,7 +103,13 @@ - WWW.HJ-NET.COM + + + + :/images/hj-net.png + + + true @@ -118,6 +124,9 @@ + + + Logon @@ -213,6 +222,19 @@ + + + + 530 + 20 + 71 + 29 + + + + Lang + + @@ -230,6 +252,8 @@ pb_Logon pb_Close - + + +