kernel explorer: Make it single-instance tool

This commit is contained in:
Eladash 2021-01-08 21:05:47 +02:00 committed by Megamouse
parent 07c925223b
commit 70804e2ba6
4 changed files with 33 additions and 8 deletions

View File

@ -3,6 +3,7 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <QHeaderView>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "Emu/IdManager.h"
@ -148,7 +149,9 @@ static QTreeWidgetItem* add_solid_node(QTreeWidget* tree, QTreeWidgetItem *paren
return node;
}
kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent)
kernel_explorer::kernel_explorer(QWidget* parent, std::function<void()> on_destroy)
: QDialog(parent)
, m_on_destroy(on_destroy)
{
setWindowTitle(tr("Kernel Explorer"));
setObjectName("kernel_explorer");
@ -167,11 +170,10 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent)
m_tree->header()->close();
// Merge and display everything
vbox_panel->addSpacing(10);
vbox_panel->addSpacing(8);
vbox_panel->addLayout(hbox_buttons);
vbox_panel->addSpacing(10);
vbox_panel->addSpacing(8);
vbox_panel->addWidget(m_tree);
vbox_panel->addSpacing(10);
setLayout(vbox_panel);
// Events
@ -180,6 +182,11 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent)
Update();
}
kernel_explorer::~kernel_explorer()
{
m_on_destroy();
}
void kernel_explorer::Update()
{
const auto dct = g_fxo->get<lv2_memory_container>();

View File

@ -1,10 +1,11 @@
#pragma once
#include <QDialog>
#include <QTreeWidget>
#include "util/types.hpp"
class QTreeWidget;
class kernel_explorer : public QDialog
{
Q_OBJECT
@ -25,10 +26,12 @@ class kernel_explorer : public QDialog
};
public:
kernel_explorer(QWidget* parent);
kernel_explorer(QWidget* parent, std::function<void()> on_destroy);
~kernel_explorer();
private:
QTreeWidget* m_tree;
std::function<void()> m_on_destroy;
private Q_SLOTS:
void Update();

View File

@ -1238,6 +1238,12 @@ void main_window::OnEmuStop()
{
m_game_list_frame->Refresh();
}
// Close kernel explorer if running
if (m_kernel_explorer)
{
m_kernel_explorer->close();
}
}
void main_window::OnEmuReady()
@ -1759,8 +1765,15 @@ void main_window::CreateConnects()
connect(ui->toolskernel_explorerAct, &QAction::triggered, [this]
{
kernel_explorer* kernelExplorer = new kernel_explorer(this);
kernelExplorer->show();
if (!m_kernel_explorer)
{
m_kernel_explorer = new kernel_explorer(this, [this]()
{
m_kernel_explorer = nullptr;
});
}
m_kernel_explorer->show();
});
connect(ui->toolsmemory_viewerAct, &QAction::triggered, [this]

View File

@ -21,6 +21,7 @@ class game_list_frame;
class gui_settings;
class emu_settings;
class persistent_settings;
class kernel_explorer;
struct gui_game_info;
@ -164,6 +165,7 @@ private:
log_frame* m_log_frame = nullptr;
debugger_frame* m_debugger_frame = nullptr;
game_list_frame* m_game_list_frame = nullptr;
kernel_explorer* m_kernel_explorer = nullptr;
std::shared_ptr<gui_settings> m_gui_settings;
std::shared_ptr<emu_settings> m_emu_settings;
std::shared_ptr<persistent_settings> m_persistent_settings;