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 = new QLineEdit(dockContainer);
|
||||||
m_workspaceSearch->setPlaceholderText(QStringLiteral("Search..."));
|
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");
|
QSettings s("Reclass", "Reclass");
|
||||||
QFont f(s.value("font", "JetBrains Mono").toString(), 10);
|
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();
|
const auto& t = ThemeManager::instance().current();
|
||||||
m_workspaceSearch->setStyleSheet(QStringLiteral(
|
m_workspaceSearch->setStyleSheet(QStringLiteral(
|
||||||
@@ -3439,8 +3457,6 @@ void MainWindow::createWorkspaceDock() {
|
|||||||
m_workspaceProxy->setFilterFixedString(text);
|
m_workspaceProxy->setFilterFixedString(text);
|
||||||
if (!text.isEmpty())
|
if (!text.isEmpty())
|
||||||
m_workspaceTree->expandAll();
|
m_workspaceTree->expandAll();
|
||||||
else
|
|
||||||
m_workspaceTree->collapseAll();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Custom delegate for rich text rendering (name bright, metadata dim)
|
// 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()) });
|
tabs.append({ &tab.doc->tree, name, static_cast<void*>(it.key()) });
|
||||||
}
|
}
|
||||||
rcx::syncProjectExplorer(m_workspaceModel, tabs);
|
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) {
|
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;
|
return n->structTypeName.isEmpty() ? n->name : n->structTypeName;
|
||||||
};
|
};
|
||||||
if (node->resolvedClassKeyword() == QStringLiteral("enum")) {
|
if (node->resolvedClassKeyword() == QStringLiteral("enum")) {
|
||||||
return QStringLiteral("%1 (%2) \u2014 %3")
|
return QStringLiteral("%1 \u2014 %2")
|
||||||
.arg(nameOf(node), node->resolvedClassKeyword(),
|
.arg(nameOf(node),
|
||||||
QString::number(node->enumMembers.size()));
|
QString::number(node->enumMembers.size()));
|
||||||
}
|
}
|
||||||
QVector<int> members = tree->childrenOf(node->id);
|
QVector<int> members = tree->childrenOf(node->id);
|
||||||
int vc = 0;
|
int vc = 0;
|
||||||
for (int mi : members)
|
for (int mi : members)
|
||||||
if (!isHexPad(tree->nodes[mi].kind)) ++vc;
|
if (!isHexPad(tree->nodes[mi].kind)) ++vc;
|
||||||
return QStringLiteral("%1 (%2) \u2014 %3")
|
return QStringLiteral("%1 \u2014 %2")
|
||||||
.arg(nameOf(node), node->resolvedClassKeyword(),
|
.arg(nameOf(node), QString::number(vc));
|
||||||
QString::number(vc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a new item for a type entry.
|
// Build a new item for a type entry.
|
||||||
@@ -83,6 +82,7 @@ inline QStandardItem* makeTypeItem(const Node* node, const NodeTree* tree,
|
|||||||
typeDisplayString(node, tree));
|
typeDisplayString(node, tree));
|
||||||
item->setData(QVariant::fromValue(subPtr), Qt::UserRole);
|
item->setData(QVariant::fromValue(subPtr), Qt::UserRole);
|
||||||
item->setData(QVariant::fromValue(node->id), Qt::UserRole + 1);
|
item->setData(QVariant::fromValue(node->id), Qt::UserRole + 1);
|
||||||
|
item->setData(isEnum, Qt::UserRole + 2);
|
||||||
|
|
||||||
if (!isEnum)
|
if (!isEnum)
|
||||||
buildStructChildren(item, tree, node->id, subPtr);
|
buildStructChildren(item, tree, node->id, subPtr);
|
||||||
@@ -243,12 +243,11 @@ public:
|
|||||||
painter->setFont(opt.font);
|
painter->setFont(opt.font);
|
||||||
|
|
||||||
if (!isChild) {
|
if (!isChild) {
|
||||||
// Top-level: "StructName (class) — 3"
|
// Top-level: "StructName — 3"
|
||||||
int dashPos = fullText.indexOf(QChar(0x2014));
|
int dashPos = fullText.indexOf(QChar(0x2014));
|
||||||
int parenPos = dashPos > 0 ? fullText.lastIndexOf(QStringLiteral(" ("), dashPos) : -1;
|
if (dashPos > 1) {
|
||||||
if (parenPos > 0) {
|
QString name = fullText.left(dashPos - 1);
|
||||||
QString name = fullText.left(parenPos);
|
QString meta = fullText.mid(dashPos - 1);
|
||||||
QString meta = fullText.mid(parenPos);
|
|
||||||
|
|
||||||
painter->setPen(m_text);
|
painter->setPen(m_text);
|
||||||
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, name);
|
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, name);
|
||||||
|
|||||||
Reference in New Issue
Block a user