mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 17:04:12 +08:00
let user change max buffer size
This commit is contained in:
parent
e31c9563ef
commit
d2c9e5a6f5
@ -27,7 +27,7 @@ void TextThread::Flush()
|
||||
std::wstring sentence;
|
||||
{
|
||||
LOCK(ttMutex);
|
||||
if (buffer.size() < 400 && (GetTickCount() - timestamp < FlushDelay || buffer.size() < 2)) return;
|
||||
if (buffer.size() < MaxBufferSize && (GetTickCount() - timestamp < FlushDelay || buffer.size() < 2)) return;
|
||||
sentence = status & USING_UNICODE
|
||||
? std::wstring((wchar_t*)buffer.data(), buffer.size() / 2)
|
||||
: StringToWideString(std::string(buffer.data(), buffer.size()), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
|
||||
|
@ -25,6 +25,7 @@ public:
|
||||
const ThreadParam tp;
|
||||
|
||||
inline static int FlushDelay = 250; // flush every 250ms by default
|
||||
inline static int MaxBufferSize = 500;
|
||||
inline static int ThreadCounter = 0;
|
||||
|
||||
private:
|
||||
@ -35,7 +36,7 @@ private:
|
||||
std::recursive_mutex ttMutex;
|
||||
|
||||
HANDLE deletionEvent = CreateEventW(nullptr, FALSE, FALSE, NULL);
|
||||
std::thread flushThread = std::thread([&] { while (WaitForSingleObject(deletionEvent, 100) == WAIT_TIMEOUT) Flush(); });
|
||||
std::thread flushThread = std::thread([&] { while (WaitForSingleObject(deletionEvent, 10) == WAIT_TIMEOUT) Flush(); });
|
||||
DWORD timestamp = GetTickCount();
|
||||
|
||||
ThreadOutputCallback Output;
|
||||
|
@ -5,18 +5,16 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings("NextHooker.ini", QSettings::IniFormat);
|
||||
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
|
||||
// TODO: add GUI for changing this
|
||||
if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush_Delay").toUInt();
|
||||
// TODO: add GUI for changing these
|
||||
if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush_Delay").toInt();
|
||||
if (settings.contains("Max_Buffer_Size")) TextThread::MaxBufferSize = settings.value("Max_Buffer_Size").toInt();
|
||||
|
||||
processCombo = findChild<QComboBox*>("processCombo");
|
||||
ttCombo = findChild<QComboBox*>("ttCombo");
|
||||
@ -41,9 +39,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
QSettings settings("NextHooker.ini", QSettings::IniFormat);
|
||||
settings.setValue("Window", this->geometry());
|
||||
settings.setValue("Flush_Delay", TextThread::FlushDelay);
|
||||
settings.setValue("Max_Buffer_Size", TextThread::MaxBufferSize);
|
||||
settings.sync();
|
||||
Host::Close();
|
||||
delete ui;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QMainWindow>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QComboBox>
|
||||
#include <QSettings>
|
||||
#include "host/host.h"
|
||||
|
||||
namespace Ui
|
||||
@ -51,6 +52,7 @@ private:
|
||||
QVector<HookParam> GetAllHooks(DWORD processId);
|
||||
|
||||
Ui::MainWindow* ui;
|
||||
QSettings settings = QSettings("NextHooker.ini", QSettings::IniFormat);
|
||||
QComboBox* processCombo;
|
||||
QComboBox* ttCombo;
|
||||
QComboBox* extenCombo;
|
||||
|
Loading…
x
Reference in New Issue
Block a user