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