mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
fix: workspace panel — preserve expansion on clear, dock title counts, drop kind text, close.svg clear button
This commit is contained in:
41
src/main.cpp
41
src/main.cpp
@@ -3381,7 +3381,7 @@ void MainWindow::createWorkspaceDock() {
|
||||
|
||||
m_workspaceSearch = new QLineEdit(dockContainer);
|
||||
m_workspaceSearch->setPlaceholderText(QStringLiteral("Search..."));
|
||||
m_workspaceSearch->setClearButtonEnabled(true);
|
||||
// Clear button uses our close.svg icon instead of Qt's default circle-X
|
||||
{
|
||||
QSettings s("Reclass", "Reclass");
|
||||
QFont f(s.value("font", "JetBrains Mono").toString(), 10);
|
||||
@@ -3400,6 +3400,24 @@ void MainWindow::createWorkspaceDock() {
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
auto* clearAction = m_workspaceSearch->addAction(
|
||||
QIcon(QStringLiteral(":/vsicons/close.svg")),
|
||||
QLineEdit::TrailingPosition);
|
||||
clearAction->setVisible(false);
|
||||
connect(clearAction, &QAction::triggered,
|
||||
m_workspaceSearch, &QLineEdit::clear);
|
||||
connect(m_workspaceSearch, &QLineEdit::textChanged,
|
||||
clearAction, [clearAction](const QString& text) {
|
||||
clearAction->setVisible(!text.isEmpty());
|
||||
});
|
||||
for (auto* btn : m_workspaceSearch->findChildren<QToolButton*>()) {
|
||||
if (btn->defaultAction() == clearAction) {
|
||||
btn->setIconSize(QSize(14, 14));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
const auto& t = ThemeManager::instance().current();
|
||||
m_workspaceSearch->setStyleSheet(QStringLiteral(
|
||||
@@ -3439,8 +3457,6 @@ void MainWindow::createWorkspaceDock() {
|
||||
m_workspaceProxy->setFilterFixedString(text);
|
||||
if (!text.isEmpty())
|
||||
m_workspaceTree->expandAll();
|
||||
else
|
||||
m_workspaceTree->collapseAll();
|
||||
});
|
||||
|
||||
// Custom delegate for rich text rendering (name bright, metadata dim)
|
||||
@@ -3807,6 +3823,25 @@ void MainWindow::rebuildWorkspaceModelNow() {
|
||||
tabs.append({ &tab.doc->tree, name, static_cast<void*>(it.key()) });
|
||||
}
|
||||
rcx::syncProjectExplorer(m_workspaceModel, tabs);
|
||||
|
||||
if (m_dockTitleLabel) {
|
||||
int structs = 0, enums = 0;
|
||||
for (int i = 0; i < m_workspaceModel->rowCount(); ++i) {
|
||||
if (m_workspaceModel->item(i)->data(Qt::UserRole + 2).toBool())
|
||||
++enums;
|
||||
else
|
||||
++structs;
|
||||
}
|
||||
QString title = QStringLiteral("Project");
|
||||
if (structs || enums) {
|
||||
title += QStringLiteral(" \u2014 %1 struct%2")
|
||||
.arg(structs).arg(structs != 1 ? "s" : "");
|
||||
if (enums)
|
||||
title += QStringLiteral(" \u00b7 %1 enum%2")
|
||||
.arg(enums).arg(enums != 1 ? "s" : "");
|
||||
}
|
||||
m_dockTitleLabel->setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::addRecentFile(const QString& path) {
|
||||
|
||||
@@ -60,17 +60,16 @@ inline QString typeDisplayString(const Node* node, const NodeTree* tree) {
|
||||
return n->structTypeName.isEmpty() ? n->name : n->structTypeName;
|
||||
};
|
||||
if (node->resolvedClassKeyword() == QStringLiteral("enum")) {
|
||||
return QStringLiteral("%1 (%2) \u2014 %3")
|
||||
.arg(nameOf(node), node->resolvedClassKeyword(),
|
||||
return QStringLiteral("%1 \u2014 %2")
|
||||
.arg(nameOf(node),
|
||||
QString::number(node->enumMembers.size()));
|
||||
}
|
||||
QVector<int> members = tree->childrenOf(node->id);
|
||||
int vc = 0;
|
||||
for (int mi : members)
|
||||
if (!isHexPad(tree->nodes[mi].kind)) ++vc;
|
||||
return QStringLiteral("%1 (%2) \u2014 %3")
|
||||
.arg(nameOf(node), node->resolvedClassKeyword(),
|
||||
QString::number(vc));
|
||||
return QStringLiteral("%1 \u2014 %2")
|
||||
.arg(nameOf(node), QString::number(vc));
|
||||
}
|
||||
|
||||
// Build a new item for a type entry.
|
||||
@@ -83,6 +82,7 @@ inline QStandardItem* makeTypeItem(const Node* node, const NodeTree* tree,
|
||||
typeDisplayString(node, tree));
|
||||
item->setData(QVariant::fromValue(subPtr), Qt::UserRole);
|
||||
item->setData(QVariant::fromValue(node->id), Qt::UserRole + 1);
|
||||
item->setData(isEnum, Qt::UserRole + 2);
|
||||
|
||||
if (!isEnum)
|
||||
buildStructChildren(item, tree, node->id, subPtr);
|
||||
@@ -243,12 +243,11 @@ public:
|
||||
painter->setFont(opt.font);
|
||||
|
||||
if (!isChild) {
|
||||
// Top-level: "StructName (class) — 3"
|
||||
// Top-level: "StructName — 3"
|
||||
int dashPos = fullText.indexOf(QChar(0x2014));
|
||||
int parenPos = dashPos > 0 ? fullText.lastIndexOf(QStringLiteral(" ("), dashPos) : -1;
|
||||
if (parenPos > 0) {
|
||||
QString name = fullText.left(parenPos);
|
||||
QString meta = fullText.mid(parenPos);
|
||||
if (dashPos > 1) {
|
||||
QString name = fullText.left(dashPos - 1);
|
||||
QString meta = fullText.mid(dashPos - 1);
|
||||
|
||||
painter->setPen(m_text);
|
||||
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, name);
|
||||
|
||||
Reference in New Issue
Block a user