Skip to content

Commit f146bcb

Browse files
committed
Finished keywords filter
Signed-off-by: 邓佳佳 <2894220@gmail.com>
1 parent 19ca4e2 commit f146bcb

6 files changed

Lines changed: 31 additions & 4 deletions

File tree

bin/themes/default/main_form/log_file_session_box.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
<Window>
33
<VBox>
44
<HBox name="keywords_filter" width="stretch" height="auto" bkcolor="white" padding="0,0,0,8">
5+
<Button name="start_capture" width="28" height="28" valign="center" tooltiptext="开始监控文件" margin="0,0,5" visible="false"
6+
forenormalimage="start_capture.png"
7+
hotimage="../public/button/icon_hover.png"
8+
pushedimage="../public/button/icon_pushed.png"
9+
disabledimage="start_capture.png" />
10+
<Button name="stop_capture" width="28" height="28" valign="center" tooltiptext="暂停监控文件" margin="0,0,5" visible="false"
11+
forenormalimage="stop_capture.png"
12+
hotimage="../public/button/icon_hover.png"
13+
pushedimage="../public/button/icon_pushed.png"
14+
disabledimage="stop_capture.png" />
15+
<Control class="splitline_ver_level1" margin="5,0,10" visible="false"/>
516
<HListBox name="keyword_list" width="auto"></HListBox>
617
<Control />
718
<HBox width="auto" height="auto" valign="center">
833 Bytes
Loading
684 Bytes
Loading

src/gui/main_form/log_file_session_box/log_file_session_box.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ void LogFileSessionBox::InitControl(const std::wstring& file_path, ListBox* log_
1919
GlobalManager::FillBoxWithCache(this, L"main_form/log_file_session_box.xml");
2020

2121
this->AttachBubbledEvent(kEventClick, nbase::Bind(&LogFileSessionBox::OnClicked, this, std::placeholders::_1));
22-
this->AttachBubbledEvent(kEventReturn, nbase::Bind(&LogFileSessionBox::OnKeyDown, this, std::placeholders::_1));
22+
this->AttachBubbledEvent(kEventReturn, nbase::Bind(&LogFileSessionBox::OnReturnKeyDown, this, std::placeholders::_1));
2323

2424
keyword_list_ = dynamic_cast<ListBox*>(FindSubControl(L"keyword_list"));
2525
keyword_input_ = dynamic_cast<RichEdit*>(FindSubControl(L"keyword_input"));
2626
keyword_add_ = dynamic_cast<Button*>(FindSubControl(L"keyword_add"));
2727
log_content_ = dynamic_cast<RichEdit*>(FindSubControl(L"log_content"));
28+
start_capture_ = dynamic_cast<Button*>(FindSubControl(L"start_capture"));
29+
stop_capture_ = dynamic_cast<Button*>(FindSubControl(L"stop_capture"));
2830

2931
log_instance_.reset(new FileInstance(file_path.c_str()));
3032
}
@@ -58,11 +60,23 @@ bool LogFileSessionBox::OnClicked(EventArgs* msg)
5860
{
5961
AddKeyword();
6062
}
63+
else if (name == L"start_capture")
64+
{
65+
StartCapture();
66+
stop_capture_->SetVisible(true);
67+
start_capture_->SetVisible(false);
68+
}
69+
else if (name == L"stop_capture")
70+
{
71+
StopCapture();
72+
start_capture_->SetVisible(true);
73+
stop_capture_->SetVisible(false);
74+
}
6175

6276
return true;
6377
}
6478

65-
bool LogFileSessionBox::OnKeyDown(EventArgs* msg)
79+
bool LogFileSessionBox::OnReturnKeyDown(EventArgs* msg)
6680
{
6781
std::wstring name = msg->pSender->GetName();
6882
if (name == L"keyword_input")

src/gui/main_form/log_file_session_box/log_file_session_box.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LogFileSessionBox : public VBox
2020
void RemoveKeyword(KeywordItem* keyword_item);
2121

2222
bool OnClicked(EventArgs* msg);
23-
bool OnKeyDown(EventArgs* msg);
23+
bool OnReturnKeyDown(EventArgs* msg);
2424
void OnFileChangedCallback(const std::wstring& log_file, const std::string& data, bool append = true);
2525

2626
static const LPCTSTR kFindString;
@@ -34,6 +34,8 @@ class LogFileSessionBox : public VBox
3434
RichEdit* log_content_ = nullptr;
3535
ListBox* keyword_list_ = nullptr;
3636
Button* keyword_add_ = nullptr;
37+
Button* start_capture_ = nullptr;
38+
Button* stop_capture_ = nullptr;
3739

3840
// data
3941
std::shared_ptr<FileInstance> log_instance_; // Îļþ״̬¹ÜÀí

src/module/file_manager/file_instance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void FileInstance::CaptureFileThread()
6464
{
6565
// 等待文件大小变更的事件
6666
DWORD wait = WaitForSingleObject(find_handle_, INFINITE);
67-
if (wait == WAIT_OBJECT_0 && find_handle_)
67+
if (wait == WAIT_OBJECT_0)
6868
{
6969
if (!FindNextChangeNotification(find_handle_))
7070
{

0 commit comments

Comments
 (0)