1
0
Fork 0

GUI: resolved issue #110 (Attach Dialog + Detach menu option) + updated calculator icon

This commit is contained in:
Mr. eXoDia 2014-08-05 04:29:54 +02:00
parent 520d063a79
commit b8f1ebbb30
13 changed files with 253 additions and 8 deletions

View File

@ -0,0 +1,75 @@
#include "AttachDialog.h"
#include "ui_AttachDialog.h"
AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AttachDialog)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
setFixedSize(this->size()); //fixed size
//setup actions
mAttachAction = new QAction("Attach", this);
mAttachAction->setShortcut(QKeySequence("enter"));
connect(mAttachAction, SIGNAL(triggered()), this, SLOT(on_btnAttach_clicked()));
mRefreshAction = new QAction("Refresh", this);
mRefreshAction->setShortcut(QKeySequence("F5"));
connect(mRefreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
this->addAction(mRefreshAction);
//setup process list
int charwidth = ui->listProcesses->getCharWidth();
ui->listProcesses->addColumnAt(charwidth * sizeof(int) * 2 + 8, "PID", true);
ui->listProcesses->addColumnAt(0, "Path", true);
connect(ui->listProcesses, SIGNAL(enterPressedSignal()), this, SLOT(on_btnAttach_clicked()));
connect(ui->listProcesses, SIGNAL(doubleClickedSignal()), this, SLOT(on_btnAttach_clicked()));
connect(ui->listProcesses, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(processListContextMenu(QPoint)));
refresh();
}
AttachDialog::~AttachDialog()
{
delete ui;
}
void AttachDialog::refresh()
{
ui->listProcesses->setRowCount(0);
ui->listProcesses->setTableOffset(0);
DBGPROCESSINFO* entries;
int count;
if(!DbgFunctions()->GetProcessList(&entries, &count))
return;
ui->listProcesses->setRowCount(count);
for(int i = 0; i < count; i++)
{
ui->listProcesses->setCellContent(i, 0, QString().sprintf("%.8X", entries[i].dwProcessId));
ui->listProcesses->setCellContent(i, 1, QString(entries[i].szExeFile));
}
ui->listProcesses->setSingleSelection(0);
ui->listProcesses->reloadData();
}
void AttachDialog::on_btnAttach_clicked()
{
QString pid = ui->listProcesses->getCellContent(ui->listProcesses->getInitialSelection(), 0);
DbgCmdExec(QString("attach " + pid).toUtf8().constData());
accept();
}
void AttachDialog::processListContextMenu(const QPoint & pos)
{
QMenu* wMenu = new QMenu(this); //create context menu
wMenu->addAction(mAttachAction);
wMenu->addAction(mRefreshAction);
QMenu wCopyMenu("&Copy", this);
ui->listProcesses->setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
{
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
}
wMenu->exec(mapToGlobal(pos)); //execute context menu
}

View File

