chore: do something make old qt version happy

This commit is contained in:
x-tools-author 2024-03-26 16:35:03 +08:00
parent 6e73593b59
commit 3155c80174
20 changed files with 469 additions and 55 deletions

View File

@ -154,6 +154,10 @@ function(x_tools_deploy_qt_for_linux target)
endfunction()
function(x_tools_deploy_qt target)
if(NOT QT_VERSION_MAJOR EQUAL 6)
return()
endif()
if(${WINDEPLOYQT_EXECUTABLE} STREQUAL "")
return()
endif()

View File

@ -117,11 +117,7 @@ include_directories(${CMAKE_SOURCE_DIR}/Source/Assistants/FileCheck/Source)
# -------------------------------------------------------------------------------------------------
# Modbus module
if(NOT Qt${QT_VERSION_MAJOR}_VERSION VERSION_LESS "6.5.0")
option(X_TOOLS_IMPORT_MODULE_MODBUS_STUDIO "Enable Modbus Studio module" ON)
else()
option(X_TOOLS_IMPORT_MODULE_MODBUS_STUDIO "Enable Modbus Studio module" OFF)
endif()
option(X_TOOLS_IMPORT_MODULE_MODBUS_STUDIO "Enable Modbus Studio module" ON)
if(X_TOOLS_IMPORT_MODULE_MODBUS_STUDIO)
file(GLOB_RECURSE X_TOOLS_MODBUS_STUDIO_H "${CMAKE_SOURCE_DIR}/Source/ModbusStudio/*.h")
file(GLOB_RECURSE X_TOOLS_MODBUS_STUDIO_UI "${CMAKE_SOURCE_DIR}/Source/ModbusStudio/*.ui")

View File

@ -61,7 +61,7 @@ xToolsCRCAssistant::xToolsCRCAssistant(QWidget* parent)
initParameterModel();
connect(m_parameterComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCRCAssistant::changedParameterModel);
connect(m_calculatedBt, &QPushButton::clicked, this, &xToolsCRCAssistant::calculate);

View File

@ -38,7 +38,7 @@ xToolsFileCheckAssistant::xToolsFileCheckAssistant(QWidget* parent)
// Appending algorithms to combo box
#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0)
QMetaEnum algorithms = QMetaEnum::fromType<SAKToolFileCheckAssistant::Algorithm>();
QMetaEnum algorithms = QMetaEnum::fromType<xToolsFileCheckAssistant::Algorithm>();
#else
QMetaEnum algorithms = QMetaEnum::fromType<QCryptographicHash::Algorithm>();
#endif
@ -193,7 +193,7 @@ void xToolsFileCheckAssistant::onUpperCheckBoxClicked()
void xToolsFileCheckAssistant::onAlgorithmChanged(int index)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0)
QMetaEnum algorithms = QMetaEnum::fromType<SAKToolFileCheckAssistant::Algorithm>();
QMetaEnum algorithms = QMetaEnum::fromType<xToolsFileCheckAssistant::Algorithm>();
#else
QMetaEnum algorithms = QMetaEnum::fromType<QCryptographicHash::Algorithm>();
#endif

View File

@ -9,6 +9,7 @@
#include "xToolsNumberAssistant.h"
#include "ui_xToolsNumberAssistant.h"
#include "xToolsCompatibility.h"
#include "xToolsDataStructure.h"
#include "xToolsInterface.h"
@ -42,7 +43,7 @@ xToolsNumberAssistant::xToolsNumberAssistant(QWidget *parent)
this,
&xToolsNumberAssistant::updateCookedData);
connect(ui->comboBoxCookedDataType,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsNumberAssistant::onCookedDataTypeChanged);
@ -113,7 +114,7 @@ void updateRawData(QLineEdit *le, T value)
{
T *ptr = &value;
QByteArray tmp = QByteArray::fromRawData(reinterpret_cast<char *>(ptr), sizeof(T));
le->setText(tmp.toHex(' '));
le->setText(xToolsByteArrayToHex(tmp, ' '));
}
void xToolsNumberAssistant::updateRawData()

View File

