-
Notifications
You must be signed in to change notification settings - Fork 0
Initialize submission, add the start page. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This reverts commit b78bdad.
CMakeLists.txt
Outdated
list(APPEND TGFX_INSPECTOR_LIBS Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets | ||
Qt${QT_VERSION_MAJOR}::WebSockets Qt${QT_VERSION_MAJOR}::OpenGL Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Quick | ||
Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::QuickControls2 Qt${QT_VERSION_MAJOR}::Core5Compat) | ||
if (${QT_VERSION} VERSION_LESS "5.15") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
统一升级到QT6吧,和PAG那边的工具保持一致
src/ResolvService.h
Outdated
std::atomic<bool> exit; | ||
std::mutex mutex; | ||
std::condition_variable conditionVariable; | ||
std::vector<QueueItem> queue; | ||
uint16_t port; | ||
std::thread thread; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些变量都初始化一下
src/StartView.cpp
Outdated
#include "Socket.h" | ||
|
||
namespace inspector { | ||
ClientData::ClientData(int64_t time, uint32_t protoVer, int32_t activeTime, uint16_t port, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
构造方法参数太多了,可以封装到结构体中
src/StartView.cpp
Outdated
} | ||
|
||
QList<QObject*> StartView::getFileItems() const { | ||
QList<QObject*> items; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
构造的时候可以把初始容量传进去或者QList::reserve指定容量,避免append的过程中QList扩容
src/StartView.h
Outdated
std::string procName; | ||
std::string address; | ||
uint8_t type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
成员变量都初始化下
src/StartView.h
Outdated
QString filesPath; | ||
QString filesName; | ||
QDateTime lastOpened; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
成员变量初始化
src/StartView.h
Outdated
QString lastOpenFile; | ||
QStringList recentFiles; | ||
QList<FileItem*> fileItems; | ||
std::mutex resolvLock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
初始化
vendor.json
Outdated
"-DKDDockWidgets_QT6=ON", | ||
"-DKDDockWidgets_STATIC=ON", | ||
"-DKDDW_FRONTEND_QTQUICK=ON", | ||
"-DCMAKE_PREFIX_PATH=\"/Users/lifengdy/Qt/6.8.1/macos/lib/cmake\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里写死了你的本地路径
src/ResolvService.cpp
Outdated
#endif | ||
|
||
namespace inspector { | ||
ResolvService::ResolvService(uint16_t port) : port(port), thread([this] { worker(); }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worker()最好不要写在这里
src/ResolvService.h
Outdated
}; | ||
|
||
public: | ||
ResolvService() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认构造可以不写,感觉这块应该禁用默认构造
src/ResolvService.h
Outdated
std::condition_variable conditionVariable = {}; | ||
std::vector<QueueItem> queue = {}; | ||
uint16_t port = 0; | ||
std::thread thread; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看在构造函数中初始化,这里也可以使用std::shared_ptrstd::thread
src/StartView.cpp
Outdated
} | ||
|
||
void StartView::loadRecentFiles() { | ||
QSettings settings("MyCompany", "Inspector"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个设置项叫MyCompany吗
src/StartView.cpp
Outdated
tgfx::debug::IpAddress addr; | ||
size_t len = 0; | ||
for (;;) { | ||
auto msg = broadcastListen->readData(len, addr, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readData返回的是data,变量取名为msg不太合适
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里读取的是broadcastMessage,我把命名补全
src/ResolvService.cpp
Outdated
thread.join(); | ||
} | ||
|
||
void ResolvService::query(uint32_t ip, const std::function<void(std::string&&)>& callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
结合上下文看了下,std::function<void(std::string&&)中使用const char*应该就可以了,没必要使用右值引用
src/StartView.cpp
Outdated
tgfx::debug::BroadcastMessage bm = {}; | ||
memcpy(&bm, msg, len); | ||
auto protoVer = bm.protocolVersion; | ||
char procname[tgfx::debug::WelcomeMessageProgramNameSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
初始化下
#include "tgfx/core/Clock.h" | ||
|
||
namespace inspector { | ||
ClientData::ClientData(Data data) : data(std::move(data)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的ClientData和Data可以合并吗?两个都是表示一个Data数据结构
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个之前是说构造函数太多,封装到结构体中了
src/StartView.h
Outdated
} | ||
|
||
private: | ||
QString filesPath = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QString filesPath = "";
for (;;) { | ||
std::unique_lock<std::mutex> lock(mutex); | ||
conditionVariable.wait( | ||
lock, [this] { return !queue.empty() || exit.load(std::memory_order_relaxed); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的代码已经加锁,可以不使用atomic变量
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个锁是为了保护队列,atomic变量是判断是否退出的
src/StartView.cpp
Outdated
} | ||
|
||
void StartView::connectToClientByLayerInspector(QObject* object) { | ||
auto client = dynamic_cast<ClientData*>(object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把rtti关掉,使用static_cast转换
resolv = std::make_unique<ResolvService>(port); | ||
loadRecentFiles(); | ||
|
||
broadcastTimer = new QTimer(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
起始页在后台的时候,可以暂停定时器
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还没做后台的功能,后面合入完善的功能后改下
初始化提交,增加起始页面。