mirror of
https://github.com/x-tools-author/x-tools.git
synced 2025-09-15 15:28:40 +08:00
chore: update files of project
This commit is contained in:
parent
5d1fd21d29
commit
818ac0450a
@ -19,11 +19,10 @@ if(X_TOOLS_BUILD_FOR_STORE)
|
||||
endif()
|
||||
|
||||
set(X_TOOLS_QT_COMPONENTS Core Gui Widgets WebSockets Network)
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
||||
list(APPEND X_TOOLS_QT_COMPONENTS SerialPort)
|
||||
list(APPEND X_TOOLS_QT_COMPONENTS SerialBus)
|
||||
# add_compile_definitions(X_TOOLS_IMPORT_MODULE_SERIALPORT)
|
||||
add_compile_definitions(X_TOOLS_IMPORT_MODULE_SERIALPORT)
|
||||
add_compile_definitions(X_TOOLS_IMPORT_MODULE_SERIALBUS)
|
||||
endif()
|
||||
|
||||
@ -152,7 +151,7 @@ target_link_libraries(xTools PRIVATE Qt${QT_VERSION_MAJOR}::Gui)
|
||||
target_link_libraries(xTools PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
target_link_libraries(xTools PRIVATE Qt${QT_VERSION_MAJOR}::Network)
|
||||
target_link_libraries(xTools PRIVATE Qt${QT_VERSION_MAJOR}::WebSockets)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
|
||||
target_link_libraries(xTools PRIVATE Qt${QT_VERSION_MAJOR}::SerialPort)
|
||||
target_link_libraries(xTools PRIVATE Qt${QT_VERSION_MAJOR}::SerialBus)
|
||||
endif()
|
||||
@ -163,7 +162,17 @@ if(X_TOOLS_IMPORT_MODULE_BLUETOOTH)
|
||||
endif()
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Assistants
|
||||
option(X_TOOLS_ENABLE_APP_ASSISTANTS "Enable assistant applications" OFF)
|
||||
if(X_TOOLS_ENABLE_APP_ASSISTANTS)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/Source/Assistants)
|
||||
endif()
|
||||
|
||||
option(X_TOOLS_ENABLE_APP_MODBUS_STUDIO "Enable Modbus Studio application" OFF)
|
||||
if(X_TOOLS_ENABLE_APP_MODBUS_STUDIO)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/Source/ModbusStudio)
|
||||
endif()
|
||||
|
||||
option(X_TOOLS_ENABLE_APP_CANBUS_STUDIO "Enable CANBus Studio application" OFF)
|
||||
if(X_TOOLS_ENABLE_APP_CANBUS_STUDIO)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/Source/CANBusStudio)
|
||||
endif()
|
||||
|
||||
@ -263,92 +263,6 @@ void xToolsInterface::setLineEditValidator(QLineEdit *lineEdit,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_SERIALPORT
|
||||
void xToolsInterface::addSerialPortNametItemsToComboBox(QComboBox *comboBox)
|
||||
{
|
||||
if (comboBox) {
|
||||
comboBox->clear();
|
||||
QList<QSerialPortInfo> coms = QSerialPortInfo::availablePorts();
|
||||
QStandardItemModel *itemModel = new QStandardItemModel(comboBox);
|
||||
for (auto &var : coms) {
|
||||
QStandardItem *item = new QStandardItem(var.portName());
|
||||
item->setToolTip(var.description());
|
||||
itemModel->appendRow(item);
|
||||
}
|
||||
|
||||
comboBox->setModel(itemModel);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_SERIALPORT
|
||||
void xToolsInterface::addSerialPortBaudRateItemsToComboBox(QComboBox *comboBox)
|
||||
{
|
||||
if (comboBox) {
|
||||
comboBox->clear();
|
||||
QList<qint32> bd = QSerialPortInfo::standardBaudRates();
|
||||
for (auto &var : bd) {
|
||||
comboBox->addItem(QString::number(var), QVariant::fromValue(var));
|
||||
}
|
||||
|
||||
comboBox->setCurrentText("9600");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_SERIALPORT
|
||||
void xToolsInterface::addSerialPortDataBitItemsToComboBox(QComboBox *comboBox)
|
||||
{
|
||||
if (comboBox) {
|
||||
comboBox->clear();
|
||||
comboBox->addItem("8", QVariant::fromValue(int(QSerialPort::Data8)));
|
||||
comboBox->addItem("7", QVariant::fromValue(int(QSerialPort::Data7)));
|
||||
comboBox->addItem("6", QVariant::fromValue(int(QSerialPort::Data6)));
|
||||
comboBox->addItem("5", QVariant::fromValue(int(QSerialPort::Data5)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_SERIALPORT
|
||||
void xToolsInterface::addSerialPortStopBitItemsToComboBox(QComboBox *comboBox)
|
||||
{
|
||||
if (comboBox) {
|
||||
comboBox->clear();
|
||||
comboBox->addItem("1", QVariant::fromValue(int(QSerialPort::OneStop)));
|
||||
#ifdef Q_OS_WINDOWS
|
||||
comboBox->addItem("1.5", QVariant::fromValue(int(QSerialPort::OneAndHalfStop)));
|
||||
#endif
|
||||
comboBox->addItem("2", QVariant::fromValue(int(QSerialPort::TwoStop)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_SERIALPORT
|
||||
void xToolsInterface::addSerialPortParityItemsToComboBox(QComboBox *comboBox)
|
||||
{
|
||||
if (comboBox) {
|
||||
comboBox->clear();
|
||||
comboBox->addItem(tr("No"), QVariant::fromValue(int(QSerialPort::NoParity)));
|
||||
comboBox->addItem(tr("Even"), QVariant::fromValue(int(QSerialPort::EvenParity)));
|
||||
comboBox->addItem(tr("Odd"), QVariant::fromValue(int(QSerialPort::OddParity)));
|
||||
comboBox->addItem(tr("Space"), QVariant::fromValue(int(QSerialPort::SpaceParity)));
|
||||
comboBox->addItem(tr("Mark"), QVariant::fromValue(int(QSerialPort::MarkParity)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_SERIALPORT
|
||||
void xToolsInterface::addSerialPortFlowControlItemsToComboBox(QComboBox *comboBox)
|
||||
{
|
||||
if (comboBox) {
|
||||
comboBox->clear();
|
||||
comboBox->addItem(tr("No"), QVariant::fromValue(int(QSerialPort::NoFlowControl)));
|
||||
comboBox->addItem(tr("Hardware"), QVariant::fromValue(int(QSerialPort::HardwareControl)));
|
||||
comboBox->addItem(tr("Software"), QVariant::fromValue(int(QSerialPort::SoftwareControl)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void xToolsInterface::setComboBoxIndexFromSettings(QSettings *settings,
|
||||
QString key,
|
||||
QComboBox *comboBox)
|
||||
@ -367,7 +281,9 @@ void xToolsInterface::setSettingsValueFromComboBoxIndex(QSettings *settings,
|
||||
settings->setValue(key, currentIndex);
|
||||
}
|
||||
|
||||
void xToolsInterface::setLineEditTextFromSettings(QSettings *settings, QString key, QLineEdit *lineEdit)
|
||||
void xToolsInterface::setLineEditTextFromSettings(QSettings *settings,
|
||||
QString key,
|
||||
QLineEdit *lineEdit)
|
||||
{
|
||||
QString text = settings->value(key).toString();
|
||||
if (!text.isEmpty()) {
|
||||
|
||||
@ -92,15 +92,6 @@ public:
|
||||
static void setLineEditValidator(QLineEdit *lineEdit,
|
||||
SAKEnumValidatorType type,
|
||||
int maxLength = INT_MAX);
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_SERIALPORT
|
||||
// Serialport interfaces
|
||||
static void addSerialPortNametItemsToComboBox(QComboBox *comboBox);
|
||||
static void addSerialPortBaudRateItemsToComboBox(QComboBox *comboBox);
|
||||
static void addSerialPortDataBitItemsToComboBox(QComboBox *comboBox);
|
||||
static void addSerialPortStopBitItemsToComboBox(QComboBox *comboBox);
|
||||
static void addSerialPortParityItemsToComboBox(QComboBox *comboBox);
|
||||
static void addSerialPortFlowControlItemsToComboBox(QComboBox *comboBox);
|
||||
#endif
|
||||
static void setComboBoxIndexFromSettings(QSettings *settings, QString key, QComboBox *comboBox);
|
||||
static void setSettingsValueFromComboBoxIndex(QSettings *settings,
|
||||
QString key,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user