1
0
Fork 0

Merge pull request #2694 from torusrxxx/patch000000c3

Add shortcuts in Goto dialog
This commit is contained in:
Duncan Ogilvie 2021-07-26 20:31:12 +02:00 committed by GitHub
commit 48986ff3d3
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -41,6 +41,7 @@ GotoDialog::GotoDialog(QWidget* parent, bool allowInvalidExpression, bool allowI
connect(mValidateThread, SIGNAL(expressionChanged(bool, bool, dsint)), this, SLOT(expressionChanged(bool, bool, dsint)));
connect(ui->editExpression, SIGNAL(textChanged(QString)), mValidateThread, SLOT(textChanged(QString)));
connect(ui->editExpression, SIGNAL(textEdited(QString)), this, SLOT(textEditedSlot(QString)));
connect(ui->labelError, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString)));
connect(this, SIGNAL(finished(int)), this, SLOT(finishedSlot(int)));
connect(Config(), SIGNAL(disableAutoCompleteUpdated()), this, SLOT(disableAutoCompleteUpdated()));
@ -88,7 +89,17 @@ void GotoDialog::expressionChanged(bool validExpression, bool validPointer, dsin
QString expression = ui->editExpression->text();
if(!expression.length())
{
ui->labelError->setText(tr("<font color='red'><b>Empty expression...</b></font>"));
QString tips[] = {"RVA", tr("File offset"), "PEB", "TEB"};
const char* expressions[] = {":$%", ":#%", "peb()", "teb()"};
QString labelText(tr("Shortcuts: "));
for(size_t i = 0; i < 4; i++)
{
labelText += "<a href=\"";
labelText += QString(expressions[i]).replace('%', "%" + tips[i] + "%") + "\">" + QString(expressions[i]).replace('%', tips[i]) + "</a>";
if(i < 3)
labelText += '\t';
}
ui->labelError->setText(labelText);
setOkEnabled(false);
expressionText.clear();
}
@ -193,6 +204,19 @@ void GotoDialog::textEditedSlot(QString text)
mCompletionText = text;
}
void GotoDialog::linkActivated(const QString & link)
{
if(link.contains('%'))
{
int x = link.indexOf('%');
int y = link.lastIndexOf('%');
ui->editExpression->setText(QString(link).replace('%', ""));
ui->editExpression->setSelection(x, y - 1);
}
else
ui->editExpression->setText(link);
}
void GotoDialog::disableAutoCompleteUpdated()
{
if(Config()->getBool("Gui", "DisableAutoComplete"))

View File

@ -37,6 +37,7 @@ private slots:
void on_buttonOk_clicked();
void finishedSlot(int result);
void textEditedSlot(QString text);
void linkActivated(const QString & link);
private:
Ui::GotoDialog* ui;