完成QTableview pagecontrol 控制,更新串口配置的串口名称设置,添加读取配置文件处理
parent
246153fc8f
commit
1d8c55ea70
|
@ -0,0 +1,77 @@
|
|||
#include "aboutdialog.h"
|
||||
#include "ui_aboutdialog.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
#include <QPushButton>
|
||||
#include <QStandardItemModel>
|
||||
#include <QDate>
|
||||
#include <QFont>
|
||||
|
||||
#define MAJOR_VERSION 1
|
||||
#define MINOR_VERSION 0
|
||||
#define BUILD_VERSION 0
|
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AboutDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||||
this->setWindowTitle(tr("About EMU Configurer Kit"));
|
||||
|
||||
QPixmap pixmap(":/images/hj-net.png");
|
||||
pixmap = pixmap.scaled(250, 75, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
|
||||
ui->label_logo->setPixmap(pixmap);
|
||||
|
||||
ui->buttonBox->clear();
|
||||
QPushButton *okButton = ui->buttonBox->addButton(QDialogButtonBox::Ok);
|
||||
okButton->setFixedSize(100, 30);
|
||||
|
||||
QFont font("Arial", 14, QFont::Bold);
|
||||
ui->productName->setFont(font);
|
||||
ui->productName->setText(QString(tr("Configurer Kit for EMU Host")));
|
||||
|
||||
QStandardItemModel *model = new QStandardItemModel(this);
|
||||
|
||||
QString version = QString(tr("Version %1.%2.%3")).arg(MAJOR_VERSION).arg(MINOR_VERSION).arg(BUILD_VERSION);
|
||||
|
||||
QString formattedDate;
|
||||
QDate date = QDate::fromString(__DATE__, "MMM dd yyyy");
|
||||
if (date.isValid())
|
||||
{
|
||||
formattedDate = date.toString("yyyy-MM-dd"); // 输出格式: 2024-11-12
|
||||
formattedDate += QString(" %1").arg(__TIME__);
|
||||
}
|
||||
else
|
||||
{
|
||||
formattedDate = "Invalid Date";
|
||||
}
|
||||
|
||||
QString compileDate = QString(tr("Compiled on %1"))
|
||||
.arg(formattedDate);
|
||||
|
||||
// 添加一些字符串到模型中
|
||||
QStringList stringList;
|
||||
stringList << version
|
||||
<< compileDate;
|
||||
|
||||
// 将每个字符串作为 QStandardItem 添加到模型中
|
||||
for (const QString &str : stringList)
|
||||
{
|
||||
QStandardItem *item = new QStandardItem(str);
|
||||
model->appendRow(item);
|
||||
}
|
||||
|
||||
// 将模型设置到 QListView
|
||||
ui->listView->setModel(model);
|
||||
|
||||
setFixedSize(640, 480);
|
||||
|
||||
}
|
||||
|
||||
AboutDialog::~AboutDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef ABOUTDIALOG_H
|
||||
#define ABOUTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class AboutDialog;
|
||||
}
|
||||
|
||||
class AboutDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutDialog(QWidget *parent = nullptr);
|
||||
~AboutDialog();
|
||||
|
||||
private:
|
||||
Ui::AboutDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ABOUTDIALOG_H
|
|
@ -0,0 +1,131 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AboutDialog</class>
|
||||
<widget class="QDialog" name="AboutDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About Configurer ...</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>420</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_logo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>261</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WWW.HJ-NET.COM</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListView" name="listView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>120</y>
|
||||
<width>621</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::IgnoreAction</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="productName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>601</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AboutDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AboutDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -8,6 +8,8 @@
|
|||
#include <QPushButton>
|
||||
#include <QScrollBar>
|
||||
#include <QHeaderView>
|
||||
#include <QSpinBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "globalparameters.h"
|
||||
#include "mytablemodel.h"
|
||||
|
@ -16,13 +18,19 @@
|
|||
#define PER_PAGE_SIZE (30)
|
||||
|
||||
DevicePropertyPage::DevicePropertyPage(QWidget *parent) :
|
||||
QWidget(parent),m_pTableView(nullptr),m_pButton(nullptr)
|
||||
QWidget(parent),m_nDownCounter(0),m_pTableView(nullptr),m_pButton(nullptr),m_totalPageCount(0),m_currentPage(0)
|
||||
{
|
||||
InitializeTable();
|
||||
|
||||
m_pTimer = new QTimer(this);
|
||||
connect(m_pTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
|
||||
//m_pTimer->start(AppData::getInstance()->nTimeOut);
|
||||
|
||||
m_pDownCounterTimer = new QTimer(this);
|
||||
connect(m_pDownCounterTimer, SIGNAL(timeout()), this, SLOT(handleDownCounter()));
|
||||
|
||||
updatePageButtonState();
|
||||
updatePageLabel();
|
||||
}
|
||||
|
||||
DevicePropertyPage::~DevicePropertyPage()
|
||||
|
@ -33,15 +41,18 @@ void DevicePropertyPage::handleTimeout()
|
|||
{
|
||||
if(m_pTimer->isActive())
|
||||
{
|
||||
m_pTimer->stop();
|
||||
|
||||
Refresh();
|
||||
|
||||
int nInterval = 5000;
|
||||
m_pTimer->start(nInterval*1000);
|
||||
}
|
||||
}
|
||||
|
||||
void DevicePropertyPage::handleDownCounter()
|
||||
{
|
||||
m_nDownCounter--;
|
||||
m_pDownCounterLabel->setText(QString("%1").arg(m_nDownCounter));
|
||||
if (m_nDownCounter == 0)
|
||||
m_nDownCounter = m_pTimerIntervalSpinBox->value();
|
||||
}
|
||||
|
||||
void DevicePropertyPage::InitializeTableView(MyTableModel *model, QTableView *tableView)
|
||||
{
|
||||
//设置tableview的model
|
||||
|
@ -56,6 +67,8 @@ void DevicePropertyPage::InitializeTableView(MyTableModel *model, QTableView *ta
|
|||
|
||||
pHeaderView->setHidden(false); //false 显示行号列 true Hide
|
||||
|
||||
pHeaderView->setStretchLastSection(true); //设置充满表宽度
|
||||
|
||||
//pHeaderView->setVisible(true);
|
||||
//pHeaderView->setFixedHeight(40);
|
||||
|
||||
|
@ -103,6 +116,7 @@ void DevicePropertyPage::InitializeTableView(MyTableModel *model, QTableView *ta
|
|||
tableView->setColumnWidth(2,base);
|
||||
tableView->setColumnWidth(3,base-40);
|
||||
tableView->setColumnWidth(4,base+60);
|
||||
tableView->setColumnWidth(5,base+60);
|
||||
#endif
|
||||
|
||||
tableView->show();
|
||||
|
@ -114,13 +128,21 @@ void DevicePropertyPage::InitializeTable()
|
|||
m_myModel->setHeadData(AppData::getInstance()->lstDataTableHeaderText);
|
||||
|
||||
m_pTableView = new QTableView(this);
|
||||
m_pButton = new QPushButton(tr("Refresh"), this);
|
||||
|
||||
//m_pButton = new QPushButton(tr("Refresh"), this);
|
||||
// 设置固定大小和位置的按钮
|
||||
//m_pButton->setFixedSize(100, 30); // 设置按钮的固定大小
|
||||
|
||||
m_pFirstButton = new QPushButton(tr("First"), this);
|
||||
m_pForwardButton = new QPushButton(tr("Forward"), this);
|
||||
m_pNextButton = new QPushButton(tr("Next"), this);
|
||||
m_pLastButton = new QPushButton(tr("Last"), this);
|
||||
|
||||
m_pFirstButton->setFixedSize(80, 30); // 设置按钮的固定大小
|
||||
m_pForwardButton->setFixedSize(80, 30); // 设置按钮的固定大小
|
||||
m_pNextButton->setFixedSize(80, 30); // 设置按钮的固定大小
|
||||
m_pLastButton->setFixedSize(80, 30); // 设置按钮的固定大小
|
||||
|
||||
m_pGotoPageNumberLineEdit = new QLineEdit(tr("1"), this);
|
||||
m_pGotoPageNumberLineEdit->setFixedWidth(40);
|
||||
m_pValidator = new QIntValidator(this);
|
||||
|
@ -128,10 +150,26 @@ void DevicePropertyPage::InitializeTable()
|
|||
m_pValidator->setRange(0, 100);
|
||||
|
||||
m_pGotoPageNumberLabel = new QLabel(tr("Page"), this);
|
||||
m_pGotoPageNumberButton = new QPushButton(tr("Goto"), this);
|
||||
m_pGotoPageNumberButton = new QPushButton(tr("Go"), this);
|
||||
m_pGotoPageNumberButton->setFixedSize(40, 30);
|
||||
|
||||
m_pPagesLabel = new QLabel(tr("Total %d Pages, Current No.%d Page"), this);
|
||||
|
||||
// 设置字体为粗体
|
||||
QFont font = m_pPagesLabel->font();
|
||||
font.setBold(true); // 设置为粗体
|
||||
m_pPagesLabel->setFont(font);
|
||||
|
||||
// 创建一个QSpinBox,范围为10到100
|
||||
m_pTimerIntervalSpinBox = new QSpinBox(this);
|
||||
m_pTimerIntervalSpinBox->setRange(15, 300); // 设置范围为10到100
|
||||
m_pTimerIntervalSpinBox->setValue(15); // 默认值设为10
|
||||
|
||||
m_pRefreshCheckBox = new QCheckBox(tr("Auto Refresh"), this);
|
||||
m_pDownCounterLabel = new QLabel(tr("0"), this);
|
||||
|
||||
m_pDownCounterLabel->setFont(font);
|
||||
|
||||
// 创建主布局
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
|
||||
|
@ -139,9 +177,25 @@ void DevicePropertyPage::InitializeTable()
|
|||
|
||||
mainLayout->addWidget(m_pTableView);
|
||||
|
||||
// 创建一个水平布局来包含按钮
|
||||
QHBoxLayout *buttonLayout0 = new QHBoxLayout();
|
||||
//buttonLayout0->addStretch(); // 让按钮保持在右侧
|
||||
buttonLayout0->setContentsMargins(0, 0, 0, 0); // 取消按钮的边距
|
||||
|
||||
// 添加标签、QSpinBox到布局
|
||||
buttonLayout0->addWidget(new QLabel(tr("Interval(Sec.)"), this));
|
||||
buttonLayout0->addWidget(m_pTimerIntervalSpinBox);
|
||||
buttonLayout0->addWidget(m_pRefreshCheckBox);
|
||||
buttonLayout0->addWidget(m_pDownCounterLabel);
|
||||
m_pDownCounterLabel->setVisible(false);
|
||||
|
||||
|
||||
QSpacerItem *spacer2 = new QSpacerItem(10, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
buttonLayout0->addItem(spacer2);
|
||||
|
||||
// 创建一个水平布局来包含按钮
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||
buttonLayout->addStretch(); // 让按钮保持在右侧
|
||||
//buttonLayout->addStretch(); // 让按钮保持在右侧
|
||||
|
||||
buttonLayout->addWidget(m_pPagesLabel);
|
||||
QSpacerItem *spacer0 = new QSpacerItem(10, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
@ -160,23 +214,24 @@ void DevicePropertyPage::InitializeTable()
|
|||
buttonLayout->addWidget(m_pGotoPageNumberLineEdit);
|
||||
buttonLayout->addWidget(m_pGotoPageNumberButton);
|
||||
|
||||
buttonLayout->addWidget(m_pButton);
|
||||
//buttonLayout->addWidget(m_pButton);
|
||||
|
||||
buttonLayout->setContentsMargins(0, 0, 0, 0); // 取消按钮的边距
|
||||
|
||||
// 将表格视图和按钮布局添加到主布局
|
||||
mainLayout->addLayout(buttonLayout0);
|
||||
mainLayout->addLayout(buttonLayout);
|
||||
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0); // 取消主布局的边距
|
||||
mainLayout->setSpacing(10); // 取消布局间的间距
|
||||
|
||||
// 设置固定大小和位置的按钮
|
||||
m_pButton->setFixedSize(100, 30); // 设置按钮的固定大小
|
||||
|
||||
// 连接信号和槽
|
||||
connect(m_pTableView, &QTableView::doubleClicked, this, &DevicePropertyPage::onTableViewDoubleClicked);
|
||||
connect(m_pButton, &QPushButton::clicked, this, &DevicePropertyPage::onButtonClicked);
|
||||
|
||||
connect(m_pRefreshCheckBox, &QCheckBox::stateChanged, this, &DevicePropertyPage::CheckRefresh);
|
||||
|
||||
connect(m_pFirstButton, &QPushButton::clicked, this, &DevicePropertyPage::onFirstButtonClicked);
|
||||
connect(m_pLastButton, &QPushButton::clicked, this, &DevicePropertyPage::onLastButtonClicked);
|
||||
connect(m_pForwardButton, &QPushButton::clicked, this, &DevicePropertyPage::onForwardButtonClicked);
|
||||
|
@ -186,6 +241,46 @@ void DevicePropertyPage::InitializeTable()
|
|||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void DevicePropertyPage::CheckRefresh(int state)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
{
|
||||
qDebug() << "Checkbox is checked";
|
||||
|
||||
Refresh();
|
||||
|
||||
pageTo(1);
|
||||
|
||||
int nInterver = m_pTimerIntervalSpinBox->value() * 1000;
|
||||
m_pTimer->start(nInterver);
|
||||
|
||||
m_nDownCounter = m_pTimerIntervalSpinBox->value();
|
||||
m_pDownCounterLabel->setText(QString("%1").arg(m_nDownCounter));
|
||||
|
||||
m_pDownCounterTimer->start(1000);
|
||||
m_pDownCounterLabel->setVisible(true);
|
||||
|
||||
}
|
||||
else if (state == Qt::Unchecked)
|
||||
{
|
||||
qDebug() << "Checkbox is unchecked";
|
||||
if (m_pTimer->isActive())
|
||||
{
|
||||
m_pTimer->stop();
|
||||
}
|
||||
if (m_pDownCounterTimer->isActive())
|
||||
{
|
||||
m_pDownCounterTimer->stop();
|
||||
};
|
||||
|
||||
m_pDownCounterLabel->setVisible(false);
|
||||
m_pDownCounterLabel->setText("0");
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Checkbox is in an indeterminate state";
|
||||
}
|
||||
}
|
||||
void DevicePropertyPage::setBaseType(unsigned int base, unsigned int mask)
|
||||
{
|
||||
filterBaseType = base;
|
||||
|
@ -213,6 +308,30 @@ void DevicePropertyPage::Refresh()
|
|||
QGuiApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void DevicePropertyPage::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
// 检查是否按下特定按键
|
||||
switch(event->key())
|
||||
{
|
||||
case Qt::Key_PageDown:
|
||||
{
|
||||
if (m_currentPage < m_totalPageCount)
|
||||
onNextButtonClicked();
|
||||
break;
|
||||
}
|
||||
|
||||
case Qt::Key_PageUp:
|
||||
{
|
||||
if (m_currentPage > 1)
|
||||
onForwardButtonClicked();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理其他按键,调用基类的 keyPressEvent
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
int DevicePropertyPage::PageDataProcess()
|
||||
{
|
||||
//获取数据总数
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QIntValidator>
|
||||
#include <QSpinBox>
|
||||
#include <QCheckBox>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "datafetcher.h"
|
||||
|
||||
|
@ -27,9 +30,12 @@ public:
|
|||
|
||||
public slots:
|
||||
void handleTimeout(); //超时处理函数
|
||||
void handleDownCounter(); //倒计时
|
||||
|
||||
private:
|
||||
QTimer *m_pTimer;
|
||||
QTimer *m_pDownCounterTimer;
|
||||
int m_nDownCounter;
|
||||
|
||||
private:
|
||||
MyTableModel* m_myModel;
|
||||
|
@ -53,6 +59,9 @@ protected:
|
|||
//翻倒第i页
|
||||
void pageTo(int page);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void onButtonClicked();
|
||||
|
||||
|
@ -63,6 +72,7 @@ private slots:
|
|||
void onForwardButtonClicked();
|
||||
void onNextButtonClicked();
|
||||
void onGotoButtonClicked();
|
||||
void CheckRefresh(int state);
|
||||
|
||||
private:
|
||||
unsigned int filterBaseType;
|
||||
|
@ -80,6 +90,9 @@ private:
|
|||
QLineEdit* m_pGotoPageNumberLineEdit;
|
||||
QPushButton* m_pGotoPageNumberButton;
|
||||
|
||||
QCheckBox *m_pRefreshCheckBox;
|
||||
QSpinBox* m_pTimerIntervalSpinBox;
|
||||
QLabel* m_pDownCounterLabel;
|
||||
QLabel* m_pPagesLabel;
|
||||
|
||||
QVector<int> columnWidths; // 存储初始列宽
|
||||
|
|
|
@ -74,10 +74,12 @@ win32:LIBS += Ws2_32.lib
|
|||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
aboutdialog.cpp \
|
||||
datafetcher.cpp \
|
||||
devicepropertypage.cpp \
|
||||
formserialportsettingdialog.cpp \
|
||||
globalparameters.cpp \
|
||||
ipaddress.cpp \
|
||||
kutilities.cpp \
|
||||
main.cpp \
|
||||
maindialog.cpp \
|
||||
|
@ -87,10 +89,12 @@ SOURCES += \
|
|||
ziputils.cpp
|
||||
|
||||
HEADERS += \
|
||||
aboutdialog.h \
|
||||
datafetcher.h \
|
||||
devicepropertypage.h \
|
||||
formserialportsettingdialog.h \
|
||||
globalparameters.h \
|
||||
ipaddress.h \
|
||||
kutilities.h \
|
||||
maindialog.h \
|
||||
mainwindow.h \
|
||||
|
@ -103,6 +107,7 @@ HEADERS += \
|
|||
frame_define.h
|
||||
|
||||
FORMS += \
|
||||
aboutdialog.ui \
|
||||
formserialportsettingdialog.ui \
|
||||
maindialog.ui \
|
||||
mainwindow.ui
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[serialport]
|
||||
number=10
|
||||
prefix=/dev/ttymxc
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <QListView>
|
||||
#include <QStandardItemModel>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "globalparameters.h"
|
||||
|
||||
|
@ -152,4 +154,48 @@ void FormSerialPortSettingDialog::InitializeUi()
|
|||
}
|
||||
|
||||
ui->cb_type->setModel(model_type);
|
||||
|
||||
ui->toolButton->setFixedSize(40, 30);
|
||||
|
||||
ui->buttonBox->clear();
|
||||
QPushButton *okButton = ui->buttonBox->addButton(QDialogButtonBox::Ok);
|
||||
QPushButton *cancelButton = ui->buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||
okButton->setFixedSize(100, 30);
|
||||
cancelButton->setFixedSize(100, 30);
|
||||
|
||||
//设置串口号
|
||||
ui->cb_serialport->setView(new QListView(this));
|
||||
|
||||
QStandardItemModel* model_serialport = new QStandardItemModel(this);
|
||||
|
||||
for (int i=0; i < AppData::getInstance()->SerialPortCount ; i++)
|
||||
{
|
||||
QString name = AppData::getInstance()->SerialPortPrefix + QString("%1").arg(i);
|
||||
|
||||
QStandardItem* item = new QStandardItem(name);
|
||||
//QVariant var = QVariant::fromValue(data);
|
||||
item->setData(name);
|
||||
model_serialport->appendRow(item);
|
||||
}
|
||||
|
||||
ui->cb_serialport->setModel(model_serialport);
|
||||
|
||||
connect(okButton, &QPushButton::clicked, this, &FormSerialPortSettingDialog::onOkClicked);
|
||||
connect(cancelButton, &QPushButton::clicked, this, &FormSerialPortSettingDialog::onCancelClicked);
|
||||
connect(ui->toolButton, &QPushButton::clicked, this, &FormSerialPortSettingDialog::onToolButtonClicked);
|
||||
}
|
||||
|
||||
void FormSerialPortSettingDialog::onOkClicked()
|
||||
{
|
||||
QMessageBox::information(this, "onOkClicked", "Refresh");
|
||||
}
|
||||
|
||||
void FormSerialPortSettingDialog::onCancelClicked()
|
||||
{
|
||||
QMessageBox::information(this, "onCancelClicked", "Refresh");
|
||||
}
|
||||
|
||||
void FormSerialPortSettingDialog::onToolButtonClicked()
|
||||
{
|
||||
QMessageBox::information(this, "onToolButtonClicked", "Refresh");
|
||||
}
|
||||
|
|
|
@ -21,6 +21,11 @@ private:
|
|||
|
||||
protected:
|
||||
void InitializeUi();
|
||||
|
||||
private slots:
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
void onToolButtonClicked();
|
||||
};
|
||||
|
||||
#endif // FORMSERIALPORTSETTINGDIALOG_H
|
||||
|
|
|
@ -2,14 +2,29 @@
|
|||
<ui version="4.0">
|
||||
<class>FormSerialPortSettingDialog</class>
|
||||
<widget class="QDialog" name="FormSerialPortSettingDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>706</width>
|
||||
<width>726</width>
|
||||
<height>526</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>726</width>
|
||||
<height>526</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>726</width>
|
||||
<height>526</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>设备串口设置</string>
|
||||
</property>
|
||||
|
@ -29,9 +44,6 @@
|
|||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="device_name">
|
||||
<property name="geometry">
|
||||
|
@ -149,19 +161,6 @@
|
|||
<property name="text">
|
||||
<string>串口号</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>port</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="port">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>160</y>
|
||||
<width>181</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
|
@ -488,6 +487,16 @@
|
|||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_serialport">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>160</y>
|
||||
<width>181</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>device_id</tabstop>
|
||||
|
@ -495,7 +504,7 @@
|
|||
<tabstop>device_manufature</tabstop>
|
||||
<tabstop>cb_type</tabstop>
|
||||
<tabstop>slave_id</tabstop>
|
||||
<tabstop>port</tabstop>
|
||||
<tabstop>cb_serialport</tabstop>
|
||||
<tabstop>cb_baund</tabstop>
|
||||
<tabstop>cb_data</tabstop>
|
||||
<tabstop>cb_parity</tabstop>
|
||||
|
@ -506,8 +515,8 @@
|
|||
<tabstop>checkBox_DTS</tabstop>
|
||||
<tabstop>checkBox_CTS</tabstop>
|
||||
<tabstop>checkBox_DTR</tabstop>
|
||||
<tabstop>toolButton</tabstop>
|
||||
<tabstop>so_file</tabstop>
|
||||
<tabstop>toolButton</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="emscfgres.qrc"/>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <QHeaderView>
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QSettings>
|
||||
|
||||
#include <hv/hlog.h>
|
||||
|
||||
|
@ -13,6 +14,8 @@
|
|||
#include "mytablemodel.h"
|
||||
#include "kutilities.h"
|
||||
|
||||
#define INI_SETTING_FILE "emscfger.conf"
|
||||
|
||||
AppData::~AppData()
|
||||
{
|
||||
}
|
||||
|
@ -23,7 +26,8 @@ AppData::AppData(token)
|
|||
<< ("Parameter")
|
||||
<< ("Value")
|
||||
<< ("Unit")
|
||||
<< ("Time");
|
||||
<< ("Time")
|
||||
<< ("");
|
||||
|
||||
nTimeOut = 5000;
|
||||
qsDestinationIp = "127.0.0.1";
|
||||
|
@ -32,6 +36,14 @@ AppData::AppData(token)
|
|||
|
||||
}
|
||||
|
||||
bool AppData::readConfiguration(QString iniFile)
|
||||
{
|
||||
QSettings settings(iniFile, QSettings::IniFormat);
|
||||
SerialPortCount = settings.value("serialport/number", "10").toInt();
|
||||
SerialPortPrefix = settings.value("serialport/prefix", "/dev/ttymxc").toString();
|
||||
return false;
|
||||
}
|
||||
|
||||
AppCommon::AppCommon(token)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
AppData(const AppData &other) = delete;
|
||||
AppData& operator=(const AppData &other) = delete;
|
||||
|
||||
bool readConfiguration(QString iniFile);
|
||||
public:
|
||||
//数据表格的表头
|
||||
QStringList lstDataTableHeaderText;
|
||||
|
@ -117,6 +118,11 @@ public:
|
|||
|
||||
//最后的错误信息
|
||||
QString qsLastErrorString;
|
||||
|
||||
//串口数量
|
||||
int SerialPortCount;
|
||||
//串口字符串前缀
|
||||
QString SerialPortPrefix;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
#pragma execution_character_set("utf-8")
|
||||
|
||||
#include "ipaddress.h"
|
||||
#include "qlabel.h"
|
||||
#include "qlineedit.h"
|
||||
#include "qboxlayout.h"
|
||||
#include "qregexp.h"
|
||||
#include "qvalidator.h"
|
||||
#include "qevent.h"
|
||||
|
||||
IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->initForm();
|
||||
}
|
||||
|
||||
bool IPAddress::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QLineEdit *txt = (QLineEdit *)watched;
|
||||
if (txt == txtIP1 || txt == txtIP2 || txt == txtIP3 || txt == txtIP4)
|
||||
{
|
||||
QKeyEvent *key = (QKeyEvent *)event;
|
||||
|
||||
//如果当前按下了小数点则移动焦点到下一个输入框
|
||||
if (key->text() == ".")
|
||||
{
|
||||
this->focusNextChild();
|
||||
}
|
||||
|
||||
//如果按下了退格键并且当前文本框已经没有了内容则焦点往前移
|
||||
if (key->key() == Qt::Key_Backspace)
|
||||
{
|
||||
if (txt->text().length() <= 1)
|
||||
{
|
||||
this->focusNextPrevChild(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void IPAddress::initForm()
|
||||
{
|
||||
bgColor = "#FFFFFF";
|
||||
borderColor = "#A6B5B8";
|
||||
borderRadius = 3;
|
||||
|
||||
//用于显示小圆点的标签,居中对齐
|
||||
labDot1 = new QLabel;
|
||||
labDot1->setAlignment(Qt::AlignCenter);
|
||||
labDot1->setText(".");
|
||||
|
||||
labDot2 = new QLabel;
|
||||
labDot2->setAlignment(Qt::AlignCenter);
|
||||
labDot2->setText(".");
|
||||
|
||||
labDot3 = new QLabel;
|
||||
labDot3->setAlignment(Qt::AlignCenter);
|
||||
labDot3->setText(".");
|
||||
|
||||
//用于输入IP地址的文本框,居中对齐
|
||||
txtIP1 = new QLineEdit;
|
||||
txtIP1->setObjectName("txtIP1");
|
||||
txtIP1->setAlignment(Qt::AlignCenter);
|
||||
txtIP1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
connect(txtIP1, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
|
||||
|
||||
txtIP2 = new QLineEdit;
|
||||
txtIP2->setObjectName("txtIP2");
|
||||
txtIP2->setAlignment(Qt::AlignCenter);
|
||||
txtIP2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
connect(txtIP2, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
|
||||
|
||||
txtIP3 = new QLineEdit;
|
||||
txtIP3->setObjectName("txtIP3");
|
||||
txtIP3->setAlignment(Qt::AlignCenter);
|
||||
txtIP3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
connect(txtIP3, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
|
||||
|
||||
txtIP4 = new QLineEdit;
|
||||
txtIP4->setObjectName("txtIP4");
|
||||
txtIP4->setAlignment(Qt::AlignCenter);
|
||||
txtIP4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
connect(txtIP4, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
|
||||
|
||||
//设置IP地址校验过滤
|
||||
QRegExp regExp("(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})");
|
||||
txtIP1->setValidator(new QRegExpValidator(regExp, this));
|
||||
txtIP2->setValidator(new QRegExpValidator(regExp, this));
|
||||
txtIP3->setValidator(new QRegExpValidator(regExp, this));
|
||||
txtIP4->setValidator(new QRegExpValidator(regExp, this));
|
||||
|
||||
//绑定事件过滤器,识别键盘按下
|
||||
txtIP1->installEventFilter(this);
|
||||
txtIP2->installEventFilter(this);
|
||||
txtIP3->installEventFilter(this);
|
||||
txtIP4->installEventFilter(this);
|
||||
|
||||
QFrame *frame = new QFrame;
|
||||
frame->setObjectName("frameIP");
|
||||
|
||||
QStringList qss;
|
||||
qss.append(QString("QFrame#frameIP{border:1px solid %1;border-radius:%2px;}").arg(borderColor).arg(borderRadius));
|
||||
qss.append(QString("QLabel{min-width:15px;background-color:%1;}").arg(bgColor));
|
||||
qss.append(QString("QLineEdit{background-color:%1;border:none;}").arg(bgColor));
|
||||
qss.append(QString("QLineEdit#txtIP1{border-top-left-radius:%1px;border-bottom-left-radius:%1px;}").arg(borderRadius));
|
||||
qss.append(QString("QLineEdit#txtIP4{border-top-right-radius:%1px;border-bottom-right-radius:%1px;}").arg(borderRadius));
|
||||
frame->setStyleSheet(qss.join(""));
|
||||
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->setMargin(0);
|
||||
verticalLayout->setSpacing(0);
|
||||
verticalLayout->addWidget(frame);
|
||||
|
||||
//将控件按照横向布局排列
|
||||
QHBoxLayout *layout = new QHBoxLayout(frame);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(txtIP1);
|
||||
layout->addWidget(labDot1);
|
||||
layout->addWidget(txtIP2);
|
||||
layout->addWidget(labDot2);
|
||||
layout->addWidget(txtIP3);
|
||||
layout->addWidget(labDot3);
|
||||
layout->addWidget(txtIP4);
|
||||
}
|
||||
|
||||
void IPAddress::textChanged(const QString &text)
|
||||
{
|
||||
int len = text.length();
|
||||
int value = text.toInt();
|
||||
|
||||
//判断当前是否输入完成一个网段,是的话则自动移动到下一个输入框
|
||||
if (len == 3)
|
||||
{
|
||||
if (value >= 100 && value <= 255)
|
||||
{
|
||||
this->focusNextChild();
|
||||
}
|
||||
}
|
||||
|
||||
//拼接成完整IP地址
|
||||
ip = QString("%1.%2.%3.%4").arg(txtIP1->text()).arg(txtIP2->text()).arg(txtIP3->text()).arg(txtIP4->text());
|
||||
}
|
||||
|
||||
QString IPAddress::getIP() const
|
||||
{
|
||||
return this->ip;
|
||||
}
|
||||
|
||||
QSize IPAddress::sizeHint() const
|
||||
{
|
||||
return QSize(250, 20);
|
||||
}
|
||||
|
||||
QSize IPAddress::minimumSizeHint() const
|
||||
{
|
||||
return QSize(30, 10);
|
||||
}
|
||||
|
||||
void IPAddress::setIP(const QString &ip)
|
||||
{
|
||||
//先检测IP地址是否合法
|
||||
QRegExp regExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");
|
||||
if (!regExp.exactMatch(ip))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->ip != ip)
|
||||
{
|
||||
this->ip = ip;
|
||||
|
||||
//将IP地址填入各个网段
|
||||
QStringList list = ip.split(".");
|
||||
txtIP1->setText(list.at(0));
|
||||
txtIP2->setText(list.at(1));
|
||||
txtIP3->setText(list.at(2));
|
||||
txtIP4->setText(list.at(3));
|
||||
}
|
||||
}
|
||||
|
||||
void IPAddress::clear()
|
||||
{
|
||||
txtIP1->clear();
|
||||
txtIP2->clear();
|
||||
txtIP3->clear();
|
||||
txtIP4->clear();
|
||||
txtIP1->setFocus();
|
||||
}
|
||||
|
||||
void IPAddress::setBgColor(const QString &bgColor)
|
||||
{
|
||||
if (this->bgColor != bgColor)
|
||||
{
|
||||
this->bgColor = bgColor;
|
||||
}
|
||||
}
|
||||
|
||||
void IPAddress::setBorderColor(const QString &borderColor)
|
||||
{
|
||||
if (this->borderColor != borderColor)
|
||||
{
|
||||
this->borderColor = borderColor;
|
||||
}
|
||||
}
|
||||
|
||||
void IPAddress::setBorderRadius(int borderRadius)
|
||||
{
|
||||
if (this->borderRadius != borderRadius)
|
||||
{
|
||||
this->borderRadius = borderRadius;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef IPADDRESS_H
|
||||
#define IPADDRESS_H
|
||||
|
||||
/**
|
||||
* IP地址输入框控件 作者:feiyangqingyun(QQ:517216493) 2017-8-11
|
||||
* 1:可设置IP地址,自动填入框
|
||||
* 2:可清空IP地址
|
||||
* 3:支持按下小圆点自动切换
|
||||
* 4:支持退格键自动切换
|
||||
* 5:支持IP地址过滤
|
||||
* 6:可设置背景色/边框颜色/边框圆角角度
|
||||
*/
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainterPath>
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
|
||||
class IPAddress : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString ip READ getIP WRITE setIP)
|
||||
|
||||
public:
|
||||
explicit IPAddress(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
QLabel *labDot1; //第一个小圆点
|
||||
QLabel *labDot2; //第二个小圆点
|
||||
QLabel *labDot3; //第三个小圆点
|
||||
|
||||
QLineEdit *txtIP1; //IP地址网段输入框1
|
||||
QLineEdit *txtIP2; //IP地址网段输入框2
|
||||
QLineEdit *txtIP3; //IP地址网段输入框3
|
||||
QLineEdit *txtIP4; //IP地址网段输入框4
|
||||
|
||||
QString ip; //IP地址
|
||||
QString bgColor; //背景颜色
|
||||
QString borderColor;//边框颜色
|
||||
int borderRadius; //边框圆角角度
|
||||
|
||||
private slots:
|
||||
void initForm();
|
||||
void textChanged(const QString &text);
|
||||
|
||||
public:
|
||||
//获取IP地址
|
||||
QString getIP() const;
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
//设置IP地址
|
||||
void setIP(const QString &ip);
|
||||
//清空
|
||||
void clear();
|
||||
|
||||
//设置背景颜色
|
||||
void setBgColor(const QString &bgColor);
|
||||
//设置边框颜色
|
||||
void setBorderColor(const QString &borderColor);
|
||||
//设置边框圆角角度
|
||||
void setBorderRadius(int borderRadius);
|
||||
|
||||
};
|
||||
|
||||
#endif // IPADDRESS_H
|
|
@ -12,6 +12,7 @@
|
|||
#include <QStyleFactory>
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
||||
#include <hv/hv.h>
|
||||
#include <hv/hmain.h>
|
||||
|
@ -20,6 +21,7 @@
|
|||
#include <hv/hsocket.h>
|
||||
#include <hv/hssl.h>
|
||||
|
||||
#include "globalparameters.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -85,6 +87,10 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
//读取配置
|
||||
QString iniFilePath = QDir(appDir).filePath("emscfger.conf");
|
||||
AppData::getInstance()->readConfiguration(iniFilePath);
|
||||
|
||||
MainWindow w;
|
||||
//隐藏(不显示)最大化最小化按钮
|
||||
w.setWindowFlags(w.windowFlags()&~Qt::WindowMinMaxButtonsHint);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "kutilities.h"
|
||||
#include "devicepropertypage.h"
|
||||
#include "formserialportsettingdialog.h"
|
||||
#include "aboutdialog.h"
|
||||
|
||||
MainDialog::MainDialog(QWidget *parent) :
|
||||
QMainWindow (parent),
|
||||
|
@ -27,6 +28,7 @@ MainDialog::MainDialog(QWidget *parent) :
|
|||
//ui->setupUi(this);
|
||||
|
||||
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||||
this->setWindowTitle(tr("EMU Configurer Kit"));
|
||||
|
||||
InitializeUI();
|
||||
|
||||
|
@ -102,9 +104,6 @@ void MainDialog::InitializeUI()
|
|||
// Set central widget
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
// Set initial size of the dialog
|
||||
setWindowTitle(tr("EMS Configurer "));
|
||||
|
||||
//resize(800, 600);
|
||||
|
||||
setMinimumSize(1024, 768);
|
||||
|
@ -222,9 +221,11 @@ void MainDialog::loadWindowState()
|
|||
//增加设备
|
||||
void MainDialog::onToolButton1Clicked()
|
||||
{
|
||||
FormSerialPortSettingDialog dlg;
|
||||
dlg.setModal(true);
|
||||
if(dlg.exec() == QDialog::Accepted)
|
||||
FormSerialPortSettingDialog* dlg = new FormSerialPortSettingDialog(this);
|
||||
dlg->setWindowFlags(dlg->windowFlags()&~(Qt::WindowMinMaxButtonsHint|Qt::WindowContextHelpButtonHint));
|
||||
//dlg.setModal(true);
|
||||
dlg->show();
|
||||
if(dlg->exec() == QDialog::Accepted)
|
||||
QMessageBox::information(this, "OK Clicked", "Button 1 was clicked!");
|
||||
else
|
||||
QMessageBox::information(this, "Cancel Clicked", "Cancel was clicked!");
|
||||
|
@ -239,7 +240,12 @@ void MainDialog::onToolButton2Clicked()
|
|||
//关于
|
||||
void MainDialog::onAboutButtonClicked()
|
||||
{
|
||||
QMessageBox::information(this, "Button Clicked", "About");
|
||||
AboutDialog *aboutDlg = new AboutDialog(this);
|
||||
aboutDlg->setWindowFlags(aboutDlg->windowFlags()&~(Qt::WindowMinMaxButtonsHint|Qt::WindowContextHelpButtonHint));
|
||||
//aboutDlg->setWindowFlags(aboutDlg->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
|
||||
aboutDlg->setStyleSheet("border-radius: 4px;"); // 定制圆角
|
||||
aboutDlg->show();
|
||||
}
|
||||
|
||||
//刷新
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
#include "ui_mainwindow.h"
|
||||
#include <QPixmap>
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
#include <hv/hlog.h>
|
||||
#include "MainDialog.h"
|
||||
#include "mysqlutils.h"
|
||||
#include "kutilities.h"
|
||||
#include "ipaddress.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
|
@ -16,7 +15,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
, m_pMainDialog(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||||
this->setWindowTitle(tr("EMU Configurer Kit"));
|
||||
|
||||
QPixmap pixmap(":/images/hj-net.png");
|
||||
pixmap = pixmap.scaled(250, 75, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
|
||||
|
@ -24,13 +25,20 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
QString qsLineEditStyle("QLineEdit { min-height: 20px; min-width: 120px; }");
|
||||
ui->userToken->setStyleSheet(qsLineEditStyle);
|
||||
ui->serverIp->setStyleSheet(qsLineEditStyle);
|
||||
|
||||
QRegularExpression rx("^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$");
|
||||
QRegularExpressionValidator* ipValidator = new QRegularExpressionValidator(rx, this);
|
||||
ui->serverIp->setValidator(ipValidator);
|
||||
setIp("127.0.0.1");
|
||||
//setIp("192.168.0.155");
|
||||
ui->serverIP->setIP("127.0.0.1");
|
||||
|
||||
ui->pb_Logon->setFixedSize(100, 30);
|
||||
ui->pb_Close->setFixedSize(100, 30);
|
||||
ui->pb_Test->setFixedSize(45, 25);
|
||||
|
||||
QFont font("Arial", 24, QFont::Bold);
|
||||
ui->productName1->setText(tr("Configurer Kit"));
|
||||
ui->productName1->setFont(font);
|
||||
|
||||
QFont font2("Arial", 12, QFont::Bold);
|
||||
ui->productName2->setText(tr("for EMU Host"));
|
||||
ui->productName2->setFont(font2);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -45,13 +53,13 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::setIp(const QString &ip)
|
||||
{
|
||||
ui->serverIp->setText(ip);
|
||||
ui->serverIP->setIP(ip);
|
||||
}
|
||||
|
||||
bool MainWindow::testDatabase()
|
||||
{
|
||||
CWaitorCursor wait;
|
||||
QString svr = ui->serverIp->text();
|
||||
QString svr = ui->serverIP->getIP();
|
||||
std::string dbserver = svr.toStdString(); //"tcp://192.168.4.254";
|
||||
int dbport = 3306;
|
||||
std::string dbuser = "root";
|
||||
|
@ -78,7 +86,7 @@ bool MainWindow::testServerEcho()
|
|||
{
|
||||
using namespace hv;
|
||||
|
||||
QString svr = ui->serverIp->text();
|
||||
QString svr = ui->serverIP->getIP();
|
||||
|
||||
int connfd = AppTcpClient::getInstance()->Initialize(svr,DEVICE_SERVER_PORT);
|
||||
if (connfd <= 0)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>615</width>
|
||||
<height>362</height>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
|
@ -27,7 +27,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>183</y>
|
||||
<y>173</y>
|
||||
<width>101</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
|
@ -36,11 +36,11 @@
|
|||
<string>Host IP</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="productName1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>50</y>
|
||||
<y>70</y>
|
||||
<width>391</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
|
@ -58,20 +58,7 @@
|
|||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="serverIp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>180</y>
|
||||
<width>121</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<widget class="QLabel" name="productName2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
|
@ -96,10 +83,10 @@
|
|||
<widget class="QPushButton" name="pb_Test">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>180</y>
|
||||
<x>440</x>
|
||||
<y>170</y>
|
||||
<width>51</width>
|
||||
<height>21</height>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -123,7 +110,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>287</y>
|
||||
<y>300</y>
|
||||
<width>251</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
|
@ -162,9 +149,9 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>240</y>
|
||||
<width>181</width>
|
||||
<height>23</height>
|
||||
<y>250</y>
|
||||
<width>180</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
|
@ -197,7 +184,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>240</y>
|
||||
<y>250</y>
|
||||
<width>101</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
|
@ -211,13 +198,38 @@
|
|||
<rect>
|
||||
<x>250</x>
|
||||
<y>210</y>
|
||||
<width>180</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="IPAddress" name="serverIP" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>170</y>
|
||||
<width>181</width>
|
||||
<height>23</height>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>IPAddress</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ipaddress.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>pb_Test</tabstop>
|
||||
<tabstop>userName</tabstop>
|
||||
<tabstop>userToken</tabstop>
|
||||
<tabstop>pb_Logon</tabstop>
|
||||
<tabstop>pb_Close</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in New Issue