socket: Unified Soket thread management.

This commit is contained in:
2025-06-19 11:59:32 +08:00
parent beaadfbf85
commit b2aa0d3752
17 changed files with 235 additions and 88 deletions

View File

@@ -50,35 +50,8 @@ private:
private:
QMenu* menu_;
QThread* th_;
QThread* mainTh_;
SocketWorker* sockWorker_{};
QStandardItemModel* model_;
};
class ConnectWorker : public QObject
{
Q_OBJECT
public:
explicit ConnectWorker(ClientCore* clientCore, QObject* parent = nullptr)
: QObject(parent), clientCore_(clientCore)
{
}
public slots:
void doConnect(const QString& ip, int port, QThread* parentThread)
{
emit connecting();
bool connected = clientCore_->Connect(ip, port);
clientCore_->moveToThread(parentThread);
emit connectResult(connected);
}
signals:
void connectResult(bool success);
void connecting();
private:
ClientCore* clientCore_;
};
#endif // CONNECTCONTROL_H