From e791e403d8af2ac3409989e6842b6a40b2ab3aef Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 8 Oct 2026 11:43:45 +0200 Subject: [PATCH] Palette: make the file and symbol switchers full-width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/plugin/ollieplugin.cpp | 40 ++++++++++++++++++++------------------ src/plugin/ollieplugin.h | 5 +++++ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/plugin/ollieplugin.cpp b/src/plugin/ollieplugin.cpp index 76d358e..52db469 100644 --- a/src/plugin/ollieplugin.cpp +++ b/src/plugin/ollieplugin.cpp @@ -408,6 +408,23 @@ QList 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); diff --git a/src/plugin/ollieplugin.h b/src/plugin/ollieplugin.h index e7258c8..9d31486 100644 --- a/src/plugin/ollieplugin.h +++ b/src/plugin/ollieplugin.h @@ -85,6 +85,11 @@ private: // async-arrival paths). Root is used to project-qualify the frecency key. QList buildFileItems(const QString &root, const QStringList &files) const; QList buildSymbolItems(const QString &root, const QList &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 {