@ -0,0 +1,30 @@
#ifndef ATTACHDIALOG_H
#define ATTACHDIALOG_H
#include <QDialog>
namespace Ui
{
class AttachDialog;
}
class AttachDialog : public QDialog
{
Q_OBJECT
public:
explicit AttachDialog(QWidget* parent = 0);
~AttachDialog();
private slots:
void on_btnAttach_clicked();
void refresh();
void processListContextMenu(const QPoint & pos);
private:
Ui::AttachDialog* ui;
QAction* mAttachAction;
QAction* mRefreshAction;
};
#endif // ATTACHDIALOG_H

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AttachDialog</class>
<widget class="QDialog" name="AttachDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>293</height>
</rect>
</property>
<property name="windowTitle">
<string>Attach</string>
</property>
<property name="windowIcon">
<iconset resource="../../resource.qrc">
<normaloff>:/icons/images/attach.png</normaloff>:/icons/images/attach.png</iconset>
</property>
<widget class="StdTable" name="listProcesses">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>251</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
<widget class="QPushButton" name="btnAttach">
<property name="geometry">
<rect>
<x>450</x>
<y>260</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>&amp;Attach</string>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>530</x>
<y>260</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>StdTable</class>
<extends>QFrame</extends>
<header>StdTable.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../resource.qrc"/>
</resources>
<connections>
<connection>
<sender>btnCancel</sender>
<signal>clicked()</signal>
<receiver>AttachDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>561</x>
<y>272</y>
</hint>
<hint type="destinationlabel">
<x>551</x>
<y>255</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -156,6 +156,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(ui->actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdates())); connect(ui->actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdates()));
connect(ui->actionCallStack, SIGNAL(triggered()), this, SLOT(displayCallstack())); connect(ui->actionCallStack, SIGNAL(triggered()), this, SLOT(displayCallstack()));
connect(ui->actionDonate, SIGNAL(triggered()), this, SLOT(donate())); connect(ui->actionDonate, SIGNAL(triggered()), this, SLOT(donate()));
connect(ui->actionAttach, SIGNAL(triggered()), this, SLOT(displayAttach()));
connect(ui->actionDetach, SIGNAL(triggered()), this, SLOT(detach()));
connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString))); connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString)));
connect(Bridge::getBridge(), SIGNAL(addRecentFile(QString)), this, SLOT(addRecentFile(QString))); connect(Bridge::getBridge(), SIGNAL(addRecentFile(QString)), this, SLOT(addRecentFile(QString)));
@ -231,6 +233,7 @@ void MainWindow::setTab(QWidget* widget)
void MainWindow::refreshShortcuts() void MainWindow::refreshShortcuts()
{ {
ui->actionOpen->setShortcut(ConfigShortcut("FileOpen")); ui->actionOpen->setShortcut(ConfigShortcut("FileOpen"));
ui->actionAttach->setShortcut(ConfigShortcut("FileAttach"));
ui->actionExit->setShortcut(ConfigShortcut("FileExit")); ui->actionExit->setShortcut(ConfigShortcut("FileExit"));
ui->actionCpu->setShortcut(ConfigShortcut("ViewCpu")); ui->actionCpu->setShortcut(ConfigShortcut("ViewCpu"));
@ -253,6 +256,7 @@ void MainWindow::refreshShortcuts()
ui->actionRunSelection->setShortcut(ConfigShortcut("DebugRunSelection")); ui->actionRunSelection->setShortcut(ConfigShortcut("DebugRunSelection"));
ui->actionPause->setShortcut(ConfigShortcut("DebugPause")); ui->actionPause->setShortcut(ConfigShortcut("DebugPause"));
ui->actionRestart->setShortcut(ConfigShortcut("DebugRestart")); ui->actionRestart->setShortcut(ConfigShortcut("DebugRestart"));
ui->actionDetach->setShortcut(ConfigShortcut("DebugDetach"));
ui->actionClose->setShortcut(ConfigShortcut("DebugClose")); ui->actionClose->setShortcut(ConfigShortcut("DebugClose"));
ui->actionStepInto->setShortcut(ConfigShortcut("DebugStepInto")); ui->actionStepInto->setShortcut(ConfigShortcut("DebugStepInto"));
ui->actioneStepInto->setShortcut(ConfigShortcut("DebugeStepInfo")); ui->actioneStepInto->setShortcut(ConfigShortcut("DebugeStepInfo"));
@ -479,11 +483,7 @@ void MainWindow::openFile()
{ {
filename = fileToOpen->text(); filename = fileToOpen->text();
} }
DbgCmdExec(QString("init \"" + filename + "\"").toUtf8().constData());
if(DbgIsDebugging())
DbgCmdExecDirect("stop");
QString cmd;
DbgCmdExec(cmd.sprintf("init \"%s\"", filename.toUtf8().constData()).toUtf8().constData());
//file is from recent menu //file is from recent menu
if(fileToOpen != NULL && fileToOpen->objectName().startsWith("MRU")) if(fileToOpen != NULL && fileToOpen->objectName().startsWith("MRU"))
@ -907,3 +907,14 @@ void MainWindow::donate()
return; return;
QDesktopServices::openUrl(QUrl("https://blockchain.info/address/1GuXgtCrLk4aYgivAT7xAi8zVHWk5CkEoY")); QDesktopServices::openUrl(QUrl("https://blockchain.info/address/1GuXgtCrLk4aYgivAT7xAi8zVHWk5CkEoY"));
} }
void MainWindow::displayAttach()
{
AttachDialog attach(this);
attach.exec();
}
void MainWindow::detach()
{
DbgCmdExec("detach");
}

View File

