refactor and use .ini
This commit is contained in:
parent
e5dcd33680
commit
38ea5dba36
@ -27,7 +27,7 @@ void TextThread::Flush()
|
|||||||
std::wstring sentence;
|
std::wstring sentence;
|
||||||
{
|
{
|
||||||
LOCK(ttMutex);
|
LOCK(ttMutex);
|
||||||
if (buffer.size() < 400 && (GetTickCount() - timestamp < flushDelay || buffer.size() == 0)) return; // TODO: let user change delay before sentence is flushed
|
if (buffer.size() < 400 && (GetTickCount() - timestamp < FlushDelay || buffer.size() == 0)) return;
|
||||||
if (status & USING_UNICODE) sentence = std::wstring((wchar_t*)buffer.data(), buffer.size() / 2);
|
if (status & USING_UNICODE) sentence = std::wstring((wchar_t*)buffer.data(), buffer.size() / 2);
|
||||||
else sentence = ToWString(buffer.data(), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
|
else sentence = ToWString(buffer.data(), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
const std::wstring name;
|
const std::wstring name;
|
||||||
const ThreadParam tp;
|
const ThreadParam tp;
|
||||||
|
|
||||||
inline static unsigned flushDelay = 250; // flush every 250ms by default
|
inline static unsigned FlushDelay = 250; // flush every 250ms by default
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Flush();
|
void Flush();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@ -12,12 +13,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
QFile settings("NHWindow");
|
QSettings settings("NextHooker.ini", QSettings::IniFormat);
|
||||||
settings.open(QIODevice::ReadOnly);
|
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
|
||||||
QDataStream reader(&settings);
|
// TODO: add GUI for changing this
|
||||||
QRect rect;
|
if (settings.contains("Flush_Delay")) TextThread::FlushDelay = settings.value("Flush Delay").toUInt();
|
||||||
reader >> rect;
|
|
||||||
if (rect.bottom()) this->setGeometry(rect);
|
|
||||||
|
|
||||||
processCombo = findChild<QComboBox*>("processCombo");
|
processCombo = findChild<QComboBox*>("processCombo");
|
||||||
ttCombo = findChild<QComboBox*>("ttCombo");
|
ttCombo = findChild<QComboBox*>("ttCombo");
|
||||||
@ -42,10 +41,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
QFile settings("NHWindow");
|
QSettings settings("NextHooker.ini", QSettings::IniFormat);
|
||||||
settings.open(QIODevice::ReadWrite | QIODevice::Truncate);
|
settings.setValue("Window", this->geometry());
|
||||||
QDataStream writer(&settings);
|
settings.setValue("Flush_Delay", TextThread::FlushDelay);
|
||||||
writer << this->geometry();
|
settings.sync();
|
||||||
Host::Close();
|
Host::Close();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
@ -118,11 +117,12 @@ void MainWindow::ThreadOutput(TextThread* thread, QString output)
|
|||||||
QString MainWindow::TextThreadString(TextThread* thread)
|
QString MainWindow::TextThreadString(TextThread* thread)
|
||||||
{
|
{
|
||||||
ThreadParam tp = thread->tp;
|
ThreadParam tp = thread->tp;
|
||||||
return QString("%1:%2:%3:%4: ").arg(
|
return QString("%1:%2:%3:%4:%5: ").arg(
|
||||||
QString::number(tp.pid),
|
QString::number(tp.pid),
|
||||||
QString::number(tp.hook, 16),
|
QString::number(tp.hook, 16),
|
||||||
QString::number(tp.retn, 16),
|
QString::number(tp.retn, 16),
|
||||||
QString::number(tp.spl, 16)
|
QString::number(tp.spl, 16),
|
||||||
|
QString::number((int64_t)thread, 16)
|
||||||
).toUpper();
|
).toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user