some change.

This commit is contained in:
2025-06-19 16:20:01 +08:00
parent 5f5569495e
commit dfc2639746
8 changed files with 20 additions and 11 deletions

View File

@@ -4,6 +4,10 @@
ClientCore::ClientCore(QObject* parent) : QObject(parent) ClientCore::ClientCore(QObject* parent) : QObject(parent)
{ {
qRegisterMetaType<QSharedPointer<FrameBuffer>>("QSharedPointer<FrameBuffer>");
qRegisterMetaType<InfoClientVec>("InfoClientVec");
qRegisterMetaType<DirFileInfoVec>("DirFileInfoVec");
socket_ = new QTcpSocket(this); socket_ = new QTcpSocket(this);
connect(socket_, &QTcpSocket::readyRead, this, &ClientCore::onReadyRead); connect(socket_, &QTcpSocket::readyRead, this, &ClientCore::onReadyRead);
connect(socket_, &QTcpSocket::disconnected, this, &ClientCore::onDisconnected); connect(socket_, &QTcpSocket::disconnected, this, &ClientCore::onDisconnected);
@@ -113,7 +117,6 @@ void ClientCore::UseFrame(QSharedPointer<FrameBuffer> frame)
case FrameBufferType::FBT_CLI_TRANS_DONE: { case FrameBufferType::FBT_CLI_TRANS_DONE: {
sigTransDone(frame); sigTransDone(frame);
break; break;
break;
} }
case FrameBufferType::FBT_CLI_CAN_SEND: { case FrameBufferType::FBT_CLI_CAN_SEND: {
sigCanSend(frame); sigCanSend(frame);

View File

@@ -102,7 +102,6 @@ public:
QByteArray recvBuffer_; QByteArray recvBuffer_;
LocalFile localFile_; LocalFile localFile_;
std::array<std::function<void(QSharedPointer<FrameBuffer>)>, 256> frameCall_;
}; };
class SocketWorker : public QThread class SocketWorker : public QThread

View File

@@ -290,7 +290,7 @@ void SendThread::run()
// shoule add abort action mark. // shoule add abort action mark.
} }
QMetaObject::invokeMethod(this, [this, frame] { QMetaObject::invokeMethod(cliCore_, [this, frame] {
frame->sendRet = cliCore_->Send(frame); frame->sendRet = cliCore_->Send(frame);
if (frame->call) { if (frame->call) {
frame->call(frame); frame->call(frame);

View File

@@ -1,6 +1,7 @@
#include "LogControl.h" #include "LogControl.h"
#include <QDateTime> #include <QDateTime>
#include <QListWidgetItem>
#include <QStandardItem> #include <QStandardItem>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@@ -15,8 +16,6 @@ LogPrint::LogPrint(QWidget* parent) : QWidget(parent), ui(new Ui::LogPrint)
void LogPrint::InitControl() void LogPrint::InitControl()
{ {
model_ = new QStandardItemModel(this);
ui->listView->setModel(model_);
} }
std::string LogPrint::now_str() std::string LogPrint::now_str()
@@ -56,8 +55,8 @@ void LogPrint::Debug(const QString& message)
void LogPrint::Print(const QString& message, const QBrush& color) void LogPrint::Print(const QString& message, const QBrush& color)
{ {
auto timeStr = QString("%1%2").arg(QString::fromStdString(now_str())).arg(message); auto timeStr = QString("%1%2").arg(QString::fromStdString(now_str())).arg(message);
auto* item = new QStandardItem(timeStr); QListWidgetItem* item = new QListWidgetItem(timeStr);
item->setForeground(color); item->setForeground(color);
model_->appendRow(item); ui->listWidget->addItem(item);
ui->listView->scrollToBottom(); ui->listWidget->scrollToBottom();
} }

View File

@@ -15,7 +15,7 @@
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QListView" name="listView"/> <widget class="QListWidget" name="listWidget"/>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@@ -103,7 +103,7 @@ void TransForm::showEvent(QShowEvent* event)
{ {
QDialog::showEvent(event); QDialog::showEvent(event);
workTh_ = new TranFromTh(this, this); workTh_ = new TranFromTh(this, this);
//fileTrans_->moveToThread(workTh_); fileTrans_->moveToThread(workTh_);
connect(workTh_, &QThread::finished, fileTrans_, &QObject::deleteLater); connect(workTh_, &QThread::finished, fileTrans_, &QObject::deleteLater);
workTh_->start(); workTh_->start();
} }

View File

@@ -8,6 +8,7 @@
#include "Control/LogControl.h" #include "Control/LogControl.h"
static LogPrint* logPrint = nullptr; static LogPrint* logPrint = nullptr;
static QMutex logMut;
frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGUI) frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGUI)
{ {
@@ -27,7 +28,9 @@ frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGU
frelayGUI::~frelayGUI() frelayGUI::~frelayGUI()
{ {
QMutexLocker locker(&logMut);
delete ui; delete ui;
logPrint = nullptr;
} }
void frelayGUI::InitControl() void frelayGUI::InitControl()
@@ -89,6 +92,9 @@ void frelayGUI::ControlLayout()
void frelayGUI::ControlMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg) void frelayGUI::ControlMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{ {
Q_UNUSED(context); Q_UNUSED(context);
QMutexLocker locker(&logMut);
if (!logPrint) { if (!logPrint) {
return; return;
} }

View File

@@ -4,6 +4,7 @@
#include <QByteArray> #include <QByteArray>
#include <QSharedPointer> #include <QSharedPointer>
#include <QString> #include <QString>
#include <QMetaType>
constexpr quint32 CHUNK_BUF_SIZE = 1 * 1024 * 1024; constexpr quint32 CHUNK_BUF_SIZE = 1 * 1024 * 1024;
@@ -52,4 +53,5 @@ public:
static QByteArray PackBuffer(const QSharedPointer<FrameBuffer>& frame); static QByteArray PackBuffer(const QSharedPointer<FrameBuffer>& frame);
}; };
#endif // PROTOCOL_H #endif // PROTOCOL_H