Merge pull request #2405 from torusrxxx/patch0000009c
make graph detachable again
This commit is contained in:
commit
0355f2fd07
|
|
@ -1,5 +1,6 @@
|
|||
#include "CPUWidget.h"
|
||||
#include "ui_CPUWidget.h"
|
||||
#include <QDesktopWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include "CPUSideBar.h"
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
#include "CPUArgumentWidget.h"
|
||||
#include "DisassemblerGraphView.h"
|
||||
#include "Configuration.h"
|
||||
#include "TabWidget.h"
|
||||
|
||||
CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
|
||||
{
|
||||
|
|
@ -28,6 +30,7 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
|
|||
connect(mDisas, SIGNAL(tableOffsetChanged(dsint)), mSideBar, SLOT(changeTopmostAddress(dsint)));
|
||||
connect(mDisas, SIGNAL(viewableRowsChanged(int)), mSideBar, SLOT(setViewableRows(int)));
|
||||
connect(mDisas, SIGNAL(selectionChanged(dsint)), mSideBar, SLOT(setSelection(dsint)));
|
||||
connect(mGraph, SIGNAL(detachGraph()), this, SLOT(detachGraph()));
|
||||
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), mSideBar, SLOT(debugStateChangedSlot(DBGSTATE)));
|
||||
connect(Bridge::getBridge(), SIGNAL(updateSideBar()), mSideBar, SLOT(reload()));
|
||||
connect(Bridge::getBridge(), SIGNAL(updateArgumentView()), mArgumentWidget, SLOT(refreshData()));
|
||||
|
|
@ -40,7 +43,8 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
|
|||
ui->mTopLeftUpperRightFrameLayout->addWidget(mDisas);
|
||||
ui->mTopLeftUpperRightFrameLayout->addWidget(mGraph);
|
||||
mGraph->hide();
|
||||
disasMode = true;
|
||||
disasMode = 0;
|
||||
mGraphWindow = nullptr;
|
||||
|
||||
ui->mTopLeftVSplitter->setCollapsible(1, true); //allow collapsing of the InfoBox
|
||||
connect(ui->mTopLeftVSplitter, SIGNAL(splitterMoved(int, int)), this, SLOT(splitterMoved(int, int)));
|
||||
|
|
@ -121,6 +125,7 @@ void CPUWidget::loadWindowSettings()
|
|||
|
||||
CPUWidget::~CPUWidget()
|
||||
{
|
||||
delete mGraphWindow;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
@ -155,35 +160,101 @@ void CPUWidget::setDefaultDisposition()
|
|||
|
||||
void CPUWidget::setDisasmFocus()
|
||||
{
|
||||
if(!disasMode)
|
||||
if(disasMode == 1)
|
||||
{
|
||||
mGraph->hide();
|
||||
mDisas->show();
|
||||
mSideBar->show();
|
||||
disasMode = true;
|
||||
disasMode = 0;
|
||||
connect(mDisas, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
disconnect(mGraph, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
}
|
||||
else if(disasMode == 2)
|
||||
{
|
||||
activateWindow();
|
||||
}
|
||||
mDisas->setFocus();
|
||||
}
|
||||
|
||||
void CPUWidget::setGraphFocus()
|
||||
{
|
||||
if(disasMode)
|
||||
if(disasMode == 0)
|
||||
{
|
||||
mDisas->hide();
|
||||
mSideBar->hide();
|
||||
mGraph->show();
|
||||
disasMode = false;
|
||||
disasMode = 1;
|
||||
disconnect(mDisas, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
connect(mGraph, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
}
|
||||
else if(disasMode == 2)
|
||||
{
|
||||
mGraph->activateWindow();
|
||||
}
|
||||
mGraph->setFocus();
|
||||
}
|
||||
|
||||
void CPUWidget::detachGraph()
|
||||
{
|
||||
if(mGraphWindow == nullptr)
|
||||
{
|
||||
mGraphWindow = new MHDetachedWindow(this);
|
||||
|
||||
mGraphWindow->setWindowModality(Qt::NonModal);
|
||||
|
||||
// Find Widget and connect
|
||||
connect(mGraphWindow, SIGNAL(OnClose(QWidget*)), this, SLOT(attachGraph(QWidget*)));
|
||||
|
||||
mGraphWindow->setWindowTitle(tr("Graph"));
|
||||
mGraphWindow->setWindowIcon(mGraph->windowIcon());
|
||||
mGraphWindow->mNativeName = "";
|
||||
|
||||
mGraph->setParent(mGraphWindow);
|
||||
ui->mTopLeftUpperRightFrameLayout->removeWidget(mGraph);
|
||||
|
||||
// Create and show
|
||||
mGraphWindow->show();
|
||||
mGraphWindow->setCentralWidget(mGraph);
|
||||
|
||||
// Needs to be done explicitly
|
||||
mGraph->showNormal();
|
||||
QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
||||
int w = 640;
|
||||
int h = 480;
|
||||
int x = (screenGeometry.width() - w) / 2;
|
||||
int y = (screenGeometry.height() - h) / 2;
|
||||
mGraphWindow->showNormal();
|
||||
mGraphWindow->setGeometry(x, y, w, h);
|
||||
mGraphWindow->showNormal();
|
||||
|
||||
disasMode = 2;
|
||||
|
||||
mDisas->show();
|
||||
mSideBar->show();
|
||||
connect(mDisas, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
connect(mGraph, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
}
|
||||
}
|
||||
|
||||
void CPUWidget::attachGraph(QWidget* widget)
|
||||
{
|
||||
mGraph->setParent(this);
|
||||
ui->mTopLeftUpperRightFrameLayout->addWidget(mGraph);
|
||||
mGraph->hide();
|
||||
mGraphWindow->close();
|
||||
disconnect(mGraph, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
|
||||
delete mGraphWindow;
|
||||
mGraphWindow = nullptr;
|
||||
disasMode = 0;
|
||||
}
|
||||
|
||||
//This is used in run to selection
|
||||
duint CPUWidget::getSelectionVa()
|
||||
{
|
||||
return disasMode ? mDisas->getSelectedVa() : mGraph->get_cursor_pos();
|
||||
if(disasMode < 2)
|
||||
return disasMode == 0 ? mDisas->getSelectedVa() : mGraph->get_cursor_pos();
|
||||
else
|
||||
return !mGraph->hasFocus() ? mDisas->getSelectedVa() : mGraph->get_cursor_pos();
|
||||
}
|
||||
|
||||
CPUSideBar* CPUWidget::getSidebarWidget()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class CPURegistersView;
|
|||
class CPUInfoBox;
|
||||
class CPUArgumentWidget;
|
||||
class DisassemblerGraphView;
|
||||
class MHDetachedWindow;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
|
@ -48,19 +49,22 @@ protected:
|
|||
CPUSideBar* mSideBar;
|
||||
CPUDisassembly* mDisas;
|
||||
DisassemblerGraphView* mGraph;
|
||||
MHDetachedWindow* mGraphWindow;
|
||||
CPUMultiDump* mDump;
|
||||
CPUStack* mStack;
|
||||
CPURegistersView* mGeneralRegs;
|
||||
CPUInfoBox* mInfo;
|
||||
CPUArgumentWidget* mArgumentWidget;
|
||||
|
||||
bool disasMode;
|
||||
int disasMode;
|
||||
|
||||
private:
|
||||
Ui::CPUWidget* ui;
|
||||
|
||||
private slots:
|
||||
void splitterMoved(int pos, int index);
|
||||
void attachGraph(QWidget* widget);
|
||||
void detachGraph();
|
||||
};
|
||||
|
||||
#endif // CPUWIDGET_H
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include "BreakpointMenu.h"
|
||||
#include "StringUtil.h"
|
||||
#include "MiscUtil.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
DisassemblerGraphView::DisassemblerGraphView(QWidget* parent)
|
||||
: QAbstractScrollArea(parent),
|
||||
|
|
@ -59,6 +60,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget* parent)
|
|||
this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
this->horizontalScrollBar()->setSingleStep(this->charWidth);
|
||||
this->verticalScrollBar()->setSingleStep(this->charHeight);
|
||||
this->setWindowIcon(DIcon("graph.png"));
|
||||
|
||||
//QSize areaSize = this->viewport()->size(); <-\
|
||||
//this->adjustSize(areaSize.width(), areaSize.height()); <-- useless at this point (?)
|
||||
|
|
@ -2317,6 +2319,8 @@ void DisassemblerGraphView::setupContextMenu()
|
|||
|
||||
mPluginMenu = new QMenu(this);
|
||||
Bridge::getBridge()->emitMenuAddToList(this, mPluginMenu, GUI_GRAPH_MENU);
|
||||
mMenuBuilder->addAction(makeAction(tr("Detach"), [this]() { emit detachGraph(); }), [this](QMenu*) { return qobject_cast<QMainWindow*>(this->parent()) == nullptr; });
|
||||
|
||||
mMenuBuilder->addSeparator();
|
||||
mMenuBuilder->addBuilder(new MenuBuilder(this, [this](QMenu * menu)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ public:
|
|||
|
||||
signals:
|
||||
void selectionChanged(dsint parVA);
|
||||
void detachGraph();
|
||||
|
||||
public slots:
|
||||
void loadGraphSlot(BridgeCFGraphList* graph, duint addr);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ void MHTabWidget::DetachTab(int index, const QPoint & dropPoint)
|
|||
{
|
||||
Q_UNUSED(dropPoint);
|
||||
// Create the window
|
||||
MHDetachedWindow* detachedWidget = new MHDetachedWindow(parentWidget(), this);
|
||||
MHDetachedWindow* detachedWidget = new MHDetachedWindow(parentWidget());
|
||||
detachedWidget->setWindowModality(Qt::NonModal);
|
||||
|
||||
// Find Widget and connect
|
||||
|
|
@ -331,9 +331,8 @@ void MHTabWidget::deleteCurrentTab()
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
MHDetachedWindow::MHDetachedWindow(QWidget* parent, MHTabWidget* tabwidget) : QMainWindow(parent)
|
||||
MHDetachedWindow::MHDetachedWindow(QWidget* parent) : QMainWindow(parent)
|
||||
{
|
||||
mTabWidget = tabwidget;
|
||||
}
|
||||
|
||||
MHDetachedWindow::~MHDetachedWindow()
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class MHDetachedWindow : public QMainWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MHDetachedWindow(QWidget* parent = 0, MHTabWidget* tabwidget = 0);
|
||||
MHDetachedWindow(QWidget* parent = 0);
|
||||
~MHDetachedWindow();
|
||||
|
||||
QString mNativeName;
|
||||
|
|
@ -89,8 +89,6 @@ signals:
|
|||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
bool event(QEvent* event);
|
||||
|
||||
MHTabWidget* mTabWidget;
|
||||
};
|
||||
|
||||
#endif // __MHTABWIDGET_H__
|
||||
|
|
|
|||
Loading…
Reference in New Issue