diff --git a/protoDebuger/NetSelect.qml b/protoDebuger/NetSelect.qml index ae2cef6..96b8be4 100644 --- a/protoDebuger/NetSelect.qml +++ b/protoDebuger/NetSelect.qml @@ -44,15 +44,25 @@ Item { wrapMode: Text.NoWrap font.pointSize: 20 } + + TextEdit { id: port Layout.leftMargin: 20 - width: 80 + Layout.topMargin: 20 + width: 233 height: 40 text: qsTr("9001") + font.italic: false + font.bold: true + Layout.columnSpan: 2 + Layout.preferredHeight: 33 + Layout.preferredWidth: 233 selectionColor: "#f0f0f1" cursorVisible: true - font.pixelSize: 18 + font.pixelSize: 20 + color: white + textMargin: 4 } RadioButton { id: isServer @@ -138,6 +148,7 @@ Item { wrapMode: Text.NoWrap font.pointSize: 20 } + TextEdit { id: hostEdit Layout.leftMargin: 20 diff --git a/protoDebuger/ProtoDebug.qml b/protoDebuger/ProtoDebug.qml index 42c1ec8..0c094fd 100644 --- a/protoDebuger/ProtoDebug.qml +++ b/protoDebuger/ProtoDebug.qml @@ -119,7 +119,6 @@ Item { onClicked: { lua_script_text = lua_script.text let ret = DataWrap.saveLuaScript(lua_script_text) - console.log(ret) if(ret != 0){ tip.text = "保存lua脚本失败" tip.visible = true @@ -150,6 +149,31 @@ Item { } + Rectangle { + Layout.preferredHeight: 41 + Layout.preferredWidth: input.contentWidth<300 ? 300 : input.contentWidth + 10 + + color: "lightgrey" + border.color: "grey" + Layout.bottomMargin: 10 + + TextInput { + id: input + anchors.fill: parent + anchors.margins: 2 + font.pointSize: 15 + focus: true + } + } + Button { + id: button1 + text: qsTr("执行命令") + Layout.bottomMargin: 10 + onClicked: { + + } + } + } } } diff --git a/protoDebuger/main.cpp b/protoDebuger/main.cpp index 4ab0a17..9395edb 100644 --- a/protoDebuger/main.cpp +++ b/protoDebuger/main.cpp @@ -15,24 +15,15 @@ #include "lua_wraper.h" #include "mainwindow.h" -#define test1 293 int main(int argc, char *argv[]) { - qDebug()<setResizeMode(QQuickWidget::SizeRootObjectToView ); -// m_quickWidget->setSource(source); -// m_quickWidget->rootContext()->setContextProperty("DataWrap",&gGlobal); -// m_quickWidget->show(); -// gGlobal.SetQuickView(m_quickWidget); return app.exec(); } diff --git a/protoDebuger/main.qml b/protoDebuger/main.qml index 9a2e7b1..b2c0d31 100644 --- a/protoDebuger/main.qml +++ b/protoDebuger/main.qml @@ -39,7 +39,6 @@ Rectangle { proto_debug.visible = false } background: Image { - anchors.fill: parent source: "qrc:///res/serial.svg" } } @@ -62,7 +61,6 @@ Rectangle { } background: Image { - anchors.fill: parent source: "qrc:///res/net.svg" } onPressed:{ @@ -93,10 +91,8 @@ Rectangle { DataWrap.getValFromQml(1) } background: Image { - anchors.fill: parent source: "qrc:///res/proto.svg" } - } Text { id: label_proto @@ -121,7 +117,6 @@ Rectangle { DataWrap.getValFromQml(1) } background: Image { - anchors.fill: parent source: "qrc:///res/proto.svg" } diff --git a/protoDebuger/mainwindow.cpp b/protoDebuger/mainwindow.cpp index e18a5a1..acf5ce3 100644 --- a/protoDebuger/mainwindow.cpp +++ b/protoDebuger/mainwindow.cpp @@ -8,7 +8,7 @@ #include "sharedata.h" #include -ShareData gGlobal; +QmlShareData gGlobal; MainWindow::MainWindow(QWidget *parent) : @@ -22,10 +22,8 @@ MainWindow::MainWindow(QWidget *parent) : m_quickWidget->setSource(source); m_quickWidget->rootContext()->setContextProperty("DataWrap",&gGlobal); - gGlobal.SetQuickView(m_quickWidget); ui->centralwidget->layout()->addWidget(m_quickWidget); - } MainWindow::~MainWindow() diff --git a/protoDebuger/mainwindow.ui b/protoDebuger/mainwindow.ui index a684504..ff8f1be 100644 --- a/protoDebuger/mainwindow.ui +++ b/protoDebuger/mainwindow.ui @@ -16,6 +16,11 @@ 600 + + + Arial + + MainWindow diff --git a/protoDebuger/sharedata.cpp b/protoDebuger/sharedata.cpp index c6bf166..e4e7e83 100644 --- a/protoDebuger/sharedata.cpp +++ b/protoDebuger/sharedata.cpp @@ -6,7 +6,8 @@ #include #include -ShareData::ShareData(QObject *parent) : QObject(parent), + +QmlShareData::QmlShareData(QObject *parent) : QObject(parent), m_qml_view_(nullptr), m_luavm_status_(false) { @@ -25,7 +26,7 @@ ShareData::ShareData(QObject *parent) : QObject(parent), } } -int ShareData::SetQuickView(QQuickWidget *view) +int QmlShareData::SetQuickView(QQuickWidget *view) { QStringList comList; const auto infos = QSerialPortInfo::availablePorts(); @@ -47,20 +48,20 @@ int ShareData::SetQuickView(QQuickWidget *view) } -int ShareData::OnDataRecv(QByteArray arr) +int QmlShareData::OnDataRecv(QByteArray arr) { if(m_luavm_status_) m_lua_.OnSerialData(QString(arr)); } -int ShareData::ShowDataInQML(QString x) +int QmlShareData::ShowDataInQML(QString x) { if(nullptr != m_qml_protodebug_){ QMetaObject::invokeMethod(m_qml_protodebug_, "addString",Q_ARG(QVariant, x)); } } -int ShareData::SendUartData(const char *data) +int QmlShareData::SendUartData(const char *data) { if(nullptr != data){ this->m_serial_controller_->SendData((char *)data,strlen(data)); @@ -69,7 +70,7 @@ int ShareData::SendUartData(const char *data) return -1; } -int ShareData::openUart(QString port, QString baudRate, QString dataBits, QString stopBits, QString flow) +int QmlShareData::openUart(QString port, QString baudRate, QString dataBits, QString stopBits, QString flow) { if(m_serial_controller_->OpenSerial(port,baudRate,dataBits,stopBits,flow) == 0){ m_serial_controller_->SetListener(this); @@ -79,7 +80,7 @@ int ShareData::openUart(QString port, QString baudRate, QString dataBits, QStrin return -1; } -int ShareData::openNetwork(QString ip, unsigned int port, bool is_ws,int type) +int QmlShareData::openNetwork(QString ip, unsigned int port, bool is_ws,int type) { if(type == NetworkController::TYPE_TCP_CLIENT){ @@ -103,12 +104,12 @@ int ShareData::openNetwork(QString ip, unsigned int port, bool is_ws,int type) return -1; } -int ShareData::closeNetwork() +int QmlShareData::closeNetwork() { m_network_->Close(); } -int ShareData::closeSerial() +int QmlShareData::closeSerial() { if(m_serial_controller_->CloseSerial() == 0){ qDebug()<<"close serial ok"; @@ -118,12 +119,13 @@ int ShareData::closeSerial() return -1; } -int ShareData::TestLua() +int QmlShareData::TestLua() { - m_lua_.OnSerialData("ss"); + m_lua_.OnSerialData("ceshi"); + return 0; } -int ShareData::TestShowData() +int QmlShareData::TestShowData() { if(nullptr != m_qml_protodebug_){ QMetaObject::invokeMethod(m_qml_protodebug_, "addString",Q_ARG(QVariant, QString("test\r\n"))); @@ -131,7 +133,7 @@ int ShareData::TestShowData() return 0; } -int ShareData::updateLuaScript(QString str) +int QmlShareData::updateLuaScript(QString str) { qDebug()<m_network_->ReadData((int8_t * )dat); diff --git a/protoDebuger/sharedata.h b/protoDebuger/sharedata.h index 30da8c1..d88a819 100644 --- a/protoDebuger/sharedata.h +++ b/protoDebuger/sharedata.h @@ -9,17 +9,17 @@ #include "lua_wraper.h" #include -class ShareData; +class QmlShareData; -extern ShareData gGlobal; +extern QmlShareData gGlobal; // 桥接Lua虚拟机和qml界面 -class ShareData : public QObject ,SerialController::SerialListener +class QmlShareData : public QObject ,SerialController::SerialListener { Q_OBJECT Q_PROPERTY(QString _txt READ rtxt WRITE settxt NOTIFY txtchanged) public: - explicit ShareData(QObject *parent = nullptr); + explicit QmlShareData(QObject *parent = nullptr); int SetQuickView(QQuickWidget *); QString rtxt() const{ return _txt;