@ -26,6 +26,7 @@
#include "UpdateChecker.h" #include "UpdateChecker.h"
#include "CallStackView.h" #include "CallStackView.h"
#include "CalculatorDialog.h" #include "CalculatorDialog.h"
#include "AttachDialog.h"
namespace Ui namespace Ui
{ {
@ -94,6 +95,8 @@ public slots:
void refreshShortcuts(); void refreshShortcuts();
void openShortcuts(); void openShortcuts();
void donate(); void donate();
void displayAttach();
void detach();
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;

View File

@ -38,6 +38,7 @@
</widget> </widget>
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="menuRecent_Files"/> <addaction name="menuRecent_Files"/>
<addaction name="actionAttach"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
@ -70,6 +71,7 @@
<addaction name="actionPause"/> <addaction name="actionPause"/>
<addaction name="actionRestart"/> <addaction name="actionRestart"/>
<addaction name="actionClose"/> <addaction name="actionClose"/>
<addaction name="actionDetach"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionStepInto"/> <addaction name="actionStepInto"/>
<addaction name="actioneStepInto"/> <addaction name="actioneStepInto"/>
@ -567,6 +569,30 @@
<string>Calculator</string> <string>Calculator</string>
</property> </property>
</action> </action>
<action name="actionAttach">
<property name="icon">
<iconset resource="../../resource.qrc">
<normaloff>:/icons/images/attach.png</normaloff>:/icons/images/attach.png</iconset>
</property>
<property name="text">
<string>Attach</string>
</property>
<property name="toolTip">
<string>Attach</string>
</property>
</action>
<action name="actionDetach">
<property name="icon">
<iconset resource="../../resource.qrc">
<normaloff>:/icons/images/detach.png</normaloff>:/icons/images/detach.png</iconset>
</property>
<property name="text">
<string>Detach</string>
</property>
<property name="toolTip">
<string>Detach</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources> <resources>

View File

@ -167,6 +167,7 @@ Configuration::Configuration() : QObject()
// hotkeys settings // hotkeys settings
defaultShortcuts.insert("FileOpen", Shortcut(tr("File -> Open"), "F3", true)); defaultShortcuts.insert("FileOpen", Shortcut(tr("File -> Open"), "F3", true));
defaultShortcuts.insert("FileAttach", Shortcut(tr("File -> Attach"), "Alt+A", true));
defaultShortcuts.insert("FileExit", Shortcut(tr("File -> Exit"), "Alt+X", true)); defaultShortcuts.insert("FileExit", Shortcut(tr("File -> Exit"), "Alt+X", true));
defaultShortcuts.insert("ViewCpu", Shortcut(tr("View -> CPU"), "Alt+C", true)); defaultShortcuts.insert("ViewCpu", Shortcut(tr("View -> CPU"), "Alt+C", true));
@ -190,6 +191,7 @@ Configuration::Configuration() : QObject()
defaultShortcuts.insert("DebugPause", Shortcut(tr("Debug -> Pause"), "F12", true)); defaultShortcuts.insert("DebugPause", Shortcut(tr("Debug -> Pause"), "F12", true));
defaultShortcuts.insert("DebugRestart", Shortcut(tr("Debug -> Restart"), "Ctrl+F2", true)); defaultShortcuts.insert("DebugRestart", Shortcut(tr("Debug -> Restart"), "Ctrl+F2", true));
defaultShortcuts.insert("DebugClose", Shortcut(tr("Debug -> Close"), "Alt+F2", true)); defaultShortcuts.insert("DebugClose", Shortcut(tr("Debug -> Close"), "Alt+F2", true));
defaultShortcuts.insert("DebugDetach", Shortcut(tr("Debug -> Detach"), "Ctrl+Alt+F2", true));
defaultShortcuts.insert("DebugStepInto", Shortcut(tr("Debug -> Step into"), "F7", true)); defaultShortcuts.insert("DebugStepInto", Shortcut(tr("Debug -> Step into"), "F7", true));
defaultShortcuts.insert("DebugeStepInfo", Shortcut(tr("Debug -> Step into (skip execptions)"), "Shift+F7", true)); defaultShortcuts.insert("DebugeStepInfo", Shortcut(tr("Debug -> Step into (skip execptions)"), "Shift+F7", true));
defaultShortcuts.insert("DebugStepOver", Shortcut(tr("Debug -> Step over"), "F8", true)); defaultShortcuts.insert("DebugStepOver", Shortcut(tr("Debug -> Step over"), "F8", true));

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

View File

@ -43,5 +43,8 @@
<file>images/shortcut.png</file> <file>images/shortcut.png</file>
<file>images/donate.png</file> <file>images/donate.png</file>
<file>images/calculator.png</file> <file>images/calculator.png</file>
<file>images/attach.png</file>
<file>images/detach.png</file>
<file>images/trace.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -83,7 +83,8 @@ SOURCES += \
Src/Gui/CallStackView.cpp \ Src/Gui/CallStackView.cpp \
Src/Gui/ShortcutsDialog.cpp \ Src/Gui/ShortcutsDialog.cpp \
Src/BasicView/ShortcutEdit.cpp \ Src/BasicView/ShortcutEdit.cpp \
Src/Gui/CalculatorDialog.cpp Src/Gui/CalculatorDialog.cpp \
Src/Gui/AttachDialog.cpp
HEADERS += \ HEADERS += \
@ -145,7 +146,8 @@ HEADERS += \
Src/Gui/CallStackView.h \ Src/Gui/CallStackView.h \
Src/Gui/ShortcutsDialog.h \ Src/Gui/ShortcutsDialog.h \
Src/BasicView/ShortcutEdit.h \ Src/BasicView/ShortcutEdit.h \
Src/Gui/CalculatorDialog.h Src/Gui/CalculatorDialog.h \
Src/Gui/AttachDialog.h
INCLUDEPATH += \ INCLUDEPATH += \
@ -177,7 +179,8 @@ FORMS += \
Src/Gui/PatchDialog.ui \ Src/Gui/PatchDialog.ui \
Src/Gui/PatchDialogGroupSelector.ui \ Src/Gui/PatchDialogGroupSelector.ui \
Src/Gui/ShortcutsDialog.ui \ Src/Gui/ShortcutsDialog.ui \
Src/Gui/CalculatorDialog.ui Src/Gui/CalculatorDialog.ui \
Src/Gui/AttachDialog.ui
INCLUDEPATH += $$PWD/Src/Bridge INCLUDEPATH += $$PWD/Src/Bridge