mirror of
https://github.com/x64dbg/x64dbg.git
synced 2024-11-23 13:00:14 +00:00
Allow detaching a trace tab
This commit is contained in:
parent
e1b7dfddb6
commit
8d9f129af6
@ -58,7 +58,7 @@ QList<QWidget*> MHTabWidget::windows()
|
||||
return mWindows;
|
||||
}
|
||||
|
||||
// Add a tab
|
||||
// Add a tab with icon
|
||||
int MHTabWidget::addTabEx(QWidget* widget, const QIcon & icon, const QString & label, const QString & nativeName)
|
||||
{
|
||||
mNativeNames.append(nativeName);
|
||||
@ -148,7 +148,15 @@ void MHTabWidget::DetachTab(int index, const QPoint & dropPoint)
|
||||
void MHTabWidget::DeleteTab(int index)
|
||||
{
|
||||
QWidget* w = widget(index);
|
||||
if(index >= QTabWidget::count())
|
||||
{
|
||||
// The tab is detached, so need to re-attach, transfer the widget back to tab widget from detached window
|
||||
MHDetachedWindow* window = dynamic_cast<MHDetachedWindow*>(widget(index)->parent());
|
||||
index = window->mPreviousIndex;
|
||||
AttachTab(window);
|
||||
}
|
||||
mHistory.removeAll((MIDPKey)w);
|
||||
// Delete tab
|
||||
removeTab(index);
|
||||
mNativeNames.removeAt(index);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ signals:
|
||||
public slots:
|
||||
void AttachTab(QWidget* parent);
|
||||
void DetachTab(int index, const QPoint &);
|
||||
void DeleteTab(int index);
|
||||
virtual void DeleteTab(int index);
|
||||
void tabMoved(int from, int to);
|
||||
void OnDetachFocused(QWidget* parent);
|
||||
void currentChanged(int index);
|
||||
|
@ -1,29 +1,28 @@
|
||||
#include <QFrame>
|
||||
#include <QTimerEvent>
|
||||
#include "TraceManager.h"
|
||||
#include "TraceWidget.h"
|
||||
#include "TraceBrowser.h"
|
||||
#include "BrowseDialog.h"
|
||||
#include "MRUList.h"
|
||||
#include "StringUtil.h"
|
||||
#include "MiscUtil.h"
|
||||
#include "TabBar.h"
|
||||
|
||||
TraceManager::TraceManager(QWidget* parent) : QTabWidget(parent)
|
||||
TraceManager::TraceManager(QWidget* parent) : MHTabWidget(parent, true, true)
|
||||
{
|
||||
setMovable(true);
|
||||
|
||||
//MRU
|
||||
//MRU List
|
||||
mMRUList = new MRUList(this, "Recent Trace Files");
|
||||
connect(mMRUList, SIGNAL(openFile(QString)), this, SLOT(openSlot(QString)));
|
||||
mMRUList->load();
|
||||
|
||||
//Close All Tabs
|
||||
mCloseAllTabs = new QPushButton(this);
|
||||
//Close All Tabs Button
|
||||
QPushButton* mCloseAllTabs = new QPushButton(this);
|
||||
mCloseAllTabs->setIcon(DIcon("close-all-tabs"));
|
||||
mCloseAllTabs->setToolTip(tr("Close All Tabs"));
|
||||
connect(mCloseAllTabs, SIGNAL(clicked()), this, SLOT(closeAllTabs()));
|
||||
setCornerWidget(mCloseAllTabs, Qt::TopLeftCorner);
|
||||
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
||||
connect(Bridge::getBridge(), SIGNAL(openTraceFile(const QString &)), this, SLOT(openSlot(const QString &)));
|
||||
}
|
||||
|
||||
@ -51,14 +50,22 @@ void TraceManager::openSlot(const QString & path)
|
||||
{
|
||||
//load the new file
|
||||
TraceWidget* newView = new TraceWidget(Bridge::getArchitecture(), path, this);
|
||||
addTab(newView, path); //TODO: Proper title
|
||||
addTabEx(newView, DIcon("trace"), path, path); //TODO: Proper title
|
||||
int index = count() - 1;
|
||||
setCurrentIndex(index);
|
||||
mMRUList->addEntry(path);
|
||||
mMRUList->save();
|
||||
connect(newView, &TraceWidget::closeFile, this, [index, this]()
|
||||
connect(newView, &TraceWidget::closeFile, this, [newView, this]()
|
||||
{
|
||||
closeTab(index);
|
||||
// Find index, it could be moved by the user to another position
|
||||
for(int index = 0; index < count(); index++)
|
||||
{
|
||||
if(widget(index) == newView)
|
||||
{
|
||||
DeleteTab(index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(newView, &TraceWidget::displayLogWidget, this, [this]()
|
||||
{
|
||||
@ -66,21 +73,21 @@ void TraceManager::openSlot(const QString & path)
|
||||
});
|
||||
}
|
||||
|
||||
void TraceManager::closeTab(int index)
|
||||
void TraceManager::DeleteTab(int index)
|
||||
{
|
||||
auto view = qobject_cast<TraceWidget*>(widget(index));
|
||||
if(view)
|
||||
{
|
||||
removeTab(index);
|
||||
view->deleteLater(); // It needs to return from close event before we can delete
|
||||
}
|
||||
MHTabWidget::DeleteTab(index); // Tell the parent class to close the tab
|
||||
}
|
||||
|
||||
void TraceManager::closeAllTabs()
|
||||
{
|
||||
while(count())
|
||||
{
|
||||
closeTab(count() - 1);
|
||||
DeleteTab(count() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
#include <QTabWidget>
|
||||
#include <QPushButton>
|
||||
#include <QMap>
|
||||
#include "TraceWidget.h"
|
||||
#include "TabWidget.h"
|
||||
|
||||
class MRUList;
|
||||
|
||||
class TraceManager : public QTabWidget
|
||||
class TraceManager : public MHTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -22,11 +22,10 @@ signals:
|
||||
public slots:
|
||||
void open();
|
||||
void openSlot(const QString &);
|
||||
void closeTab(int index);
|
||||
void DeleteTab(int index) override;
|
||||
void closeAllTabs();
|
||||
void toggleTraceRecording();
|
||||
|
||||
private:
|
||||
MRUList* mMRUList;
|
||||
QPushButton* mCloseAllTabs;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user