use qfontdialog for extra and main window and massive perf improvement when loading large threads
This commit is contained in:
parent
f56e9ff07c
commit
6a015f04bc
@ -26,5 +26,6 @@ int main(int argc, char *argv[])
|
||||
QDir::setCurrent(QFileInfo(S(Util::GetModuleFilename().value())).absolutePath());
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setFont(QFont("MS Shell Dlg 2", 10));
|
||||
return MainWindow().show(), app.exec();
|
||||
}
|
||||
|
@ -3,8 +3,10 @@
|
||||
#include "defs.h"
|
||||
#include "host/util.h"
|
||||
#include <shellapi.h>
|
||||
#include <QMenu>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFontDialog>
|
||||
|
||||
extern const char* ATTACH;
|
||||
extern const char* LAUNCH;
|
||||
@ -16,6 +18,7 @@ extern const char* SAVE_HOOKS;
|
||||
extern const char* SEARCH_FOR_HOOKS;
|
||||
extern const char* SETTINGS;
|
||||
extern const char* EXTENSIONS;
|
||||
extern const char* FONT;
|
||||
extern const char* SELECT_PROCESS;
|
||||
extern const char* ATTACH_INFO;
|
||||
extern const char* SELECT_PROCESS_INFO;
|
||||
@ -75,9 +78,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
connect(ui->ttCombo, qOverload<int>(&QComboBox::activated), this, &MainWindow::ViewThread);
|
||||
connect(ui->textOutput, &QPlainTextEdit::selectionChanged, [this] { if (!(QApplication::mouseButtons() & Qt::LeftButton)) ui->textOutput->copy(); });
|
||||
connect(ui->textOutput, &QPlainTextEdit::customContextMenuRequested, this, &MainWindow::OutputContextMenu);
|
||||
|
||||
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
|
||||
if (settings.contains(WINDOW)) setGeometry(settings.value(WINDOW).toRect());
|
||||
if (settings.contains(FONT)) SetOutputFont(settings.value(FONT).toString());
|
||||
TextThread::filterRepetition = settings.value(FILTER_REPETITION, TextThread::filterRepetition).toBool();
|
||||
autoAttach = settings.value(AUTO_ATTACH, autoAttach).toBool();
|
||||
autoAttachSavedOnly = settings.value(ATTACH_SAVED_ONLY, autoAttachSavedOnly).toBool();
|
||||
@ -172,7 +177,7 @@ void MainWindow::ProcessDisconnected(DWORD processId)
|
||||
void MainWindow::ThreadAdded(TextThread& thread)
|
||||
{
|
||||
std::wstring threadCode = Util::GenerateCode(thread.hp, thread.tp.processId);
|
||||
QString ttString = TextThreadString(thread) + S(FormatString(L"(%s)", threadCode));
|
||||
QString ttString = TextThreadString(thread) + S(FormatString(L" (%s)", threadCode));
|
||||
bool savedMatch = savedThreadCtx == thread.tp.ctx && savedThreadCtx2 == thread.tp.ctx2 && savedThreadCode == threadCode;
|
||||
if (savedMatch) savedThreadCtx = savedThreadCtx2 = savedThreadCode[0] = 0;
|
||||
QMetaObject::invokeMethod(this, [this, ttString, savedMatch]
|
||||
@ -206,9 +211,16 @@ bool MainWindow::SentenceReceived(TextThread& thread, std::wstring& sentence)
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::OutputContextMenu(QPoint point)
|
||||
{
|
||||
std::unique_ptr<QMenu> menu(ui->textOutput->createStandardContextMenu());
|
||||
menu->addAction(FONT, [this] { if (QString font = QFontDialog::getFont(&ok, ui->textOutput->font(), this, FONT).toString(); ok) SetOutputFont(font); });
|
||||
menu->exec(ui->textOutput->mapToGlobal(point));
|
||||
}
|
||||
|
||||
QString MainWindow::TextThreadString(TextThread& thread)
|
||||
{
|
||||
return QString("%1:%2:%3:%4:%5: %6 ").arg(
|
||||
return QString("%1:%2:%3:%4:%5: %6").arg(
|
||||
QString::number(thread.handle, 16),
|
||||
QString::number(thread.tp.processId, 16),
|
||||
QString::number(thread.tp.addr, 16),
|
||||
@ -521,3 +533,12 @@ void MainWindow::ViewThread(int index)
|
||||
ui->textOutput->setPlainText(S((current = &Host::GetThread(ParseTextThreadString(ui->ttCombo->itemText(index))))->storage->c_str()));
|
||||
ui->textOutput->moveCursor(QTextCursor::End);
|
||||
}
|
||||
|
||||
void MainWindow::SetOutputFont(QString fontString)
|
||||
{
|
||||
QFont font = ui->textOutput->font();
|
||||
font.fromString(fontString);
|
||||
font.setStyleStrategy(QFont::NoFontMerging);
|
||||
ui->textOutput->setFont(font);
|
||||
QSettings(CONFIG_FILE, QSettings::IniFormat).setValue(FONT, font.toString());
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ private:
|
||||
void ThreadAdded(TextThread& thread);
|
||||
void ThreadRemoved(TextThread& thread);
|
||||
bool SentenceReceived(TextThread& thread, std::wstring& sentence);
|
||||
void OutputContextMenu(QPoint point);
|
||||
QString TextThreadString(TextThread& thread);
|
||||
ThreadParam ParseTextThreadString(QString ttString);
|
||||
DWORD GetSelectedProcessId();
|
||||
@ -43,6 +44,7 @@ private:
|
||||
void Settings();
|
||||
void Extensions();
|
||||
void ViewThread(int index);
|
||||
void SetOutputFont(QString font);
|
||||
|
||||
Ui::MainWindow* ui;
|
||||
ExtenWindow* extenWindow;
|
||||
|
@ -13,16 +13,8 @@
|
||||
<property name="windowTitle">
|
||||
<string>Textractor</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">
|
||||
QObject
|
||||
{
|
||||
font: 10pt "MS Shell Dlg 2";
|
||||
}
|
||||
#textOutput
|
||||
{
|
||||
font: 13pt "MS Shell Dlg 2";
|
||||
}
|
||||
<property name="styleSheet">
|
||||
<string notr="true">
|
||||
QPushButton, QComboBox
|
||||
{
|
||||
padding-top: 3px;
|
||||
@ -32,7 +24,7 @@
|
||||
text-align: left;
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
@ -83,6 +75,15 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="textOutput">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Meiryo</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "ui_extrawindow.h"
|
||||
#include "defs.h"
|
||||
#include <QColorDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
@ -15,9 +16,6 @@ extern const char* SIZE_LOCK;
|
||||
extern const char* BG_COLOR;
|
||||
extern const char* TEXT_COLOR;
|
||||
extern const char* FONT;
|
||||
extern const char* FONT_SIZE;
|
||||
extern const char* FONT_FAMILY;
|
||||
extern const char* FONT_WEIGHT;
|
||||
extern const char* SAVE_SETTINGS;
|
||||
|
||||
struct Window : QDialog
|
||||
@ -73,25 +71,12 @@ public:
|
||||
private:
|
||||
void RequestFont()
|
||||
{
|
||||
QFont font = ui.display->font();
|
||||
QDialog fontDialog(this, Qt::WindowCloseButtonHint);
|
||||
fontDialog.setWindowTitle(FONT);
|
||||
QFormLayout layout(&fontDialog);
|
||||
QLineEdit fontFamily(font.family(), &fontDialog);
|
||||
layout.addRow(FONT_FAMILY, &fontFamily);
|
||||
QSpinBox fontSize(&fontDialog);
|
||||
fontSize.setValue(font.pointSize());
|
||||
layout.addRow(FONT_SIZE, &fontSize);
|
||||
QSpinBox fontWeight(&fontDialog);
|
||||
fontWeight.setValue(font.weight());
|
||||
layout.addRow(FONT_WEIGHT, &fontWeight);
|
||||
QPushButton save(SAVE_SETTINGS, &fontDialog);
|
||||
layout.addWidget(&save);
|
||||
connect(&save, &QPushButton::clicked, &fontDialog, &QDialog::accept);
|
||||
if (!fontDialog.exec()) return;
|
||||
font = QFont(fontFamily.text(), fontSize.value(), fontWeight.value());
|
||||
settings.setValue(FONT, font.toString());
|
||||
ui.display->setFont(font);
|
||||
bool ok;
|
||||
if (QFont font = QFontDialog::getFont(&ok, ui.display->font(), this, FONT); ok)
|
||||
{
|
||||
settings.setValue(FONT, font.toString());
|
||||
ui.display->setFont(font);
|
||||
}
|
||||
};
|
||||
|
||||
void setBackgroundColor(QColor color)
|
||||
@ -159,7 +144,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
if (!sentenceInfo["current select"]) return false;
|
||||
|
||||
QString qSentence = S(sentence);
|
||||
if (!window.settings.value(SHOW_ORIGINAL).toBool()) qSentence = qSentence.section('\n', qSentence.count('\n') / 2 + 1);
|
||||
if (!window.settings.value(SHOW_ORIGINAL, true).toBool()) qSentence = qSentence.section('\n', qSentence.count('\n') / 2 + 1);
|
||||
|
||||
QMetaObject::invokeMethod(&window, [=] { window.ui.display->setText(qSentence); });
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user