1
0
Fork 0

GUI: option to edit script in ScriptView

This commit is contained in:
mrexodia 2017-03-14 09:31:31 +01:00
parent f7d3f7cb74
commit c29aa34baa
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
5 changed files with 14 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#include "ScriptView.h" #include "ScriptView.h"
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QDesktopServices>
#include "Configuration.h" #include "Configuration.h"
#include "Bridge.h" #include "Bridge.h"
#include "RichTextPainter.h" #include "RichTextPainter.h"
@ -377,6 +378,7 @@ void ScriptView::setupContextMenu()
}; };
mMenu->addAction(makeShortcutAction(DIcon("arrow-restart.png"), tr("Re&load Script"), SLOT(reload()), "ActionReloadScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("arrow-restart.png"), tr("Re&load Script"), SLOT(reload()), "ActionReloadScript"), isempty);
mMenu->addAction(makeShortcutAction(DIcon("control-exit.png"), tr("&Unload Script"), SLOT(unload()), "ActionUnloadScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("control-exit.png"), tr("&Unload Script"), SLOT(unload()), "ActionUnloadScript"), isempty);
mMenu->addAction(makeShortcutAction(DIcon("edit-script.png"), tr("&Edit Script"), SLOT(edit()), "ActionEditScript"), isempty);
mMenu->addSeparator(); mMenu->addSeparator();
mMenu->addAction(makeShortcutAction(DIcon("breakpoint_toggle.png"), tr("Toggle &BP"), SLOT(bpToggle()), "ActionToggleBreakpointScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("breakpoint_toggle.png"), tr("Toggle &BP"), SLOT(bpToggle()), "ActionToggleBreakpointScript"), isempty);
mMenu->addAction(makeShortcutAction(DIcon("arrow-run-cursor.png"), tr("Ru&n until selection"), SLOT(runCursor()), "ActionRunToCursorScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("arrow-run-cursor.png"), tr("Ru&n until selection"), SLOT(runCursor()), "ActionRunToCursorScript"), isempty);
@ -385,7 +387,7 @@ void ScriptView::setupContextMenu()
mMenu->addAction(makeShortcutAction(DIcon("control-stop.png"), tr("&Abort"), SLOT(abort()), "ActionAbortScript"), isempty); mMenu->addAction(makeShortcutAction(DIcon("control-stop.png"), tr("&Abort"), SLOT(abort()), "ActionAbortScript"), isempty);
mMenu->addAction(makeAction(DIcon("neworigin.png"), tr("&Continue here..."), SLOT(newIp())), isempty); mMenu->addAction(makeAction(DIcon("neworigin.png"), tr("&Continue here..."), SLOT(newIp())), isempty);
mMenu->addSeparator(); mMenu->addSeparator();
mMenu->addAction(makeShortcutAction(DIcon("terminal-command.png"), tr("&Execute Command..."), SLOT(cmdExec()), "ActionExecuteCommandScript")); mMenu->addAction(makeShortcutAction(DIcon("terminal-command.png"), tr("E&xecute Command..."), SLOT(cmdExec()), "ActionExecuteCommandScript"));
} }
bool ScriptView::isScriptCommand(QString text, QString cmd, QString & mnemonic, QString & argument) bool ScriptView::isScriptCommand(QString text, QString cmd, QString & mnemonic, QString & argument)
@ -474,6 +476,7 @@ void ScriptView::openFile()
void ScriptView::paste() void ScriptView::paste()
{ {
DbgScriptUnload(); DbgScriptUnload();
filename.clear();
DbgScriptLoad("x64dbg://localhost/clipboard"); DbgScriptLoad("x64dbg://localhost/clipboard");
} }
@ -487,9 +490,16 @@ void ScriptView::reload()
void ScriptView::unload() void ScriptView::unload()
{ {
filename.clear();
DbgScriptUnload(); DbgScriptUnload();
} }
void ScriptView::edit()
{
if(!filename.isEmpty())
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(filename)));
}
void ScriptView::run() void ScriptView::run()
{ {
if(!getRowCount()) if(!getRowCount())

View File

@ -31,6 +31,7 @@ public slots:
void paste(); void paste();
void reload(); void reload();
void unload(); void unload();
void edit();
void run(); void run();
void bpToggle(); void bpToggle();
void runCursor(); void runCursor();

View File

@ -523,6 +523,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
defaultShortcuts.insert("ActionLoadScript", Shortcut(tr("Actions -> Load Script"), "Ctrl+O")); defaultShortcuts.insert("ActionLoadScript", Shortcut(tr("Actions -> Load Script"), "Ctrl+O"));
defaultShortcuts.insert("ActionReloadScript", Shortcut(tr("Actions -> Reload Script"), "Ctrl+R")); defaultShortcuts.insert("ActionReloadScript", Shortcut(tr("Actions -> Reload Script"), "Ctrl+R"));
defaultShortcuts.insert("ActionUnloadScript", Shortcut(tr("Actions -> Unload Script"), "Ctrl+U")); defaultShortcuts.insert("ActionUnloadScript", Shortcut(tr("Actions -> Unload Script"), "Ctrl+U"));
defaultShortcuts.insert("ActionEditScript", Shortcut(tr("Actions -> Edit Script"), ""));
defaultShortcuts.insert("ActionRunScript", Shortcut(tr("Actions -> Run Script"), "Space")); defaultShortcuts.insert("ActionRunScript", Shortcut(tr("Actions -> Run Script"), "Space"));
defaultShortcuts.insert("ActionToggleBreakpointScript", Shortcut(tr("Actions -> Toggle Script Breakpoint"), "F2")); defaultShortcuts.insert("ActionToggleBreakpointScript", Shortcut(tr("Actions -> Toggle Script Breakpoint"), "F2"));
defaultShortcuts.insert("ActionRunToCursorScript", Shortcut(tr("Actions -> Run Script to Cursor"), "Shift+F4")); defaultShortcuts.insert("ActionRunToCursorScript", Shortcut(tr("Actions -> Run Script to Cursor"), "Shift+F4"));

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

View File

@ -294,5 +294,6 @@
<file>images/wide.png</file> <file>images/wide.png</file>
<file>images/layout.png</file> <file>images/layout.png</file>
<file>images/summary.png</file> <file>images/summary.png</file>
<file>images/edit-script.png</file>
</qresource> </qresource>
</RCC> </RCC>