@ -21,7 +21,7 @@ xToolsStringAssistant::xToolsStringAssistant(QWidget* parent)
connect(ui->textEdit, &QTextEdit::textChanged, this, &xToolsStringAssistant::onTextEditTextChanged);
connect(ui->inputFormatComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsStringAssistant::onInputFormatComboBoxCurrentIndexChanged);
connect(ui->createPushButton,

View File

@ -16,7 +16,9 @@
#include "xToolsBroadcastAssistant.h"
#include "xToolsCRCAssistant.h"
#include "xToolsFileCheckAssistant.h"
#ifdef X_TOOLS_IMPORT_MODULE_MDNS
#include "xToolsMdnsAssistant.h"
#endif
#include "xToolsNumberAssistant.h"
#include "xToolsPingAssistant.h"
#include "xToolsStringAssistant.h"
@ -25,7 +27,9 @@ SAKAssistantsFactory::SAKAssistantsFactory(QObject* parent)
: QObject(parent)
{
addAssistant<xToolsCRCAssistant>(AssistantTypeCrc, tr("CRC Assistant"));
#ifdef X_TOOLS_IMPORT_MODULE_MDNS
addAssistant<xToolsMdnsAssistant>(AssistantTypeMdns, tr("mDNS Assistant"));
#endif
addAssistant<xToolsPingAssistant>(AssistantTypePing, tr("Ping Assistant"));
addAssistant<xToolsAsciiAssistant>(AssistantTypeAscii, tr("ASCII Assistant"));
addAssistant<xToolsBase64Assisatnt>(AssistantTypeBase64, tr("Base64 Assistant"));

View File

@ -54,12 +54,15 @@ void xToolsCanBusStudioUi::initUi()
void xToolsCanBusStudioUi::initUiSelectPlugin()
{
ui->pluginComboBox->clear();
ui->pluginComboBox->addItems(QCanBus::instance()->plugins());
QList<QByteArray> plugins = QCanBus::instance()->plugins();
for (const QByteArray& plugin : plugins) {
ui->pluginComboBox->addItem(QString::fromLatin1(plugin));
}
ui->disconnectPushButton->setEnabled(false);
ui->connectPushButton->setEnabled(true);
connect(ui->pluginComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCanBusStudioUi::onPluginChanged);
connect(ui->disconnectPushButton,
@ -84,23 +87,23 @@ void xToolsCanBusStudioUi::initUiSpecifyConfiguration()
this,
&xToolsCanBusStudioUi::onCustomConfigurationChanged);
connect(ui->loopbackComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCanBusStudioUi::onLoopbackIndexChanged);
connect(ui->receivOwnComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCanBusStudioUi::onReceiveOwnIndexChanged);
connect(ui->canFdComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCanBusStudioUi::onCanFdIndexChanged);
connect(ui->bitrateComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCanBusStudioUi::onBitrateChanged);
connect(ui->dataBitrateComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCanBusStudioUi::onDataBitrateChanged);
connect(ui->customBitrateCheckBox,
@ -121,7 +124,7 @@ void xToolsCanBusStudioUi::initUiCanFrame()
ui->frameTypeComboBox->addItem(tr("RemoteRequestFrame"), QCanBusFrame::RemoteRequestFrame);
connect(ui->frameTypeComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsCanBusStudioUi::onFrameTypeChanged);
connect(ui->extendedFormatCheckBox,
@ -221,11 +224,19 @@ void xToolsCanBusStudioUi::onConnectClicked()
}
QString errorString;
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
mDevice = QCanBus::instance()->createDevice(pluginName, interfaceName, &errorString);
if (!mDevice) {
qCWarning(gLC) << errorString;
return;
}
#else
mDevice = QCanBus::instance()->createDevice(pluginName.toLatin1(), interfaceName);
if (!mDevice) {
qCWarning(gLC) << tr("Create device failed!");
return;
}
#endif
connect(mDevice, &QCanBusDevice::errorOccurred, this, &xToolsCanBusStudioUi::onErrorOccure);
connect(mDevice, &QCanBusDevice::framesReceived, this, &xToolsCanBusStudioUi::onFrameReceived);

View File

@ -102,7 +102,7 @@ static void xToolsInitApp(const QString &appName)
static void xToolsInstallMessageHandler()
{
#ifndef QT_DEBUG
#ifdef X_TOOLS_USING_GLOG
qInstallMessageHandler(qtLogToGoogleLog);
#endif
}

View File

@ -1,4 +1,4 @@
/***************************************************************************************************
/***************************************************************************************************
* Copyright 2023-2024 x-tools-author(x-tools@outlook.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part of xTools project.
@ -12,6 +12,12 @@
#include <QFileInfo>
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#define xToolsSkipEmptyParts Qt::SkipEmptyParts
#else
#define xToolsSkipEmptyParts QString::SkipEmptyParts
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#define X_TOOLS_ABSTRACT_SOCKET_ERROR_OCCURRED &QAbstractSocket::errorOccurred
#else
@ -34,3 +40,25 @@ static qint64 xToolsBirthTimeOfFile(const QFileInfo &info)
return info.created().toMSecsSinceEpoch();
#endif
}
static QByteArray xToolsByteArrayToHex(const QByteArray &source, char separator = '\0')
{
if (source.isEmpty()) {
return source;
}
auto toHex = [](quint8 value) -> char { return "0123456789abcdef"[value & 0xF]; };
const int length = separator ? (source.size() * 3 - 1) : (source.size() * 2);
QByteArray hex(length, Qt::Uninitialized);
char *hexData = hex.data();
const uchar *data = reinterpret_cast<const uchar *>(source.constData());
for (int i = 0, o = 0; i < source.size(); ++i) {
hexData[o++] = toHex(data[i] >> 4);
hexData[o++] = toHex(data[i] & 0xf);
if ((separator) && (o < length))
hexData[o++] = separator;
}
return hex;
}

View File

@ -78,7 +78,11 @@ void xToolsSettings::setHdpiPolicy(int policy)
QString xToolsSettings::appStyle()
{
#ifdef X_TOOLS_DEFAULT_APP_STYLE
return value(mSettingsKey.appStyle, X_TOOLS_DEFAULT_APP_STYLE).toString();
#else
return QString("Funcsion");
#endif
}
void xToolsSettings::setAppStyle(const QString& style)

View File

@ -423,7 +423,7 @@ void MainWindow::aboutSoftware()
QList<Info> infoList;
infoList << Info{tr("Version"), QString(qApp->applicationVersion()), false}
#ifndef SAK_RELEASE_FOR_APP_STORE
<< Info{tr("Edition"), X_TOOL_EDITION, false}
<< Info{tr("Edition"), X_TOOLS_EDITION, false}
#endif
<< Info{tr("Author"), QString(X_TOOLS_AUTHOR), false}
<< Info{tr("Email"), QString(X_TOOLS_AUTHOR_EMAIL), false}

View File

@ -39,6 +39,7 @@
#include <QModbusRtuSerialServer>
#endif
#include "xToolsCompatibility.h"
#include "xToolsModbusStudio.h"
#include "xToolsSettings.h"
@ -97,6 +98,24 @@ public:
}
};
QList<quint16> vectorTolist(const QVector<quint16> &vector)
{
QList<quint16> list;
for (int i = 0; i < vector.length(); vector.count()) {
list.append(vector.at(i));
}
return list;
}
QVector<quint16> listToVector(const QList<quint16> &list)
{
QVector<quint16> vector;
for (int i = 0; i < list.length(); list.count()) {
vector.append(list.at(i));
}
return vector;
}
xToolsModbusStudioUi::xToolsModbusStudioUi(QWidget *parent)
: QWidget{parent}
, ui(new Ui::xToolsModbusStudioUi)
@ -390,7 +409,7 @@ void xToolsModbusStudioUi::InitSignals()
void xToolsModbusStudioUi::InitSignalsDevice()
{
connect(ui->device_list_,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsModbusStudioUi::OnDeviceTypeChanged);
connect(ui->open_button_, &QPushButton::clicked, this, &xToolsModbusStudioUi::OnOpenClicked);
@ -404,7 +423,7 @@ void xToolsModbusStudioUi::InitSignalsNetworking()
this,
&xToolsModbusStudioUi::OnAddressChanged);
connect(ui->port_spin_box,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&xToolsModbusStudioUi::OnPortChanged);
}
@ -413,16 +432,16 @@ void xToolsModbusStudioUi::InitSignalsSerialPort()
{
connect(ui->port_name_, &QComboBox::currentTextChanged, this, &xToolsModbusStudioUi::OnPortNameChanged);
connect(ui->parity_,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsModbusStudioUi::OnParityChanged);
connect(ui->baud_rate_, &QComboBox::currentTextChanged, this, &xToolsModbusStudioUi::OnBaudRateChanged);
connect(ui->data_bits_,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsModbusStudioUi::OnDataBitsChanged);
connect(ui->stop_bits_,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this,
&xToolsModbusStudioUi::OnStopBistChanged);
}
@ -430,11 +449,11 @@ void xToolsModbusStudioUi::InitSignalsSerialPort()
void xToolsModbusStudioUi::InitSignalsClient()
{
connect(ui->timeout_,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&xToolsModbusStudioUi::OnClientTimeoutChanged);
connect(ui->repeat_time_,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&xToolsModbusStudioUi::OnClientRepeatTimeChanged);
}
@ -447,7 +466,7 @@ void xToolsModbusStudioUi::InitSignalsServer()
this,
&xToolsModbusStudioUi::OnServerJustListenChanged);
connect(ui->server_address,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&xToolsModbusStudioUi::OnServerAddressChanged);
}
@ -459,15 +478,15 @@ void xToolsModbusStudioUi::InitSignalsClientOperations()
this,
&xToolsModbusStudioUi::OnFunctionCodeChanged);
connect(ui->device_address_,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&xToolsModbusStudioUi::OnTargetAddressChanged);
connect(ui->start_address_,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&xToolsModbusStudioUi::OnStartAddressChanged);
connect(ui->quantity_,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
&xToolsModbusStudioUi::OnAddressNumberChanged);
connect(ui->read_, &QPushButton::clicked, this, &xToolsModbusStudioUi::OnReadClicked);
@ -698,7 +717,11 @@ void xToolsModbusStudioUi::OnReadClicked()
OutputModbusReply(reply, function_code);
if (reply->error() == QModbusDevice::NoError) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
UpdateClientTableViewData(reply->result().values());
#else
UpdateClientTableViewData(vectorTolist(reply->result().values()));
#endif
reply->deleteLater();
}
});
@ -719,7 +742,11 @@ void xToolsModbusStudioUi::OnWriteClicked()
QModbusReply *reply = factory->SendWriteRequest(modbus_device_,
registerType,
start_address,
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
values,
#else
listToVector(values),
#endif
server_address);
if (xToolsModbusStudio::Instance()->IsValidModbusReply(reply)) {
connect(reply, &QModbusReply::finished, this, [=]() {
@ -758,7 +785,7 @@ void xToolsModbusStudioUi::OnSendClicked()
qCWarning(kLoggingCategory) << "Send raw request:"
<< "server address:" << server_address
<< "function code:" << function_code
<< "data:" << QString(pdu.toHex(' '));
<< "data:" << QString(xToolsByteArrayToHex(pdu, ' '));
if (xToolsModbusStudio::Instance()->IsValidModbusReply(reply)) {
connect(reply, &QModbusReply::finished, this, [=]() {
OutputModbusReply(reply, function_code);
@ -766,7 +793,7 @@ void xToolsModbusStudioUi::OnSendClicked()
});
QString info = "pdu(No server address, no crc):";
info += QString(pdu.toHex(' '));
info += QString(xToolsByteArrayToHex(pdu, ' '));
outputMessage(info, false, TXCOLOR, TXFLAG);
}
@ -774,7 +801,7 @@ void xToolsModbusStudioUi::OnSendClicked()
int index = settings_->value(key_ctx_->send_history_index).toInt();
bool ret = WriteSettingsArray(key_ctx_->send_history,
key_ctx_->pdu,
QString(pdu.toHex(' ')),
QString(xToolsByteArrayToHex(pdu, ' ')),
index,
MAX_HISTORY_INDEX);
if (!ret) {
@ -782,9 +809,9 @@ void xToolsModbusStudioUi::OnSendClicked()
}
if (index > ui->pdu_->count()) {
ui->pdu_->addItem(QString(pdu.toHex(' ')));
ui->pdu_->addItem(QString(xToolsByteArrayToHex(pdu, ' ')));
} else {
ui->pdu_->insertItem(index, QString(pdu.toHex(' ')));
ui->pdu_->insertItem(index, QString(xToolsByteArrayToHex(pdu, ' ')));
}
index = index + 1 > MAX_HISTORY_INDEX ? 0 : index + 1;
@ -1068,7 +1095,7 @@ void xToolsModbusStudioUi::UpdateServerRegistersData()
quint8 xToolsModbusStudioUi::GetClientFunctionCode()
{
QString txt = ui->function_code_->currentText();
QStringList list = txt.split('-', Qt::SkipEmptyParts);
QStringList list = txt.split('-', xToolsSkipEmptyParts);
if (list.length()) {
return list.first().toInt(Q_NULLPTR, 16);
}
@ -1170,7 +1197,7 @@ void xToolsModbusStudioUi::OutputModbusReply(QModbusReply *reply, int function_c
"data unit: %3")
.arg(server_address)
.arg(function_code)
.arg(QString::fromLatin1(data.toHex(' ')));
.arg(QString::fromLatin1(xToolsByteArrayToHex(data, ' ')));
outputMessage(info, false, RXCOLOR, RXFLAG);
} else if (reply->type() == QModbusReply::ReplyType::Common) {
QString info = ui->function_code_->currentText();

View File

@ -63,17 +63,23 @@ xToolsToolBoxUiInputMenu::xToolsToolBoxUiInputMenu(const QString& settingsGroup,
ui->spinBoxStartIndex->setGroupKey(settingsGroup + "/input", "startIndex");
mParameters.startIndex = ui->spinBoxStartIndex->value();
connect(ui->spinBoxStartIndex, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](int) {
this->mParameters.startIndex = ui->spinBoxStartIndex->value();
emit parametersChanged();
});
connect(ui->spinBoxStartIndex,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
[=](int) {
this->mParameters.startIndex = ui->spinBoxStartIndex->value();
emit parametersChanged();
});
ui->spinBoxEndIndex->setGroupKey(settingsGroup + "/input", "endIndex");
mParameters.endIndex = ui->spinBoxEndIndex->value();
connect(ui->spinBoxEndIndex, QOverload<int>::of(&QSpinBox::valueChanged), this, [=]() {
this->mParameters.endIndex = ui->spinBoxEndIndex->value();
emit parametersChanged();
});
connect(ui->spinBoxEndIndex,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this,
[=]() {
this->mParameters.endIndex = ui->spinBoxEndIndex->value();
emit parametersChanged();
});
ui->comboBoxAglorithm->setGroupKey(settingsGroup + "/input", "algorithm");
mParameters.algorithm = ui->comboBoxAglorithm->currentData().toInt();

View File

@ -48,7 +48,7 @@ protected:
QString m_serverIp;
int m_serverPort;
QString m_bindingIpPort;
std::atomic_int8_t m_messageType;
qint8 m_messageType;
signals:
void clientIpChanged();

View File

@ -46,7 +46,7 @@ protected:
QStringList m_clients;
int m_clientIndex;
QString m_bindingIpPort;
std::atomic_int8_t m_messageType;
qint8 m_messageType;
signals:
void serverIpChanged();

View File

@ -66,11 +66,11 @@ void xToolsAnalyzerToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, const Q
bool fixed = ui->checkBoxFixedLength->isChecked();
cookedTool->setFixed(fixed);
});
connect(ui->spinBoxFrameLength, QOverload<int>::of(&QSpinBox::valueChanged), this, [=]() {
connect(ui->spinBoxFrameLength, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=]() {
int len = ui->spinBoxFrameLength->value();
cookedTool->setFrameBytes(len);
});
connect(ui->spinBoxMaxTempBytes, QOverload<int>::of(&QSpinBox::valueChanged), this, [=]() {
connect(ui->spinBoxMaxTempBytes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=]() {
int maxBytes = ui->spinBoxMaxTempBytes->value();
cookedTool->setMaxTempBytes(maxBytes);
});

View File

@ -38,15 +38,15 @@ void xToolsCrcCalculatorToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, co
ui->comboBoxAlgorithm->setCurrentIndex(crcTool->algorithm());
ui->checkBoxBigEndian->setChecked(crcTool->bigEndian());
connect(ui->spinBoxStartIndex,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
crcTool,
&xToolsCrcCalculatorTool::setStartIndex);
connect(ui->spinBoxEndIndex,
QOverload<int>::of(&QSpinBox::valueChanged),
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
crcTool,
&xToolsCrcCalculatorTool::setEndIndex);
connect(ui->comboBoxAlgorithm,
QOverload<int>::of(&QComboBox::currentIndexChanged),
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
crcTool,
&xToolsCrcCalculatorTool::setAlgorithm);
connect(ui->checkBoxBigEndian,

View File

@ -12,7 +12,9 @@
int main(const int argc, char *argv[])
{
#ifdef X_TOOLS_BUILD_WITH_CMAKE
Q_INIT_RESOURCE(xToolsCommon);
#endif
return xToolsExec<MainWindow, xToolsMainWindow, Application>(argc,
argv,
QString("xTools"),

331
xTools.pro Normal file
View File

@ -0,0 +1,331 @@
QT += core gui serialport serialbus network websockets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
#---------------------------------------------------------------------------------------------------
# Android settings
X_TOOLS_APP_NAME = "xTools"
X_TOOLS_ORG_NAME = "xTools"
X_TOOLS_ORG_DOMAIN = "IT"
X_TOOLS_APP_DESCRIPTION = "xTools Studio"
X_TOOLS_APP_COPYRIGHT = "Copyright 2018-2024 x-tools-author(x-tools@outlook.com). All rights reserved."
win32 {
QMAKE_TARGET_COMPANY = "$${X_TOOLS_ORG_NAME}"
QMAKE_TARGET_DESCRIPTION = "$${X_TOOLS_APP_DESCRIPTION}"
QMAKE_TARGET_COPYRIGHT = "$${X_TOOLS_APP_COPYRIGHT}"
QMAKE_TARGET_PRODUCT = "$${X_TOOLS_APP_NAME}"
QMAKE_TARGET_VERSION = "$${SAK_VERSION}"
}
#---------------------------------------------------------------------------------------------------
#Output directory
UI_DIR = $$OUT_PWD/ui
MOC_DIR = $$OUT_PWD/moc
RCC_DIR = $$OUT_PWD/res
OBJECTS_DIR = $$OUT_PWD/obj
#---------------------------------------------------------------------------------------------------
#Configuration of Windows
win32 {
RC_ICONS = xTools.ico
msvc:{
lessThan(QT_MAJOR_VERSION, 6){
QMAKE_CXXFLAGS += -execution-charset:utf-8
}
}
}
DEFINES += X_TOOLS_CLEAR_MESSAGE_INTERVAL=8000
DEFINES += X_TOOLS_EDITION=\"\\\"Beta\\\"\"
DEFINES += X_TOOLS_AUTHOR=\"\\\"x-tools-author\\\"\"
DEFINES += X_TOOLS_AUTHOR_EMAIL=\"\\\"x-tools@outlook.com\\\"\"
DEFINES += X_TOOLS_GITHUB_REPOSITORY_URL=\"\\\"https://github.com/x-tools-author/x-tools\\\"\"
DEFINES += X_TOOLS_GITEE_REPOSITORY_URL=\"\\\"https://gitee.com/x-tools-author/x-tools\\\"\"
INCLUDEPATH += Source
INCLUDEPATH += Source/Assistants
INCLUDEPATH += Source/Assistants/ASCII/Source
INCLUDEPATH += Source/Assistants/Base64/Source
INCLUDEPATH += Source/Assistants/Broadcast/Source
INCLUDEPATH += Source/Assistants/CRC/Source
INCLUDEPATH += Source/Assistants/FileCheck/Source
INCLUDEPATH += Source/Assistants/Number/Source
INCLUDEPATH += Source/Assistants/Ping/Source
INCLUDEPATH += Source/Assistants/String/Source
INCLUDEPATH += Source/Common/Common
INCLUDEPATH += Source/Common/CommonUI
INCLUDEPATH += Source/Tools/Tools
INCLUDEPATH += Source/Tools/ToolsUI
INCLUDEPATH += Source/ToolBox/ToolBox
INCLUDEPATH += Source/ToolBox/ToolBoxUI
INCLUDEPATH += Source/ModbusStudio/ModbusStudio
INCLUDEPATH += Source/ModbusStudio/ModbusStudioUI
INCLUDEPATH += Source/ToolBox/ToolBox
INCLUDEPATH += Source/ToolBox/ToolBoxUI
SOURCES += \
Source/Application.cpp \
Source/Assistants/ASCII/Source/xToolsAsciiAssistant.cpp \
Source/Assistants/Base64/Source/xToolsBase64Assisatnt.cpp \
Source/Assistants/Broadcast/Source/xToolsBroadcastAssistant.cpp \
Source/Assistants/Broadcast/Source/xToolsBroadcastThread.cpp \
Source/Assistants/CRC/Source/xToolsCRCAssistant.cpp \
Source/Assistants/FileCheck/Source/xToolsCryptographicHashCalculator.cpp \
Source/Assistants/FileCheck/Source/xToolsFileCheckAssistant.cpp \
Source/Assistants/Number/Source/xToolsNumberAssistant.cpp \
Source/Assistants/Ping/Source/xToolsPingAssistant.cpp \
Source/Assistants/String/Source/xToolsStringAssistant.cpp \
Source/Assistants/xToolsAssistantFactory.cpp \
Source/Common/Common/xToolsCrcInterface.cpp \
Source/Common/Common/xToolsDataStructure.cpp \
Source/Common/Common/xToolsInterface.cpp \
Source/Common/Common/xToolsNetworkInterfaceScanner.cpp \
Source/Common/Common/xToolsSerialPortScanner.cpp \
Source/Common/Common/xToolsSettings.cpp \
Source/Common/Common/xToolsTableModel.cpp \
Source/Common/CommonUI/xToolsAffixesComboBox.cpp \
Source/Common/CommonUI/xToolsApplication.cpp \
Source/Common/CommonUI/xToolsBaudRateComboBox.cpp \
Source/Common/CommonUI/xToolsCheckBox.cpp \
Source/Common/CommonUI/xToolsComboBox.cpp \
Source/Common/CommonUI/xToolsCrcAlgorithmComboBox.cpp \
Source/Common/CommonUI/xToolsDataBitsComboBox.cpp \
Source/Common/CommonUI/xToolsEscapeCharacterComboBox.cpp \
Source/Common/CommonUI/xToolsFlowControlComboBox.cpp \
Source/Common/CommonUI/xToolsHighlighter.cpp \
Source/Common/CommonUI/xToolsIpComboBox.cpp \
Source/Common/CommonUI/xToolsLineEdit.cpp \
Source/Common/CommonUI/xToolsMainWindow.cpp \
Source/Common/CommonUI/xToolsMenu.cpp \
Source/Common/CommonUI/xToolsParityComboBox.cpp \
Source/Common/CommonUI/xToolsPortNameComboBox.cpp \
Source/Common/CommonUI/xToolsResponseOptionComboBox.cpp \
Source/Common/CommonUI/xToolsSpinBox.cpp \
Source/Common/CommonUI/xToolsStopBitsComboBox.cpp \
Source/Common/CommonUI/xToolsTextFormatComboBox.cpp \
Source/Common/CommonUI/xToolsUiInterface.cpp \
Source/Common/CommonUI/xToolsWebSocketMessageTypeComboBox.cpp \
Source/ModbusStudio/ModbusStudio/xToolsModbusStudio.cpp \
Source/ModbusStudio/ModbusStudioUI/xToolsModbusStudioUi.cpp \
Source/SystemTrayIcon.cpp \
Source/ToolBox/ToolBox/xToolsToolBox.cpp \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUi.cpp \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiCommunicationMenu.cpp \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiFactory.cpp \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiInputMenu.cpp \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiOutputMenu.cpp \
Source/Tools/Tools/xToolsAnalyzerTool.cpp \
Source/Tools/Tools/xToolsBaseTool.cpp \
Source/Tools/Tools/xToolsCommunicationTool.cpp \
Source/Tools/Tools/xToolsCrcCalculatorTool.cpp \
Source/Tools/Tools/xToolsEmitterTool.cpp \
Source/Tools/Tools/xToolsMaskerTool.cpp \
Source/Tools/Tools/xToolsPrestorerTool.cpp \
Source/Tools/Tools/xToolsResponserTool.cpp \
Source/Tools/Tools/xToolsSerialPortTool.cpp \
Source/Tools/Tools/xToolsSerialPortTransmitterTool.cpp \
Source/Tools/Tools/xToolsSocketClientTool.cpp \
Source/Tools/Tools/xToolsSocketClientTransmitterTool.cpp \
Source/Tools/Tools/xToolsSocketServerTool.cpp \
Source/Tools/Tools/xToolsStatisticianTool.cpp \
Source/Tools/Tools/xToolsStorerTool.cpp \
Source/Tools/Tools/xToolsTableModelTool.cpp \
Source/Tools/Tools/xToolsTcpClientTool.cpp \
Source/Tools/Tools/xToolsTcpServerTool.cpp \
Source/Tools/Tools/xToolsTcpTransmitterTool.cpp \
Source/Tools/Tools/xToolsToolFactory.cpp \
Source/Tools/Tools/xToolsTransmitterTool.cpp \
Source/Tools/Tools/xToolsUdpClientTool.cpp \
Source/Tools/Tools/xToolsUdpServerTool.cpp \
Source/Tools/Tools/xToolsUdpTransmitterTool.cpp \
Source/Tools/Tools/xToolsVelometerTool.cpp \
Source/Tools/Tools/xToolsWebSocketClientTool.cpp \
Source/Tools/Tools/xToolsWebSocketServerTool.cpp \
Source/Tools/Tools/xToolsWebSocketTransmitterTool.cpp \
Source/Tools/ToolsUI/xToolsAnalyzerToolUi.cpp \
Source/Tools/ToolsUI/xToolsBaseToolUi.cpp \
Source/Tools/ToolsUI/xToolsCommunicationToolUi.cpp \
Source/Tools/ToolsUI/xToolsCrcCalculatorToolUi.cpp \
Source/Tools/ToolsUI/xToolsEmitterToolUi.cpp \
Source/Tools/ToolsUI/xToolsEmitterToolUiEditor.cpp \
Source/Tools/ToolsUI/xToolsMaskerToolUi.cpp \
Source/Tools/ToolsUI/xToolsPrestorerToolUi.cpp \
Source/Tools/ToolsUI/xToolsPrestorerToolUiEditor.cpp \
Source/Tools/ToolsUI/xToolsResponserToolUi.cpp \
Source/Tools/ToolsUI/xToolsResponserToolUiEditor.cpp \
Source/Tools/ToolsUI/xToolsSerialPortToolUi.cpp \
Source/Tools/ToolsUI/xToolsSerialPortTransmitterToolUi.cpp \
Source/Tools/ToolsUI/xToolsSerialPortTransmitterToolUiEditor.cpp \
Source/Tools/ToolsUI/xToolsSocketClientToolUi.cpp \
Source/Tools/ToolsUI/xToolsSocketClientTransmitterToolUi.cpp \
Source/Tools/ToolsUI/xToolsSocketClientTransmitterToolUiEditor.cpp \
Source/Tools/ToolsUI/xToolsSocketServerToolUi.cpp \
Source/Tools/ToolsUI/xToolsStatisticianToolUi.cpp \
Source/Tools/ToolsUI/xToolsStorerToolUi.cpp \
Source/Tools/ToolsUI/xToolsTableModelToolUi.cpp \
Source/Tools/ToolsUI/xToolsTableViewToolUi.cpp \
Source/Tools/ToolsUI/xToolsTcpTransmitterToolUi.cpp \
Source/Tools/ToolsUI/xToolsToolUiFactory.cpp \
Source/Tools/ToolsUI/xToolsTransmitterToolUi.cpp \
Source/Tools/ToolsUI/xToolsUdpTransmitterToolUi.cpp \
Source/Tools/ToolsUI/xToolsVelometerToolUi.cpp \
Source/Tools/ToolsUI/xToolsWebSocketTransmitterToolUi.cpp \
Source/main.cpp \
Source/MainWindow.cpp
HEADERS += \
Source/Application.h \
Source/Assistants/ASCII/Source/xToolsAsciiAssistant.h \
Source/Assistants/Base64/Source/xToolsBase64Assisatnt.h \
Source/Assistants/Broadcast/Source/xToolsBroadcastAssistant.h \
Source/Assistants/Broadcast/Source/xToolsBroadcastThread.h \
Source/Assistants/CRC/Source/xToolsCRCAssistant.h \
Source/Assistants/FileCheck/Source/xToolsCryptographicHashCalculator.h \
Source/Assistants/FileCheck/Source/xToolsFileCheckAssistant.h \
Source/Assistants/Number/Source/xToolsNumberAssistant.h \
Source/Assistants/Ping/Source/xToolsPingAssistant.h \
Source/Assistants/String/Source/xToolsStringAssistant.h \
Source/Assistants/xToolsAssistantFactory.h \
Source/Common/Common/xTools.h \
Source/Common/Common/xToolsCompatibility.h \
Source/Common/Common/xToolsCrcInterface.h \
Source/Common/Common/xToolsDataStructure.h \
Source/Common/Common/xToolsInterface.h \
Source/Common/Common/xToolsNetworkInterfaceScanner.h \
Source/Common/Common/xToolsSerialPortScanner.h \
Source/Common/Common/xToolsSettings.h \
Source/Common/Common/xToolsTableModel.h \
Source/Common/CommonUI/xToolsAffixesComboBox.h \
Source/Common/CommonUI/xToolsApplication.h \
Source/Common/CommonUI/xToolsBaudRateComboBox.h \
Source/Common/CommonUI/xToolsCheckBox.h \
Source/Common/CommonUI/xToolsComboBox.h \
Source/Common/CommonUI/xToolsCrcAlgorithmComboBox.h \
Source/Common/CommonUI/xToolsDataBitsComboBox.h \
Source/Common/CommonUI/xToolsEscapeCharacterComboBox.h \
Source/Common/CommonUI/xToolsFlowControlComboBox.h \
Source/Common/CommonUI/xToolsHighlighter.h \
Source/Common/CommonUI/xToolsIpComboBox.h \
Source/Common/CommonUI/xToolsLineEdit.h \
Source/Common/CommonUI/xToolsMainWindow.h \
Source/Common/CommonUI/xToolsMenu.h \
Source/Common/CommonUI/xToolsParityComboBox.h \
Source/Common/CommonUI/xToolsPortNameComboBox.h \
Source/Common/CommonUI/xToolsResponseOptionComboBox.h \
Source/Common/CommonUI/xToolsSpinBox.h \
Source/Common/CommonUI/xToolsStopBitsComboBox.h \
Source/Common/CommonUI/xToolsTextFormatComboBox.h \
Source/Common/CommonUI/xToolsUi.h \
Source/Common/CommonUI/xToolsUiInterface.h \
Source/Common/CommonUI/xToolsWebSocketMessageTypeComboBox.h \
Source/MainWindow.h \
Source/ModbusStudio/ModbusStudio/xToolsModbusStudio.h \
Source/ModbusStudio/ModbusStudioUI/xToolsModbusStudioUi.h \
Source/SystemTrayIcon.h \
Source/ToolBox/ToolBox/xToolsToolBox.h \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUi.h \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiCommunicationMenu.h \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiFactory.h \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiInputMenu.h \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiOutputMenu.h \
Source/Tools/Tools/xToolsAnalyzerTool.h \
Source/Tools/Tools/xToolsBaseTool.h \
Source/Tools/Tools/xToolsCommunicationTool.h \
Source/Tools/Tools/xToolsCrcCalculatorTool.h \
Source/Tools/Tools/xToolsEmitterTool.h \
Source/Tools/Tools/xToolsMaskerTool.h \
Source/Tools/Tools/xToolsPrestorerTool.h \
Source/Tools/Tools/xToolsResponserTool.h \
Source/Tools/Tools/xToolsSerialPortTool.h \
Source/Tools/Tools/xToolsSerialPortTransmitterTool.h \
Source/Tools/Tools/xToolsSocketClientTool.h \
Source/Tools/Tools/xToolsSocketClientTransmitterTool.h \
Source/Tools/Tools/xToolsSocketServerTool.h \
Source/Tools/Tools/xToolsStatisticianTool.h \
Source/Tools/Tools/xToolsStorerTool.h \
Source/Tools/Tools/xToolsTableModelTool.h \
Source/Tools/Tools/xToolsTcpClientTool.h \
Source/Tools/Tools/xToolsTcpServerTool.h \
Source/Tools/Tools/xToolsTcpTransmitterTool.h \
Source/Tools/Tools/xToolsToolFactory.h \
Source/Tools/Tools/xToolsTransmitterTool.h \
Source/Tools/Tools/xToolsUdpClientTool.h \
Source/Tools/Tools/xToolsUdpServerTool.h \
Source/Tools/Tools/xToolsUdpTransmitterTool.h \
Source/Tools/Tools/xToolsVelometerTool.h \
Source/Tools/Tools/xToolsWebSocketClientTool.h \
Source/Tools/Tools/xToolsWebSocketServerTool.h \
Source/Tools/Tools/xToolsWebSocketTransmitterTool.h \
Source/Tools/ToolsUI/xToolsAnalyzerToolUi.h \
Source/Tools/ToolsUI/xToolsBaseToolUi.h \
Source/Tools/ToolsUI/xToolsCommunicationToolUi.h \
Source/Tools/ToolsUI/xToolsCrcCalculatorToolUi.h \
Source/Tools/ToolsUI/xToolsEmitterToolUi.h \
Source/Tools/ToolsUI/xToolsEmitterToolUiEditor.h \
Source/Tools/ToolsUI/xToolsMaskerToolUi.h \
Source/Tools/ToolsUI/xToolsPrestorerToolUi.h \
Source/Tools/ToolsUI/xToolsPrestorerToolUiEditor.h \
Source/Tools/ToolsUI/xToolsResponserToolUi.h \
Source/Tools/ToolsUI/xToolsResponserToolUiEditor.h \
Source/Tools/ToolsUI/xToolsSerialPortToolUi.h \
Source/Tools/ToolsUI/xToolsSerialPortTransmitterToolUi.h \
Source/Tools/ToolsUI/xToolsSerialPortTransmitterToolUiEditor.h \
Source/Tools/ToolsUI/xToolsSocketClientToolUi.h \
Source/Tools/ToolsUI/xToolsSocketClientTransmitterToolUi.h \
Source/Tools/ToolsUI/xToolsSocketClientTransmitterToolUiEditor.h \
Source/Tools/ToolsUI/xToolsSocketServerToolUi.h \
Source/Tools/ToolsUI/xToolsStatisticianToolUi.h \
Source/Tools/ToolsUI/xToolsStorerToolUi.h \
Source/Tools/ToolsUI/xToolsTableModelToolUi.h \
Source/Tools/ToolsUI/xToolsTableViewToolUi.h \
Source/Tools/ToolsUI/xToolsTcpTransmitterToolUi.h \
Source/Tools/ToolsUI/xToolsToolUiFactory.h \
Source/Tools/ToolsUI/xToolsTransmitterToolUi.h \
Source/Tools/ToolsUI/xToolsUdpTransmitterToolUi.h \
Source/Tools/ToolsUI/xToolsVelometerToolUi.h \
Source/Tools/ToolsUI/xToolsWebSocketTransmitterToolUi.h
RESOURCES += \
xTools.qrc \
Source/Common/xToolsCommon.qrc
FORMS += \
Source/Assistants/ASCII/Source/xToolsAsciiAssistant.ui \
Source/Assistants/Base64/Source/xToolsBase64Assisatnt.ui \
Source/Assistants/Broadcast/Source/xToolsBroadcastAssistant.ui \
Source/Assistants/CRC/Source/xToolsCRCAssistant.ui \
Source/Assistants/FileCheck/Source/xToolsFileCheckAssistant.ui \
Source/Assistants/Number/Source/xToolsNumberAssistant.ui \
Source/Assistants/Ping/Source/xToolsPingAssistant.ui \
Source/Assistants/String/Source/xToolsStringAssistant.ui \
Source/ModbusStudio/ModbusStudioUI/xToolsModbusStudioUi.ui \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUi.ui \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiCommunicationMenu.ui \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiInputMenu.ui \
Source/ToolBox/ToolBoxUI/xToolsToolBoxUiOutputMenu.ui \
Source/Tools/ToolsUI/xToolsAnalyzerToolUi.ui \
Source/Tools/ToolsUI/xToolsCrcCalculatorToolUi.ui \
Source/Tools/ToolsUI/xToolsEmitterToolUi.ui \
Source/Tools/ToolsUI/xToolsEmitterToolUiEditor.ui \
Source/Tools/ToolsUI/xToolsMaskerToolUi.ui \
Source/Tools/ToolsUI/xToolsPrestorerToolUiEditor.ui \
Source/Tools/ToolsUI/xToolsResponserToolUiEditor.ui \
Source/Tools/ToolsUI/xToolsSerialPortToolUi.ui \
Source/Tools/ToolsUI/xToolsSerialPortTransmitterToolUiEditor.ui \
Source/Tools/ToolsUI/xToolsSocketClientToolUi.ui \
Source/Tools/ToolsUI/xToolsSocketClientTransmitterToolUiEditor.ui \
Source/Tools/ToolsUI/xToolsSocketServerToolUi.ui \
Source/Tools/ToolsUI/xToolsStatisticianToolUi.ui \
Source/Tools/ToolsUI/xToolsStorerToolUi.ui \
Source/Tools/ToolsUI/xToolsTableModelToolUi.ui \
Source/Tools/ToolsUI/xToolsVelometerToolUi.ui