MCPcopy Create free account
hub / github.com/Artikash/Textractor / Window

Class Window

extensions/regexfilter.cpp:19–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17DWORD (*GetSelectedProcessId)() = [] { return 0UL; };
18
19class Window : public QDialog, Localizer
20{
21public:
22 Window() : QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
23 {
24 ui.setupUi(this);
25
26 connect(ui.regexEdit, &QLineEdit::textEdited, this, &Window::SetRegex);
27 connect(ui.saveButton, &QPushButton::clicked, this, &Window::Save);
28
29 setWindowTitle(REGEX_FILTER);
30 QMetaObject::invokeMethod(this, &QWidget::show, Qt::QueuedConnection);
31 }
32
33 void SetRegex(QString regex)
34 {
35 ui.regexEdit->setText(regex);
36 std::scoped_lock lock(m);
37 if (!regex.isEmpty()) try { ::regex = S(regex); }
38 catch (std::regex_error) { return ui.output->setText(INVALID_REGEX); }
39 else ::regex = std::nullopt;
40 ui.output->setText(QString(CURRENT_FILTER).arg(regex));
41 }
42
43private:
44 void Save()
45 {
46 auto formatted = FormatString(
47 L"\xfeff|PROCESS|%s|FILTER|%s|END|\r\n",
48 GetModuleFilename(GetSelectedProcessId()).value_or(FormatString(L"Error getting name of process 0x%X", GetSelectedProcessId())),
49 S(ui.regexEdit->text())
50 );
51 std::ofstream(REGEX_SAVE_FILE, std::ios::binary | std::ios::app).write((const char*)formatted.c_str(), formatted.size() * sizeof(wchar_t));
52 }
53
54 Ui::FilterWindow ui;
55} window;
56
57bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
58{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected