mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
feat: project tree delete, close tab, Linux AppImage bundling
- Right-click delete on classes in Project Tree dock - File > Close (Ctrl+W) to unload active project tab - File > Open now replaces current project instead of merging - Linux CI builds AppImage via linuxdeploy + Qt plugin so users don't need Qt installed (fixes libQt6Core.so.6 not found) - Pin ubuntu-22.04 for broader glibc compatibility
This commit is contained in:
37
src/main.cpp
37
src/main.cpp
@@ -364,6 +364,8 @@ void MainWindow::createMenus() {
|
||||
file->addAction(makeIcon(":/vsicons/save.svg"), "&Save", QKeySequence::Save, this, &MainWindow::saveFile);
|
||||
file->addAction(makeIcon(":/vsicons/save-as.svg"), "Save &As...", QKeySequence::SaveAs, this, &MainWindow::saveFileAs);
|
||||
file->addSeparator();
|
||||
file->addAction(makeIcon(":/vsicons/close.svg"), "&Close", QKeySequence(Qt::CTRL | Qt::Key_W), this, &MainWindow::closeFile);
|
||||
file->addSeparator();
|
||||
file->addAction(makeIcon(":/vsicons/export.svg"), "Export &C++ Header...", this, &MainWindow::exportCpp);
|
||||
file->addSeparator();
|
||||
m_mcpAction = file->addAction(QSettings("Reclass", "Reclass").value("autoStartMcp", false).toBool() ? "Stop &MCP Server" : "Start &MCP Server", this, &MainWindow::toggleMcp);
|
||||
@@ -838,6 +840,10 @@ void MainWindow::saveFileAs() {
|
||||
project_save(nullptr, true);
|
||||
}
|
||||
|
||||
void MainWindow::closeFile() {
|
||||
project_close();
|
||||
}
|
||||
|
||||
void MainWindow::addNode() {
|
||||
auto* ctrl = activeController();
|
||||
if (!ctrl) return;
|
||||
@@ -1392,6 +1398,10 @@ QMdiSubWindow* MainWindow::project_open(const QString& path) {
|
||||
delete doc;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Close all existing tabs so the project replaces the current state
|
||||
m_mdiArea->closeAllSubWindows();
|
||||
|
||||
auto* sub = createTab(doc);
|
||||
rebuildWorkspaceModel();
|
||||
return sub;
|
||||
@@ -1437,11 +1447,36 @@ void MainWindow::createWorkspaceDock() {
|
||||
m_workspaceTree->setExpandsOnDoubleClick(false);
|
||||
m_workspaceTree->setMouseTracking(true);
|
||||
|
||||
m_workspaceTree->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_workspaceTree, &QWidget::customContextMenuRequested, this, [this](const QPoint& pos) {
|
||||
QModelIndex index = m_workspaceTree->indexAt(pos);
|
||||
if (!index.isValid()) return;
|
||||
|
||||
auto structIdVar = index.data(Qt::UserRole + 1);
|
||||
uint64_t structId = structIdVar.isValid() ? structIdVar.toULongLong() : 0;
|
||||
if (structId == 0 || structId == rcx::kGroupSentinel) return;
|
||||
|
||||
auto subVar = index.data(Qt::UserRole);
|
||||
if (!subVar.isValid()) return;
|
||||
auto* sub = static_cast<QMdiSubWindow*>(subVar.value<void*>());
|
||||
if (!sub || !m_tabs.contains(sub)) return;
|
||||
|
||||
QMenu menu;
|
||||
auto* deleteAction = menu.addAction(QIcon(":/vsicons/remove.svg"), "Delete");
|
||||
if (menu.exec(m_workspaceTree->viewport()->mapToGlobal(pos)) == deleteAction) {
|
||||
auto& tab = m_tabs[sub];
|
||||
int ni = tab.doc->tree.indexOfId(structId);
|
||||
if (ni >= 0) {
|
||||
tab.ctrl->removeNode(ni);
|
||||
rebuildWorkspaceModel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
m_workspaceDock->setWidget(m_workspaceTree);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, m_workspaceDock);
|
||||
m_workspaceDock->hide();
|
||||
|
||||
|
||||
connect(m_workspaceTree, &QTreeView::doubleClicked, this, [this](const QModelIndex& index) {
|
||||
auto structIdVar = index.data(Qt::UserRole + 1);
|
||||
uint64_t structId = structIdVar.isValid() ? structIdVar.toULongLong() : 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ private slots:
|
||||
void openFile();
|
||||
void saveFile();
|
||||
void saveFileAs();
|
||||
|
||||
void closeFile();
|
||||
|
||||
void addNode();
|
||||
void removeNode();
|
||||
|
||||
Reference in New Issue
Block a user