From 3a36dbca1d9ea552f43fd1dc574f6945cd6b78a8 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 3 Jun 2019 19:29:37 -0400 Subject: [PATCH] refactor regex filter, add guide, and make it a default --- extensions/regexfilter.cpp | 23 +++++------------ extensions/regexfilter.ui | 52 ++++++++++++++++++++++++++++++++++++++ include/defs.h | 2 +- 3 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 extensions/regexfilter.ui diff --git a/extensions/regexfilter.cpp b/extensions/regexfilter.cpp index cff1c53..5890020 100644 --- a/extensions/regexfilter.cpp +++ b/extensions/regexfilter.cpp @@ -1,8 +1,5 @@ #include "extension.h" -#include -#include -#include -#include +#include "ui_regexfilter.h" #include extern const char* REGEX_FILTER; @@ -16,25 +13,19 @@ struct : QMainWindow { void launch() { - auto centralWidget = new QWidget(this); - auto layout = new QVBoxLayout(centralWidget); - auto input = new QLineEdit(centralWidget); - auto output = new QLabel(centralWidget); - output->setAlignment(Qt::AlignCenter); - layout->addWidget(input); - layout->addWidget(output); - connect(input, &QLineEdit::textEdited, [=](QString newRegex) + ui.setupUi(this); + connect(ui.input, &QLineEdit::textEdited, [=](QString newRegex) { std::lock_guard l(m); try { regex = newRegex.toStdWString(); } - catch (...) { return output->setText(INVALID_REGEX); } - output->setText(QString(CURRENT_FILTER).arg(newRegex)); + catch (...) { return ui.output->setText(INVALID_REGEX); } + ui.output->setText(QString(CURRENT_FILTER).arg(newRegex)); }); - resize(350, 60); - setCentralWidget(centralWidget); setWindowTitle(REGEX_FILTER); show(); } + + Ui::FilterWindow ui; }*window = nullptr; BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) diff --git a/extensions/regexfilter.ui b/extensions/regexfilter.ui new file mode 100644 index 0000000..b679af4 --- /dev/null +++ b/extensions/regexfilter.ui @@ -0,0 +1,52 @@ + + + FilterWindow + + + + 0 + 0 + 350 + 76 + + + + + + + + + + + + + + Qt::AlignCenter + + + + + + + <a href="https://regexr.com">regexr.com</a> + + + Qt::RichText + + + Qt::AlignCenter + + + true + + + Qt::TextBrowserInteraction + + + + + + + + + diff --git a/include/defs.h b/include/defs.h index ce16e34..875128f 100644 --- a/include/defs.h +++ b/include/defs.h @@ -28,7 +28,7 @@ constexpr auto CONFIG_FILE = u8"Textractor.ini"; // Misc -constexpr auto DEFAULT_EXTENSIONS = u8"Remove Repetition>Lua>Copy to Clipboard>Bing Translate>Extra Window>Extra Newlines"; +constexpr auto DEFAULT_EXTENSIONS = u8"Remove Repetition>Regex Filter>Copy to Clipboard>Bing Translate>Extra Window>Extra Newlines"; constexpr auto WINDOW = u8"Window"; // EOF