diff --git a/CHANGELOG.md b/CHANGELOG.md index 0276267..7cb4460 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ [中文](doc/CHANGELOG/CHANGELOG_zh_CN.md) +## V0.2.1 ++ Add command line option to set config file path ++ Fix some bugs in file transceiver ++ Add touch screen gesture support for some scrollable widgets + ## V0.2 + Supports TCP client/server, UDP, Bluetooth SPP client/server and Bluetooth BLE + All servers support 1:N connections. Sent to/Receive from/Disconnect any client as you want diff --git a/doc/CHANGELOG/CHANGELOG_zh_CN.md b/doc/CHANGELOG/CHANGELOG_zh_CN.md index e00c697..ec80765 100644 --- a/doc/CHANGELOG/CHANGELOG_zh_CN.md +++ b/doc/CHANGELOG/CHANGELOG_zh_CN.md @@ -2,6 +2,11 @@ [English](../../CHANGELOG.md) +## V0.2.1 ++ 支持通过命令行参数指定配置文件路径 ++ 修复文件收发功能的一些小BUG ++ 对一些可以滚动的组件添加触摸屏手势支持 + ## V0.2 + 支持TCP客户端/服务器,UDP,蓝牙SPP客户端/服务器和蓝牙BLE + TCP服务器和蓝牙SPP服务器支持一对多连接,可以任意指定收发对象,断开指定连接 diff --git a/src/SerialTest.pro b/src/SerialTest.pro index 7cdfc09..3248350 100644 --- a/src/SerialTest.pro +++ b/src/SerialTest.pro @@ -81,7 +81,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target # Remember to change version in AndroidManifest.xml -VERSION = 0.2.0 +VERSION = 0.2.1 QMAKE_TARGET_PRODUCT = "SerialTest" QMAKE_TARGET_DESCRIPTION = "SerialTest" QMAKE_TARGET_COMPANY = "wh201906" diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml index 11c15c1..5d7e3a0 100644 --- a/src/android/AndroidManifest.xml +++ b/src/android/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/src/ctrltab.cpp b/src/ctrltab.cpp index e09df50..d6fe761 100644 --- a/src/ctrltab.cpp +++ b/src/ctrltab.cpp @@ -13,6 +13,7 @@ #include #include #include +#include CtrlTab::CtrlTab(QWidget *parent) : QWidget(parent), @@ -29,6 +30,7 @@ CtrlTab::CtrlTab(QWidget *parent) : commentRegExp->optimize(); ui->ctrl_dataEdit->hide(); + QScroller::grabGesture(ui->ctrl_itemArea); } CtrlTab::~CtrlTab() diff --git a/src/devicetab.cpp b/src/devicetab.cpp index c1fb0da..271ab3e 100644 --- a/src/devicetab.cpp +++ b/src/devicetab.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef Q_OS_ANDROID #include #include @@ -276,6 +277,14 @@ void DeviceTab::initUI() ui->Net_localPortEdit->setValidator(m_netPortValidator); ui->Net_remotePortEdit->setValidator(m_netPortValidator); + QScroller::grabGesture(ui->BLEC_argsScrollArea); + QScroller::grabGesture(ui->Net_argsScrollArea); + QScroller::grabGesture(ui->SP_portList); + QScroller::grabGesture(ui->BTServer_deviceList); + QScroller::grabGesture(ui->BTClient_deviceList); + QScroller::grabGesture(ui->BLEC_deviceList); + QScroller::grabGesture(ui->BLEC_UUIDList); + QScroller::grabGesture(ui->Net_addrPortList); } void DeviceTab::getAvailableTypes(bool useFirstValid) diff --git a/src/filetab.cpp b/src/filetab.cpp index 1626265..bc2d4f4 100644 --- a/src/filetab.cpp +++ b/src/filetab.cpp @@ -282,7 +282,13 @@ void FileTab::onDataTransmitted(qsizetype num) void FileTab::onDataReceived(qsizetype num) { m_handledSize += num; - ui->sizeLabel->setText(QLocale(QLocale::English).toString(m_handledSize) + " Bytes"); + if(currentProtocol() == FileXceiver::RawProtocol && ui->RawRx_autostopByteButton->isChecked()) + { + ui->progressBar->setValue((double)m_handledSize / m_fileSize * 100.0); + ui->sizeLabel->setText(QLocale(QLocale::English).toString(m_handledSize) + "/" + QLocale(QLocale::English).toString(m_fileSize) + " Bytes"); + } + else + ui->sizeLabel->setText(QLocale(QLocale::English).toString(m_handledSize) + " Bytes"); } bool FileTab::receiving() @@ -309,7 +315,7 @@ void FileTab::onStartResultArrived(bool result) m_working = result; if(result) { - if(ui->receiveModeButton->isChecked() && currentProtocol() == FileXceiver::RawProtocol) + if(ui->receiveModeButton->isChecked() && currentProtocol() == FileXceiver::RawProtocol && ui->RawRx_autostopNoneButton->isChecked()) ui->progressBar->setMaximum(0); setParameterWidgetEnabled(false); ui->startStopButton->setText(tr("Stop")); @@ -333,13 +339,26 @@ void FileTab::stop() void FileTab::updateFileSize() { - if(ui->receiveModeButton->isChecked() && currentProtocol() == FileXceiver::RawProtocol) - ui->sizeLabel->setText(""); + m_fileSize = -1; + if(ui->receiveModeButton->isChecked()) + { + if(currentProtocol() == FileXceiver::RawProtocol) + { + if(ui->RawRx_autostopByteButton->isChecked()) + m_fileSize = ui->RawRx_autostopByteBox->currentText().toLongLong(); + else + m_fileSize = -1; + } + } else { m_fileSize = QFileInfo(ui->filePathEdit->text()).size(); - ui->sizeLabel->setText(QLocale(QLocale::English).toString(m_fileSize) + " Bytes"); } + + if(m_fileSize == -1) + ui->sizeLabel->setText(""); + else + ui->sizeLabel->setText(QLocale(QLocale::English).toString(m_handledSize) + "/" + QLocale(QLocale::English).toString(m_fileSize) + " Bytes"); } void FileTab::setParameterWidgetEnabled(bool state) diff --git a/src/filexceiver.cpp b/src/filexceiver.cpp index a2f00e4..d376a54 100644 --- a/src/filexceiver.cpp +++ b/src/filexceiver.cpp @@ -6,7 +6,7 @@ FileXceiver::FileXceiver(QObject *parent) : QObject{parent} { - qRegisterMetaType(); + qRegisterMetaType("qsizetype"); // qsizetype is an alias, so the typeName is compulsory qRegisterMetaType(); qRegisterMetaType(); m_file.setParent(this); // for moveToThread() @@ -89,19 +89,19 @@ void FileXceiver::newData(const QByteArray &data) if(m_protocol == RawProtocol) { qsizetype num; - qsizetype limit = -1; + qsizetype limit = -1, currNum = -1; if(m_expectedNum != -1) { limit = m_expectedNum - m_handledNum; - limit = limit < data.size() ? limit : data.size(); - num = m_file.write(data.constData(), limit); + currNum = limit < data.size() ? limit : data.size(); + num = m_file.write(data.constData(), currNum); } else num = m_file.write(data); m_file.flush(); m_handledNum += num; emit dataReceived(num); - if(m_expectedNum != -1 && limit != data.size()) + if(m_expectedNum != -1 && currNum == limit) emit finished(); } } diff --git a/src/filexceiver.h b/src/filexceiver.h index 2523f97..83088dc 100644 --- a/src/filexceiver.h +++ b/src/filexceiver.h @@ -66,6 +66,7 @@ public slots: }; Q_DECLARE_METATYPE(qsizetype) +Q_DECLARE_METATYPE(FileXceiver::Protocol) Q_DECLARE_METATYPE(FileXceiver::ThrottleArgument) #endif // FILEXCEIVER_H diff --git a/src/i18n/SerialTest_zh_CN.qm b/src/i18n/SerialTest_zh_CN.qm index 6c1a31a..cbd6c60 100644 Binary files a/src/i18n/SerialTest_zh_CN.qm and b/src/i18n/SerialTest_zh_CN.qm differ diff --git a/src/i18n/SerialTest_zh_CN.ts b/src/i18n/SerialTest_zh_CN.ts index 1041aa9..4d9e5b6 100644 --- a/src/i18n/SerialTest_zh_CN.ts +++ b/src/i18n/SerialTest_zh_CN.ts @@ -14,72 +14,72 @@ 无法在该适配器上注册服务 - + Failed to listen to 无法监听连接 - + (Multicast)Failed to listen to port (组播)无法监听端口 - + (Multicast)Failed to join (组播)无法加入组播 - + Bluetooth SPP Service - + Controller Error: 控制器错误: - + Service Error: 服务错误: - + SerialPort 串口 - + Bluetooth Client 蓝牙客户端 - + Bluetooth Server 蓝牙服务器 - + BLE Central BLE 中心设备(Central) - + BLE Peripheral BLE 外围设备(Peripheral) - + TCP Client TCP客户端 - + TCP Server TCP服务器 - + UDP @@ -236,77 +236,77 @@ - - + + Import 导入 - - + + Export 导出 - + Paste the exported data in the box. 将导出的数据粘贴到此框中。 - - + + Done 完成 - + Import Control Panel 导入控制面板 - - - - + + + + Info 信息 - - + + Successed! 成功! - - + + Failed! 失败! - - + + Please add item first 请先添加控制项 - + Copy all text in this box and save it to somewhere. 将此文本框中的内容复制并保存。 - + To import, click the Import button, then paste the text back. 需要导入时,单击“导入”按钮,将复制的内容粘贴回来即可。 - + Copied to clipboard 已复制到剪贴板 - + Export Control Panel 导出控制面板 @@ -343,16 +343,16 @@ - - + + Export 导出 - - + + Copy All 复制全部 @@ -380,7 +380,7 @@ - + Suffix 后缀 @@ -437,67 +437,107 @@ - GB18030 + GB2312 - BIG5 + GB18030 + + + + + Big5 + + + + + windows-1252 + + + + + UTF-16LE - + + UTF-16BE + + + + + UTF-32LE + + + + + UTF-32BE + + + + + Shift_JIS + + + + + EUC-KR + + + + Set 设置 - + Unescape 转义 - - - + + + Info 信息 - + is not a valid encoding. 不是有效编码名。 - + Export received data 导出已接收数据 - - + + Successed! 成功! - - + + Failed! 失败! - + Export sended data 导出已发送数据 - - + + Export Selected 导出选中 - - + + Copy Selected 复制选中 @@ -506,8 +546,8 @@ DeviceTab - - + + Refresh 刷新 @@ -556,8 +596,8 @@ - - + + Connect 连接 @@ -613,13 +653,13 @@ - + Receive 接收 - + Send 发送 @@ -813,7 +853,7 @@ - + Remote Address: 远端地址: @@ -839,7 +879,7 @@ you can change the remote address and port on the fly. 服务名称: - + SerialTest_BT @@ -854,13 +894,13 @@ you can change the remote address and port on the fly. 关闭 - - + + Searching... 搜索中... - + Bonded 已配对 @@ -887,42 +927,42 @@ you can change the remote address and port on the fly. 设备 - + NoFlowControl 无流控 - + HardwareControl 软件流控 - + SoftwareControl 硬件流控 - + NoParity 无校验 - + EvenParity 偶校验 - + OddParity 奇校验 - + SpaceParity 固定0 - + MarkParity 固定1 @@ -947,27 +987,27 @@ you can change the remote address and port on the fly. TCP服务器 - - - + + + Disconnect 断开 - - - - - - - - - + + + + + + + + + Error 错误 - + The port has been opened. 串口已打开。 @@ -976,104 +1016,104 @@ you can change the remote address and port on the fly. 设备已连接。 - - + + The server is already running. 服务器正在运行中。 - - + + The device has already connected. 设备已连接。 - + The client has already connected to the server. 已连接到服务器。 - + The socket has already bound to a port. 已绑定至端口。 - + Delete 删除 - + Discovered 已发现 - + Please close the current connection first. 请先关闭当前连接。 - + Unsupported interface. 尚未支持此连接类型。 - + Remote Address/Name: 远端地址/主机名: - + Service 服务(Service) - + Characteristic 特征值(Characteristic) - + Descriptor 描述符(Descriptor) - + Broadcast - + Read - + WriteNoResponse - + Write - + Notify - + Indicate - + WriteSigned - + ExtendedProperty @@ -1103,7 +1143,7 @@ you can change the remote address and port on the fly. - + Start 启动 @@ -1331,22 +1371,22 @@ Continue? 已停止 - + Finished 已完成 - + Stop 停止 - + Started 已启动 - + Failed to start. 启动失败。 @@ -1802,116 +1842,126 @@ Continue? 在系统默认配置文件夹中创建配置文件 - This app will use the config file in the working directory first. If the file is not in the working directory, the app will will find it in the configuration directory. If no config file is detected, This app will create one in the current working directory. - 程序会首先尝试读取当前文件夹下的配置文件。 + 程序会首先尝试读取当前文件夹下的配置文件。 +如果当前文件夹下找不到,则会在系统默认配置文件夹中寻找。 +如果还是找不到配置文件,则会在当前文件夹下新建一个。 + + + + You can specify the config file path by passing "--config-path <path>" option when opening it. +If the config file path is not set, this app will use the config file in the working directory first. +If the file is not in the working directory, the app will will find it in the configuration directory. +If no config file is detected, This app will create one in the current working directory. + 你可以在打开时通过"--config-path <文件路径>"选项来指定程序使用的配置文件。 +如果没有指定配置文件,程序会首先尝试读取当前文件夹下的配置文件。 如果当前文件夹下找不到,则会在系统默认配置文件夹中寻找。 如果还是找不到配置文件,则会在当前文件夹下新建一个。 - + Max History Count *: 历史记录最大条数 *: - - - - + + + + Set 设置 - + Clear History 清空历史记录 - + Language * 语言 * - + Language file path (*.qm) 语言文件路径 (*.qm) - + Appearance 外观 - + Full Screen 全屏 - + Force landscape mode 强制横屏 - + Use Dock * (Experimental) 使用Dock * (实验性功能) - + Opacity: 不透明度: - + Global Font: 全局字体: - + Data Font: 数据字体: - + Restart the app to make settings with "*" take effect. 带*的设置项将在程序重启后生效。 - + Latest Release: 检查更新: - + (System) (跟随系统) - + Simplified Chinese 简体中文 - + English 英语 - + (External File) (外部文件) - - - + + + Warning 警告 - + All configurations and history will be deleted! And this app will be closed! Continue? @@ -1920,92 +1970,103 @@ Continue? 继续吗? - - - + + + Create 创建 - + The file already exists at 文件已存在,位于 - + Cannot create file there. 无法在此处创建文件。 - + Read 读取 - + Cannot read config. 无法读取配置。 - + Created at 已创建于 - + All history will be deleted! Continue? 所有的历史记录都会被删除! 继续吗? - + This app will be closed after import! Continue? 导入成功后程序会自动关闭! 继续吗? - + Import config from file 从文件导入配置 - - + + Config files 配置文件 - - + + All files 所有文件 - + Error 错误 - + Unsupported file format. 文件格式不支持。 - + Info 信息 - + Imported. 已导入。 - + Export config to file 导出配置到文件 + + main + + Use specified file as config file + 使用指定的配置文件 + + + file path + 文件路径 + + diff --git a/src/main.cpp b/src/main.cpp index 0d614e6..2093090 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include int main(int argc, char *argv[]) { @@ -29,20 +30,38 @@ int main(int argc, char *argv[]) // on Android, use default. MySettings::init(QSettings::NativeFormat); #else + + // translator is not loaded there. + QCommandLineParser parser; + parser.addHelpOption(); + parser.addOption({"config-path", + "Use specified file as config file", + "file path"}); + parser.process(a); + // on PC, store preferences in files for portable use - // Firstly, find it in current working directory - QString configPath = "preference.ini"; - if(!QFileInfo::exists(configPath)) + if(parser.isSet("config-path")) { - // Then, find it in AppConfigLocation - configPath = QStandardPaths::locate(QStandardPaths::AppConfigLocation, "preference.ini"); - if(configPath.isEmpty()) + qDebug() << "Config file path:" << parser.value("config-path"); + MySettings::init(QSettings::IniFormat, parser.value("config-path")); + } + else + { + // Firstly, find it in current working directory + QString configPath = "preference.ini"; + if(!QFileInfo::exists(configPath)) { - // If no config file is found, create one in current working directory - configPath = "preference.ini"; + // Then, find it in AppConfigLocation + configPath = QStandardPaths::locate(QStandardPaths::AppConfigLocation, "preference.ini"); + if(configPath.isEmpty() || !QFileInfo::exists(configPath)) + { + // If no config file is found, create one in current working directory + configPath = "preference.ini"; + } } + MySettings::init(QSettings::IniFormat, configPath); } - MySettings::init(QSettings::IniFormat, configPath); + #endif // set language by config file diff --git a/src/settingstab.cpp b/src/settingstab.cpp index 40f0ab2..74cff97 100644 --- a/src/settingstab.cpp +++ b/src/settingstab.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef Q_OS_ANDROID #include #endif @@ -33,6 +34,7 @@ SettingsTab::SettingsTab(QWidget *parent) : ui->Lang_nameBox->addItem(tr("Simplified Chinese"), "zh_CN"); ui->Lang_nameBox->addItem(tr("English"), "en"); ui->Lang_nameBox->addItem(tr("(External File)"), "(ext)"); + QScroller::grabGesture(ui->scrollArea); } SettingsTab::~SettingsTab() diff --git a/src/ui/devicetab.ui b/src/ui/devicetab.ui index da5fc17..e4da821 100644 --- a/src/ui/devicetab.ui +++ b/src/ui/devicetab.ui @@ -913,7 +913,7 @@ margin-bottom:3em; 0 - + QFrame::NoFrame @@ -1073,7 +1073,7 @@ margin-bottom:3em; 0 - + QFrame::NoFrame diff --git a/src/ui/settingstab.ui b/src/ui/settingstab.ui index ccb0e09..cfb83ec 100644 --- a/src/ui/settingstab.ui +++ b/src/ui/settingstab.ui @@ -38,7 +38,7 @@ 0 - -238 + 0 506 626 @@ -125,7 +125,8 @@ true - This app will use the config file in the working directory first. + You can specify the config file path by passing "--config-path <path>" option when opening it. +If the config file path is not set, this app will use the config file in the working directory first. If the file is not in the working directory, the app will will find it in the configuration directory. If no config file is detected, This app will create one in the current working directory.