Palette: make the file and symbol switchers full-width

Add OllieView::positionPalette(palette, fullWidth) and route all three
palettes through it. The Go-to-File and Go-to-Symbol switchers now span
the window width (minus a 12px margin) — long project-relative paths and
scope-qualified symbol labels fit without truncation. The M-x command
palette keeps its compact centered width. Replaces three duplicated
center-positioning blocks.
This commit is contained in:
Levi Neely 2026-10-08 11:43:45 +02:00
parent 00f81f7f56
commit e791e403d8
2 changed files with 26 additions and 19 deletions

View File

@ -408,6 +408,23 @@ QList<OllieView::ActionEntry> OllieView::collectActions() const
return entries;
}
void OllieView::positionPalette(PaletteWidget *palette, bool fullWidth)
{
QWidget *w = m_mainWindow->window();
if (!w) {
return;
}
const int margin = 12;
const int y = w->height() / 6;
if (fullWidth) {
palette->resize(w->width() - 2 * margin, 320);
palette->move(w->mapToGlobal(QPoint(margin, y)));
} else {
const QSize sz = palette->size();
palette->move(w->mapToGlobal(QPoint((w->width() - sz.width()) / 2, y)));
}
}
void OllieView::showCommandPalette()
{
if (!m_palette) {
@ -465,13 +482,8 @@ void OllieView::showCommandPalette()
m_palette->setItems(items);
// Center the palette near the top of the active window.
if (QWidget *w = m_mainWindow->window()) {
const QSize sz = m_palette->size();
const QPoint topLeft = w->mapToGlobal(QPoint((w->width() - sz.width()) / 2,
w->height() / 6));
m_palette->move(topLeft);
}
// The command palette keeps its compact centered width.
positionPalette(m_palette, /*fullWidth=*/false);
m_palette->activate();
}
@ -600,12 +612,7 @@ void OllieView::showFileSwitcher()
m_filePalette->setItems({loading});
}
if (QWidget *w = m_mainWindow->window()) {
const QSize sz = m_filePalette->size();
const QPoint topLeft = w->mapToGlobal(QPoint((w->width() - sz.width()) / 2,
w->height() / 6));
m_filePalette->move(topLeft);
}
positionPalette(m_filePalette, /*fullWidth=*/true);
m_filePalette->activate();
// Kick off (or serve from cache) the index; filesReady repopulates.
@ -700,12 +707,7 @@ void OllieView::showSymbolSwitcher()
m_symbolPalette->setItems({loading});
}
if (QWidget *w = m_mainWindow->window()) {
const QSize sz = m_symbolPalette->size();
const QPoint topLeft = w->mapToGlobal(QPoint((w->width() - sz.width()) / 2,
w->height() / 6));
m_symbolPalette->move(topLeft);
}
positionPalette(m_symbolPalette, /*fullWidth=*/true);
m_symbolPalette->activate();
m_indexer.requestSymbols(m_symbolSwitcherRoot);

View File

@ -85,6 +85,11 @@ private:
// async-arrival paths). Root is used to project-qualify the frecency key.
QList<PaletteItem> buildFileItems(const QString &root, const QStringList &files) const;
QList<PaletteItem> buildSymbolItems(const QString &root, const QList<Symbol> &symbols) const;
// Size and place a palette near the top of the active window. When
// \a fullWidth, it spans the window width (minus a small margin); otherwise
// it keeps its own width and is horizontally centered.
void positionPalette(PaletteWidget *palette, bool fullWidth);
// One harvested, runnable action with the provenance needed to build a
// unique id and to disambiguate labels shared by several commands.
struct ActionEntry {